Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@volcengine/openapi

Package Overview
Dependencies
Maintainers
0
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volcengine/openapi

火山引擎OpenAPI SDK nodejs版

  • 1.27.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
764
decreased by-34.19%
Maintainers
0
Weekly downloads
 
Created
Source

Volcano Engine OpenAPI node sdk

中文文档

Requirements:

  • Node.js >= 12

Installation

npm install -S @volcengine/openapi

Basic Usage

1. Setting OpenAPI service's AK&SK

Available in three settings

1. Use API to set AK&SK
// Use the default service instance. You can also create a new instance.
// `const iamService = new iam.IamService();`
const iamService = iam.defaultService;

// set aksk
iamService.setAccessKeyId(AccessKeyId);
iamService.setSecretKey(SecretKey);
// If you use sts to request, you need to set up `SessionToken` after aksk is set
iamService.setSessionToken(SessionToken);
2. Use environment variables to set AK & SK
VOLC_ACCESSKEY="your ak" VOLC_SECRETKEY="your sk"
3. Use configuration file

Put it in ~/.volc/config in json format, the format is:

{"VOLC_ACCESSKEY":"your ak","VOLC_SECRETKEY":"your sk"}

Request OpenAPI

Take the ListUsers API of the iam service as an example

import { iam } from'@volcengine/openapi';

async function main(AccessKeyId, SecretKey) {
   // Use the default service instance. You can also create a new instance.
   // `const iamService = new iam.IamService();`
   const iamService = iam.defaultService;

   // set aksk
   iamService.setAccessKeyId(AccessKeyId);
   iamService.setSecretKey(SecretKey);
  
   // Request OpenAPI
   const usersResponse = await iamService.ListUsers({
     Limit: 10,
     Offset: 0,
   });
}

OpenAPI signature method

By HTTP Header

import {Signer} from '@volcengine/openapi';

// http request data
const openApiRequestData: RequestObj = {
    region: 'cn-north-1',
    method: 'GET',
    // [optional] http request url query
    params: {},
    // http request headers
    headers: {},
    // [optional] http request body
    body: "",
}

const signer = new Signer(openApiRequestData, "iam");

// sign
signer.addAuthorization({accessKeyId, secretKey, sessionToken});

// Print signed headers
console.log(openApiRequestData.headers);

By HTTP Query

const openApiRequestData: RequestObj = {
    method: "POST",
    region: "cn-north-1",
    params: {
        Action: "AssumeRole",
        Version: "2018-01-01",
        RoleTrn: "trn:iam::200:role/STSRole",
        RoleSessionName: "test",
    },
}

const credentials: Credentials = {
    accessKeyId: VOLC_ACCESSKEY,
    secretKey: VOLC_SECRETKEY,
    sessionToken: "",
}

const signer = new Signer(openApiRequestData, "sts");

const signedQueryString = signer.getSignUrl(credentials);

FAQs

Package last updated on 26 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc