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 🙏

© 2025 – Pkg Stats / Ryan Hefner

postmonkey

v1.1.13

Published

A Postman Scripts helper library for easier collection development.

Downloads

18

Readme

postmonkey

Don't monkey around in Postman scripts! Use Postmonkey! Postmonkey gives you custom scripts to use in

Getting Started Guide

If you want to build this code just run yarn run build, that will build you the development mode of the bundle and publish it to dist/bundle.js.

If you then want to use this code you can start a node environment and:

pm.sendRequest("https://unpkg.com/postmonkey/dist/postmonkey.js", function (err, response) {
  // This will set the `postmonkey` variable for your use
  eval(response.text());

  // TODO your custom code here
  postmonkey...
});

And that is it, now you have this script running. The most important step, from here, will be to have this script included in a postman variable so that it can be loaded at runtime.

Postmonkey ASAP API

generateAsapToken

Generates an ASAP token from the given asap key data. The output is a JWT token complying with the Atlassain Service Authentication Protocol specification, which may be used as a Bearer token for ASAP authenticated endponts.

Syntax

postmonkey.asap.generateAsapToken(asapData, { "additional": "Claims" });

Parameters

asapData (Required)

Object with ASAP configuration data. The raw data should come from a .asap-config file generated by the asap init CLI command.

{
    "issuer": "micros/dev",
    "sub": "micros/dev",
    "kid": "micros/dev/example",
    "audience": ["identity-platform","perms"],
    "privateKey": "-----BEGIN RSA PRIVATE KEY-----UG9zdG1vbmtleUpT...-----END RSA PRIVATE KEY-----",
    "expiry": 60
}

additionalClaims (Optional)

Object with additional key/value pairs to be included as properties in the JWT token.

{
  "accountId": "490f8eb7-30df-4d5c-8129-9a617b8884aa",
}

parseAdditionalClaims

Parses an input string to create an object with key/value pairs representing additional claims to be included in an ASAP token.

Syntax

postmonkey.asap.parseAdditionalClaims(input[, reviver]);

Parameters

input Required

A comma separated string of key=value pairs, or a JSON object. If using the key=value syntax, if the =value is omitted, the default value is undefined.

Using key=value syntax:

accountId=490f8eb7-30df-4d5c-8129-9a617b8884aa,cloudId=7abe7b98-3879-4a63-8228-053b5e041e0f

Or JSON:

{
    "accountId": "490f8eb7-30df-4d5c-8129-9a617b8884aa",
    "cloudId": "7abe7b98-3879-4a63-8228-053b5e041e0f"
}

If the input value, ignoring whitespace, begins with {, then the value will be parsed using JSON.parse(). Otherwise, the value will be parsed as key=value pairs.

reviver Optional

reviver(key[, value])

A function that transforms the original parsed value into any desired value. The reviver function must be compatible with the reviver parameter for JSON.parse(). The function will be invoked with the key and value parameters. The return value will be assigned to the property. The function will be invoked with this set to the result object.

For example, if a particular value is omitted from the input, a reviver function may be used to obtain a value from Postman variables based on the key. The reviver may also be used to interpolate Postman variable strings.

Example Reviver Function

This reviver function will interpolate Postman variables, and recursively parse JSON values.

function reviver(key, value) {
    const revived = pm.variables.replaceIn(
        value === undefined ? pm.variables.get(key) : value
    );
    if (typeof revived === 'string' && /^\s*(?:{.*}|\[.*])\s*$/.test(revived)) {
        return JSON.parse(revived, reviver);
    }
    return revived;
};

Example Usage

Postman Variables

| Variable | Value | | ---------------- | --------------------------------------------------------------------------------- | | .asap-config | (see code block below) | | additionalClaims | accountId,cloudId={{cloudId-staging}} | | accountId | 490f8eb7-30df-4d5c-8129-9a617b8884aa | | cloudId-staging | 7abe7b98-3879-4a63-8228-053b5e041e0f | | iss | micros/dev | | sub | {{iss}} (Makes this equal to the issuer) | | kid | micros/dev/example | | audience | ["identity-platform","perms"] | | asap-private.pem | -----BEGIN RSA PRIVATE KEY-----UG9zdG1vbmtleUpT...-----END RSA PRIVATE KEY----- |

.asap-conifg

{
    "issuer": "{{iss}}",
    "sub": "{{sub}}",
    "kid": "{{kid}}",
    "audience": "{{audience}}",
    "privateKey": "{{asap-private.pem}}",
    "expiry": 60
}

Using this script, with the above reviver function, the token ASAP config and additionalClaims will be parsed with correctly interpolated Postman variables.

const asapConfig = JSON.parse(
    pm.variables.get('.asap-config'),
    reviver
);

const additionalClaims = postmonkey.asap.parseAdditionalClaims(
    pm.variables.get('additionalClaims'),
    reviver
);

const token = postmonkey.asap.generateAsapToken(
    asapConfig,
    additionalClaims
);

pm.request.headers.upsert({
    key: 'Authorization',
    value: `Bearer ${token}`
});