npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ali-kms

v1.0.3

Published

alibaba cloud kms(Key Management Service) client.

Downloads

13

Readme

ali-kms

Install

$ npm i ali-kms -S

Usage as command

install

$ npm i -g ali-kms
$ ali-kms --help 

ali-kms use $HOME/.kmsconfig as default config file.

example config file

accessKey=accessKey
accessSecret=accessSecret
region=cn-shanghai

Usage as package

Prepare

You need create a new RAM strategy to manager kms.

{
  "Version": "1",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "kms:*",
      "Resource": [
        "acs:kms:*:*:key",
        "acs:kms:*:*:key/*"
      ]
    }
  ]
}

This case have all privileges to manager kms. You can customize strategy follow the RAM doc.

Regions

Kms Resgions

| Name | ReginId | Publish Domain | VPC Domain | | :---: | :---: | :---: | :---: | | 华东1 | cn-hangzhou | kms.cn-hangzhou.aliyuncs.com | kms-vpc.cn-hangzhou.aliyuncs.com | | 华东2 | cn-shanghai | kms.cn-shanghai.aliyuncs.com | kms-vpc.cn-shanghai.aliyuncs.com | | 华东2(上海金融云) | cn-shanghai-finance-1 | kms.cn-shanghai-finance-1.aliyuncs.com | kms-vpc.cn-shanghai-finance-1.aliyuncs.com | | 华北1(青岛) | cn-qingdao | kms.cn-qingdao.aliyuncs.com | kms-vpc.cn-qingdao.aliyuncs.com | | 华北2 | cn-beijing | kms.cn-beijing.aliyuncs.com | kms-vpc.cn-beijing.aliyuncs.com | | 华北3(张家口) | cn-zhangjiakou | kms.cn-zhangjiakou.aliyuncs.com | kms-vpc.cn-zhangjiakou.aliyuncs.com | | 华北5(呼和浩特) | cn-huhehaote | kms.cn-huhehaote.aliyuncs.com | kms-vpc.cn-huhehaote.aliyuncs.com | | 华南1 | cn-shenzhen | kms.cn-shenzhen.aliyuncs.com | kms-vpc.cn-shenzhen.aliyuncs.com | | 华南1(深圳金融云) | cn-shenzhen-finance-1 | kms.cn-shenzhen-finance-1.aliyuncs.com | kms-vpc.cn-shenzhen-finance-1.aliyuncs.com | | 香港 | cn-hongkong | kms.cn-hongkong.aliyuncs.com | kms-vpc.cn-hongkong.aliyuncs.com | | 亚太东北(日本) | ap-northeast-1 | kms.ap-northeast-1.aliyuncs.com | kms-vpc.ap-northeast-1.aliyuncs.com | | 亚太东南(悉尼) | ap-southeast-2 | kms.ap-southeast-2.aliyuncs.com | kms-vpc.ap-southeast-2.aliyuncs.com | | 亚太东南(新加坡)| ap-southeast-1| kms.ap-southeast-1.aliyuncs.com | kms-vpc.ap-southeast-1.aliyuncs.com | | 亚太东南(马来西亚) | ap-southeast-3 | kms.ap-southeast-3.aliyuncs.com | kms-vpc.ap-southeast-3.aliyuncs.com | | 欧洲中部(法兰克福) | eu-central-1 | kms.eu-central-1.aliyuncs.com | kms-vpc.eu-central-1.aliyuncs.com | | 中东东部(迪拜) | me-east-1 | kms.me-east-1.aliyuncs.com | kms-vpc.me-east-1.aliyuncs.com |

Create A Kms Client

KMS(options)

Create A KMS Client

options:

  • accessKey {String} access key
  • accessSecret {String} access secret
  • [region] {String} region to using kms
  • [endpoint] {String} region domain. if you have region in options, endpoint will auto generate.
  • [vpc] {Boolean} if you use kms in vpc, make vpc to be true
  • [timeout] {Number} request timeout

Example:

const KMS = require('kms');
const options = {
  accessKey: 'abc',
  accessSecret: 'abc',
  region: 'cn-hangzhou',
  // endpoint: 'kms-vpc.cn-hangzhou.aliyuncs.com'
  vpc: true,
  timeout: 6000
}
const kms = KMS(options);

Operations

.describeRegions(options)

List all available regions

Parameters:

  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

const regions = await kms.describeRegions();

const { 
  RegionId
} = regions[0];

.createKey(params, options)

Create an encrypt/decrypt key

Parameters:

  • params {Object} create key params
    • description {String} key description
  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

const { KeyId } = await kms.createKey({ description: 'for you' });

.listKeys(params, options)

List all keys

Parameters:

  • [params] list params
    • [pageNumber=1] {Number} page number
    • [pageSize=10] {Number} page size
  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

const { List, TotalCount, PageNumber, PageSize } = await kms.listKeys({ pageNumber: 2, pageSize: 15 });

.describeKey(keyId, options)

Get detail of key

Parameters:

  • keyId {String} key id
  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

const {
  CreationDate,
  Description,
  KeyId,
  KeyState,
  KeyUsage,
  DeleteDate,
  Creator
} = await kms.describeKey('your key id');

.encrypt(keyId, params, options)

Encrypt plaintext

Parameters:

  • keyId {String} encrypt key
  • params {Object} encrypt params
    • plaintext {String} plaintext to encrypt
    • [context] {Object} platten json, encryption context
  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

const keyId = 'you key id'
const { CiphertextBlob } = await kms.encrypt(keyId, { plaintext: 'plaintext' });

.decrypt(params, options)

Decrypt ciphertext

Parameters:

  • params {Object} params for descrypt
    • ciphertext {String} ciphertext to decrypt
    • [context] {Object} decryption context
  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

const { Plaintext } = await kms.decrypt({ ciphertext: 'dadada' });

.generateDataKey(keyId, params, options)

Create a pair plain/cipher for encryption

Parameters:

  • keyId {String} key id
  • params {Object} generate date key params
    • keySpec {String} algorithm to encrypt/decrypt, AES_256 or AES_128
    • [length] {Number} encrypt key length
  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

const KEY_SPEC = require('kms').KEY_SPEC
const { Plaintext, CiphertextBlob } = await kms.generateDataKey('you key id'
  , { keySpec: KEY_SPEC.AES_256 });

.scheduleKeyDeletion(keyId, delayDays, options)

Delete key after delay days(7~30)

Parameters:

  • keyId {String} key id
  • delayDays {Number} delay days, min: 7, max: 30
  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

await kms.scheduleKeyDeletion('your key id', 7);

.cancelKeyDeletion(keyId, options)

Cancel schedule deletion

Parameters:

  • keyId {String} key id
  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

await kms.cancelKeyDeletion('your key id');

.enableKey(keyId, options)

Enable disabled key

Parameters:

  • keyId {String} key id
  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

await kms.enableKey('your key id');

.disableKey(keyId, options)

Disable key

Parameters:

  • keyId {String} key id
  • [options] {Object} request options
    • timeout {Number} request timeout, Unit: ms

Example:

await kms.disableKey('your key id');

License


MIT