@alicloud/sts-sdk
alibaba cloud sts client for node.js
Last updated 7 years ago by hyj1991 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @alicloud/sts-sdk 
SYNC missed versions from official npm registry.

Alibaba Cloud STS client for Node.js

npm version Travis Build Status Appveyor Build status codecov license

Installation

npm install @alicloud/sts-sdk

Node.js >= 8.5.0 required.

Usage

const StsClient = require('@alicloud/sts-sdk');

const sts = new StsClient({
  endpoint: 'sts.aliyuncs.com', // check this from sts console
  accessKeyId: '***************', // check this from aliyun console
  accessKeySecret: '***************', // check this from aliyun console
});

async function demo() {
  const res1 = await sts.assumeRole(`acs:ram::${accountID}:role/${roleName}`, 'xxx');
  console.log(res1);
  const res2 = await sts.getCallerIdentity();
  console.log(res2);
}

demo();

API Doc

Method: assumeRole()

Arguments

  • roleArn String required - aliyun resource name, acs:ram::${accountID}:role/${roleName}
  • roleSessionName String required - differentiate tokens, /^[a-zA-Z0-9.@-_]+$/
  • policy String optional - @see https://help.aliyun.com/document_detail/28664.html
  • durationSeconds Number optional - the specified expiration time (seconds), range: 900~3600, default value is 3600

Returns

  • credentials Object - sts credentials

Method: getCallerIdentity()

Returns

  • userInfo Object - the identity of the current caller

Method (Japan only): generateSessionAccessKey()

Returns

  • akInfo Object - session key & secret

Test & Coverage

You should set environment variables before running the test or coverage. For example:

  • run test
ACCESS_KEY=<your access key> SECRET_KEY=<your secret key> ENDPOINT=sts.aliyuncs.com npm run test
  • run code coverage
ACCESS_KEY=<your access key> SECRET_KEY=<your secret key> ENDPOINT=sts.aliyuncs.com npm run cov

License

MIT

Current Tags

  • 1.0.2                                ...           latest (7 years ago)

4 Versions

  • 1.0.2                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Downloads
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 4
Last Month 0
Dependencies (2)
Dev Dependencies (8)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |