constructor()

in src/oidc_role_arn_credential.ts [16:56]


  constructor(config: Config, runtime: { [key: string]: any } = {}) {
    if (!config.roleArn) {
      config.roleArn = process.env.ALIBABA_CLOUD_ROLE_ARN;
      if (!config.roleArn) {
        throw new Error('roleArn does not exist and env ALIBABA_CLOUD_ROLE_ARN is null.');
      }
    }

    if (!config.oidcProviderArn) {
      config.oidcProviderArn = process.env.ALIBABA_CLOUD_OIDC_PROVIDER_ARN;
      if (!config.oidcProviderArn) {
        throw new Error('oidcProviderArn does not exist and env ALIBABA_CLOUD_OIDC_PROVIDER_ARN is null.');
      }
    }

    if (!config.oidcTokenFilePath) {
      config.oidcTokenFilePath = process.env.ALIBABA_CLOUD_OIDC_TOKEN_FILE;
      if (!config.oidcTokenFilePath) {
        throw new Error('oidcTokenFilePath is not exists and env ALIBABA_CLOUD_OIDC_TOKEN_FILE is null.');
      }
    }

    if (!config.roleSessionName && process.env.ALIBABA_CLOUD_ROLE_SESSION_NAME) {
      config.roleSessionName = process.env.ALIBABA_CLOUD_ROLE_SESSION_NAME;
    }

    const conf = new Config({
      type: 'oidc_role_arn'
    });
    super(conf);
    this.oidcTokenFilePath = config.oidcTokenFilePath;
    this.roleArn = config.roleArn;
    this.policy = config.policy;
    this.oidcProviderArn = config.oidcProviderArn;
    this.durationSeconds = config.roleSessionExpiration || 3600;
    this.roleSessionName = config.roleSessionName || 'role_session_name';
    runtime.method = 'POST';
    runtime.anonymous = true;
    this.runtime = runtime;
    this.host = 'https://sts.aliyuncs.com';
  }