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

ziplabs-embedded-sdk

v2.0.0

Published

SDK for embedding resources from Ziplabs into your own application

Downloads

13

Readme

Ziplabs Embedded SDK

The Embedded SDK allows you to embed dashboards from Ziplabs into your own app, using your app's authentication.

Embedding is done by inserting an iframe, containing a Ziplabs page, into the host application.

Embedding a Dashboard

Using npm:

npm install --save ziplabs-embedded-sdk
import { embedDashboard } from "ziplabs-embedded-sdk";

embedDashboard({
  id: "abc123", // given by the Ziplabs embedding UI
  ziplabsDomain: "http://localhost:8088/",
  mountPoint: document.getElementById("my-div-container"), // any html element that can contain an iframe
  fetchGuestToken: () => fetchGuestTokenFromBackend(),
  dashboardUiConfig: { // dashboard UI config: hideTitle, hideTab, hideChartControls, filters.visible, filters.expanded (optional)
      hideTitle: true,
      filters: {
          expanded: true,
      }
  },
});

Authentication/Authorization with Guest Tokens

Embedded resources use a special auth token called a Guest Token to grant Ziplabs access to your users, without requiring your users to log in to Ziplabs directly. Your backend must create a Guest Token by requesting Ziplabs's POST /security/guest_token endpoint, and pass that guest token to your frontend.

The Embedding SDK takes the guest token and use it to embed a dashboard.

Creating a Guest Token

From the backend, http POST to /security/guest_token with some parameters to define what the guest token will grant access to. Guest tokens can have Row Level Security rules which filter data for the user carrying the token.

The agent making the POST request must be authenticated with the can_grant_guest_token permission.

Within your app, using the Guest Token will then allow authentication to your Ziplabs instance via creating an Anonymous user object. This guest anonymous user will default to the public role as per this setting GUEST_ROLE_NAME = "Public". + +The user parameters in the example below are optional and are provided as a means of passing user attributes that may be accessed in jinja templates inside your charts.

Example POST /security/guest_token payload:

{
  "user": {
    "username": "stan_lee",
    "first_name": "Stan",
    "last_name": "Lee"
  },
  "resources": [{
    "type": "dashboard",
    "id": "abc123"
  }],
  "rls": [
    { "clause": "publisher = 'Nintendo'" }
  ]
}