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

@c6fc/spellcraft-aws-auth

v1.1.2

Published

A plugin to empower @c6fc/spellcraft with AWS

Readme

SpellCraft AWS Integration

NPM version License

Seamlessly integrate AWS SDK for JavaScript (v2) into your SpellCraft SpellFrames. This plugin allows you to natively expose authenticated AWS contexts or role-chains to your SpellFrames, and use the full power of the SDK in both JavaScript native functions and JSonnet.

npm install --save @c6fc/spellcraft @c6fc/spellcraft-aws-auth

This module will use credential sources in the same order as the AWS SDK for JavaScript, with role-assumption happening after the priority credential source is identified. If the role requires MFA, spellcraft will prompt for it.

# Show your current AWS credential context
npx spellcraft aws-identity

{
	"Account": "123456789012"
	"Arn": "arn:aws:iam::123456789012:user/you",
	"UserId": "AIDAEXAMPLEAAAAA"
}

You can perform an assumeRole operation using this initial context to chain into a different deployment role by setting the SPELLFRAME_ASSUMEROLE envvar:

export SPELLFRAME_ASSUMEROLE="arn:aws:iam::345678901234:role/deployment"

# She the new assumerole credential context:
npx spellcraft aws-identity

{
	"Account": "345678901234"
	"Arn": "arn:aws:iam::345678901234:assumed-role/deployment/spellcraft_assumerole_timestamp",
	"UserId": "AROAEXAMPLEBBBB:spellcraft_assumerole_timestamp"
}

Features

  • Authenticate to AWS with native means, as well as role assumptions with SPELLFRAME_ASSUMEROLE
  • Provide an authenticated aws instance to function contexts.
  • Expose all AWS-SDK clients and methods directly to JSonnet.

CLI Commands

  • spellcraft aws-identity Display the AWS IAM identity of the SpellCraft execution context
  • spellcraft aws-exportcredentials Export the current credentials as environment variables

SpellFrame 'init()' features

Extends the SpellFrame's init() to include obtaining AWS credentials, and optionally performing an STS AssumeRole, before instantiating the AWS SDK for JavaScript.

JavaScript context features

Exposes an instance of the AWS-SDK v2 as aws for all native function executions.

JavaScript native functions

  • aws(clientObj, method, params={}) - Wraps the authenticated instantiation of the AWS-SDK to allow for direct API calls
  • callerId() - Returns the STS Caller Identity for the current context

API Reference

client(service, params={})

Creates an instance of the AWS service client which can be used to make API calls. This is only necessary if the client instantiation requires non-default parameters such as 'region'. Otherwise, aws.call() below is simpler.

  • param {string} service
  • param {object} params
  • return {Class.AWS.service}

Examples:

local aws = import "@c6fc/spellcraft-aws-auth/module.libsonnet";
local stsClient = aws.client('STS', { region: "us-east-1" });

{ identity: aws.api(stsClient,'getCallerIdentity') }
Another example here

api(clientObj, method, params="")

Makes an AWS API call using the provided client, of the specified method and with the supplied parameters.

  • param {Class.AWS.service} client
  • param {string} method
  • param {object} [params={}]
  • returns {string} result

Examples:

local aws = import "@c6fc/spellcraft-aws-auth/module.libsonnet";
local stsClient = aws.client('STS', { region: "us-east-1" });

{ identity: aws.api(stsClient,'getCallerIdentity') }

callerId()

Makes an AWS API call using the provided client, of the specified method and with the supplied parameters.

  • returns {string} result

Examples:

local aws = import "@c6fc/spellcraft-aws-auth/module.libsonnet";

{ callerId: aws.callerId() }

call(name, method, params="")

This is a shortcut for calling aws.api(aws.client(name, {}), method). Useful for when your service client requires no extra parameters.

  • param {string} name
  • param {string} method
  • param {object} [params={}]
  • returns {string} result

Examples:

local aws = import "@c6fc/spellcraft-aws-auth/module.libsonnet";

{ identity: aws.call('STS','getCallerIdentity') }

assertIdentity(arn)

Terminates manifestation if the current AWS identity ARN doesn't match the provided value. Useful for sanity checking prior to deployment.

  • param {string} arn
  • returns {bool} true || assertion failure

Examples:

local aws = import "@c6fc/spellcraft-aws-auth/module.libsonnet";

{ identity:: aws.assertIdentity('arn:aws:iam:123456789012:user/you') }

getCallerIdentity()

Returns details of the current AWS security principal context

Examples:

local aws = import "@c6fc/spellcraft-aws-auth/module.libsonnet";

{ identity: aws.getCallerIdentity() }

getRegionsList()

Returns an array of available AWS regions

Examples:

local aws = import "@c6fc/spellcraft-aws-auth/module.libsonnet";

{ regions: aws.getRegionList() }

getAvailabilityZones()

Returns an object containing the availability zones for each region; e.g. ["us-east-1"]: ["us-east-1a", "us-east-1b", ...]

Examples:

local aws = import "@c6fc/spellcraft-aws-auth/module.libsonnet";

{ availabilityZones: aws.getAvailabilityZones() }

Installation

Install the plugin as a dependency in your SpellCraft project:

npm install --save @c6fc/spellcraft-aws-auth

Then import the module into your Jsonnet code and use it.

local aws = import "@c6fc/spellcraft-aws-auth/module.jsonnet";

'identity.json': {
	aws: aws.getCallerIdentity()
}