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 🙏

© 2026 – Pkg Stats / Ryan Hefner

niftycloud-auth

v0.1.3

Published

This is the SDK for NIFTY Cloud API to make authentication parameters of API request.

Readme

niftycloud-auth

Build Status Coverage Status

CAUTION: EXPERIMENTAL CODE

This is the SDK for NIFTY Cloud API to make authentication parameters of API request.

Install

npm install niftycloud-auth

Basic Usage

There is classes that maekes signature parameters for signature version 2 / 3 / 4.

First, you need to create instance of class of signature version that you want to request. Then, you can request api with some parameters. Please visit NIFTY Cloud API Reference page to know about API endpoint, path and required parameters.

All api request method is avaiable both callback (err, res)=>{} and promise chain.

If content type of response is xml, response.body property includes result ofparsing xml by xml2js. Other response parameter is same as Superagent

const NiftyCloud = require("../lib/niftycloud.js");

const v2 = new NiftyCloud.V2(
  "YOUR_ACCESS_KEY",
  "YOUR_SECRET_ACCESS_KEY",
  "https://east-1.cp.cloud.nifty.com"
);

v2.get( "/api/", "DescribeInstances", {}).then((res)=>{
  console.log("res:" + JSON.stringify(res.body));
}).catch((err)=>{
  if (err instanceof v2.ApiError) {
    console.log("err:" + err);
  }
});

API

Constructor

  • Required: Access key, Secret Access key, API Endpoint
  • Optional: Proxy endpoint, authType(Only available in V4 class, value must be "nifty" or "aws")
const v2 = new NiftyCloud.V2(
  "YOUR_ACCESS_KEY",
  "YOUR_SECRET_ACCESS_KEY",
  "https://east-1.cp.cloud.nifty.com"
  {
    proxy: "http://example.com:8080"
  }
);

Signature version 2

  • GET
    • Required: Path and Action name of API
    • Optional: query , header Object and callback
"use strict";

const NiftyCloud = require("../lib/niftycloud.js");

const v2 = new NiftyCloud.V2(
  "YOUR_ACCESS_KEY",
  "YOUR_SECRET_ACCESS_KEY",
  "https://east-1.cp.cloud.nifty.com"
);

v2.get( "/api/", "DescribeInstances", {}).then((res)=>{
  console.log("res:" + JSON.stringify(res.body));
}).catch((err)=>{
  if (err instanceof v2.ApiError) {
    console.log("err:" + err);
  }
});

Signature version 3

(This class is available only for Object storage. Because other products implementation of signature version 3 is different from object storage.)

  • PUT
    • Required: Path of API
    • Optional: query, header, body Object and callback
"use strict";

const crypto = require("crypto");

const NiftyCloud = require("../lib/niftycloud.js");

const v3 = new NiftyCloud.V3(
  "YOUR_ACCESS_KEY",
  "YOUR_SECRET_ACCESS_KEY",
  "https://jp-east-2.os.cloud.nifty.com"
);

const fs = require("fs");

const image = fs.readFileSync("./niftycloud.png"); // you must prepare niftycloud.png at current path
const md5hash = crypto.createHash('md5');
md5hash.update(image);

v3.put("/first-bucket/niftycloud.png", { // you must create first-bucket before run this example
  header: {
    "Content-Type":"image/png",
    "Content-MD5" : md5hash.digest('base64')
  },
  body: image
}).then((res)=>{
  console.log("res:" + res.status);
}).catch((err)=>{
  console.log(err);
});
  • GET
    • Required: Path of API
    • Optional: query, header Object and callback
"use strict";

const NiftyCloud = require("../lib/niftycloud.js");

const v3 = new NiftyCloud.V3(
  "YOUR_ACCESS_KEY",
  "YOUR_SECRET_ACCESS_KEY",
  "https://jp-east-2.os.cloud.nifty.com"
);

const fs = require("fs");

v3.get("/first-bucket/niftycloud.png", {
  header: {
    "Content-Type":"image/png"
  },
}).then((res)=>{
  //If the Content-Type is not "application/xml" in response headers, you can get buffer response from response.body property
  const image = fs.writeFileSync("./niftycloud_get.png", res.body);
  console.log("res:" + res.status);
}).catch((err)=>{
  console.log(err);
});
  • DELETE
    • Required: Path of API
    • Optional: query, header Object and callback
"use strict";

const NiftyCloud = require("../lib/niftycloud.js");

const v3 = new NiftyCloud.V3(
  "YOUR_ACCESS_KEY",
  "YOUR_SECRET_ACCESS_KEY",
  "https://jp-east-2.os.cloud.nifty.com"
);

v3.delete("/first-bucket/niftycloud.png", {
  header: {
    "Content-Type":"image/png"
  },
}).then((res)=>{
  console.log("res:" + res.status);
}).catch((err)=>{
  console.log(err);
});

Signature version 4

  • GET
    • Required: Path of API, service ID, region
    • Optional: query, header Object and callback
"use strict";

const NiftyCloud = require("../lib/niftycloud.js");

const v4 = new NiftyCloud.V4(
  "YOUR_ACCESS_KEY",
  "YOUR_SECRET_ACCESS_KEY",
  "https://rdb.jp-east-1.api.cloud.nifty.com",
  "http://example.com:8080" //proxy server
);

v4.get("/", "rdb", "east-1", {
  query: {
    Action: "DescribeDBInstances"
  }
}).then((res)=>{
  console.log(res.body);
}).catch((err)=>{
  console.log(err);
});
  • POST
    • Required: Path of API, service ID, region
    • Optional: query, header, body Object and callback
"use strict";

const NiftyCloud = require("../lib/niftycloud.js");

const v4 = new NiftyCloud.V4(
  "YOUR_ACCESS_KEY",
  "YOUR_SECRET_ACCESS_KEY",
  "https://ess.api.cloud.nifty.com"
);

v4.post("/", "east-1", "email", {
  body: {
    "Action":"SendEmail",
    "Version":"2010-12-01",
    "Destination.ToAddresses.member.1": "[email protected]",
    "Source": "[email protected]",
    "Message.Subject.Data": "testFromApi",
    "Message.body.Text.Data": "testFromApi"
  }
}).then((res)=>{
  console.log(res.body);
}).catch((err)=>{
  console.log(err);
});

Errors

  • ParseResponseError: Error for Response parsing
    • Parameters: error.name, error.message
  • InvalidParameterError: Error for Invalid parameters
    • Parameters: error.name, error.message, error.results (array of detail messages)
  • ApiError: Error for API Response returns 4xx or 5xx
    • Parameters: error.name, error.message, error.statusCode (HTTP Status Code), error.errorCode (Error Code of NIFTY Cloud API)