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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@openfort/shield-js

v0.1.13

Published

[![Version](https://img.shields.io/npm/v/@openfort/shield-js.svg)](https://www.npmjs.org/package/@openfort/shield-js)

Downloads

1,989

Readme

ShieldJS

Version

ShieldJS is a TypeScript library for interacting with the Openfort Shield API. It provides easy-to-use methods for retrieving and storing secrets.

Features

  • Easy authentication with Openfort and custom authentication options.
  • Methods for storing and retrieving secrets securely.

Installation

To use ShieldSDK in your project, install it via npm:

npm install @openfort/shield-js

Usage

Here's a quick example to get you started:

Importing the SDK

import { ShieldSDK, ShieldOptions, ShieldAuthOptions } from 'shield-sdk';

Initializing the SDK

const shieldOptions: ShieldOptions = {
apiKey: 'your-api-key',
// Optional: Specify a custom base URL
baseURL: 'https://shield.openfort.xyz'
};

const shieldSDK = new ShieldSDK(shieldOptions);

Storing a Secret

const authOptions: ShieldAuthOptions = {
// ... authentication options
};

await shieldSDK.storeSecret("your-secret", authOptions);

Deleting a Secret

await shieldSDK.deleteSecret(authOptions);

Retrieving a Secret

const secret = await shieldSDK.getSecret(authOptions);
console.log(secret);

API Reference

  • storeSecret(secret: string, auth: ShieldAuthOptions): Promise<void>
  • getSecret(auth: ShieldAuthOptions): Promise<string>

Authentication

ShieldSDK supports two types of authentication: Openfort and Custom. The type of authentication you use depends on the configuration set in your Shield Dashboard.

Openfort Authentication

When you configure your Shield Dashboard to use Openfort, you should use OpenfortAuthOptions for authentication. Depending on your setup, the way you use OpenfortAuthOptions can vary:

  • Using an Openfort Token: If you are using a token generated by Openfort, simply provide the token in openfortOAuthToken.
const authOptions: OpenfortAuthOptions = {
    openfortOAuthToken: "your-openfort-token",
};
  • Using Third-Party OAuth Tokens: If you are using a third-party authentication provider, you need to provide the identity token, the provider type, and the token type:
const authOptions: OpenfortAuthOptions = {
    openfortOAuthToken: "your-identity-token",
    openfortOAuthProvider: OpenfortOAuthProvider.FIREBASE,
    openfortOAuthTokenType: OpenfortOAuthTokenType.ID_TOKEN
};

The Provider and Token Type enums are defined as follows:

export enum OpenfortOAuthProvider {
    ACCELBYTE = "accelbyte",
    FIREBASE = "firebase",
    LOOTLOCKER = "lootlocker",
    PLAYFAB = "playfab",
    CUSTOM = "custom",
    OIDC = "oidc",
}

export enum OpenfortOAuthTokenType {
    ID_TOKEN = "idToken",
    CUSTOM_TOKEN = "customToken",
}

Custom Authentication

If your Shield Dashboard is configured for Custom Authentication, use CustomAuthOptions. You will need to provide your custom token in the customToken field.

const authOptions: CustomAuthOptions = {
    customToken: "your-custom-token",
};