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

ctvault

v2.0.8

Published

ctvault is a wrapper library around the commercetools JavaScript SDK that aims to reduce boilerplate code and provide consolidated credential management for multiple commercetools projects.

Readme

ctvault

Motivation

ctvault is a wrapper library around the commercetools JavaScript SDK that aims to reduce boilerplate code and provide consolidated credential management for multiple commercetools projects.

Configuration

There are multiple methods for configuring the type of data store that ctvault uses. Set the CT_VAULT_CONFIG environment variable to point to the location of the JSON configuration file.

commercetools project

This configuration will point ctvault at a commercetools project, specifying a namespace and key for a custom object to store the managed credentials.

| key | value | | ------------- | ------------------------------------- | | type | "ctp" | | namespace | the custom object namespace | | key | the custom object key | | credentials | the commercetools project credentials |

Google Firebase

You can also use a Google Firebase store to serve as the credentials vault.

| key | value | | ------------- | --------------------------------------------------------------------------------------------------------------------- | | type | "firebase" | | credentials | path to a JSON file with GCP service account credentials (see https://cloud.google.com/iam/docs/service-accounts) | | collection | name of the firebase collection that holds the managed credentials |

Local file

Alternatively you can store them in a file on the local file system.

| key | value | | ------------- | --------------------------------------------- | | type | "file" | | credentials | an array of commercetools project credentials |

commercetools Credentials

Here is the structure for the commercetools credentials objects. These are both to specify the project (if you are pointing at a commercetools project) and to specify the set of managed credentials.

| key | value | | --------------- | --------------------------------------- | | oauth_url | URL to the commercetools auth server | | api_url | URL to the commercetools API gateway | | project | project key | | client_id | API client ID | | client_secret | API client secret |

Usage

ctvault acts as a simple broker. You can query it by using two methods:

getClient(projectKey)

This will return a CTP client configured to talk to the project specified in projectKey if the credentials exist in the vault. If they are not, an exception is thrown to that effect.

If projectKey is empty, ctvault will attempt to find it in the command line argument --project.

getClients

This will return an array of CTP clients for which the vault contains credentials.

Both of these methods are asynchronous, so be sure to use await.

Using a ctvault CTP client (ctclient)

ctclient uses a syntax based on api-request-builder (https://commercetools.github.io/nodejs/sdk/api/apiRequestBuilder.html), specifically the Declarative Usage section (https://commercetools.github.io/nodejs/sdk/api/apiRequestBuilder.html#declarative-usage).

Largely syntactic sugar, it provides an interface for you to use standard CRUD operations (create, get, update, remove), but also adds the following verbs:

process: This will use the processRequest method from api-request-builder to page through objects.

ensure: Given a source object, will try to find an object with the matching key. If it is not found, it will be created with the source object as the template. Use when building data models.

Examples

Query for a tax category with a key of standard:

const argv = require('yargs').argv
let ct = await require('ctvault').getClient(argv.project)

let standardTaxCategory = await ct.taxCategories.get({ key: 'standard' })

Make sure order type foo is defined:

const argv = require('yargs').argv
let ct = await require('ctvault').getClient(argv.project)

let fooOrderType = {
    key: 'FooOrderType',
    name: { 
        en: 'Foo'
    },
    resourceTypeIds: ['order'],
    description: { 
        en: 'Foo'
    },
    fieldDefinitions: [{
        name: 'bar',
        type: { name: 'String' },
        required: false,
        label: { 
            en: 'Bar'
        }
    }]
}

let foo = await ct.types.ensure(fooOrderType)