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

@lpti/unpam-sso

v0.1.6

Published

Iframe embedder for UNPAM SSO login button - supports vanilla JS and React - no dependencies

Readme

@lpti/unpam-sso

Embed the UNPAM SSO login button as an iframe widget. Supports both vanilla JavaScript and React (JSX/TSX) usage. No dependencies required for vanilla JS. TypeScript types included for React.

Installation

npm install @lpti/unpam-sso

Usage

Vanilla JavaScript (Native, No Dependencies)

ES6 Modules

import { embedButtonLogin } from '@lpti/unpam-sso';

// Basic usage
embedButtonLogin('login-container');

// With options
embedButtonLogin('login-container', {
  env: 'prod', // 'dev' or 'prod'
  lang: 'en',  // 'id' or 'en'
  size: 'lg',  // 'sm', 'md', or 'lg'
  theme: 'black', // 'white' or 'black'
  width: '300px',
  className: 'my-login-widget'
});

HTML Script Tag (via CDN)

<script type="module">
  import { embedButtonLogin } from 'https://unpkg.com/@lpti/unpam-sso@latest/index.js';
  embedButtonLogin('login-container', {
    env: 'prod',
    lang: 'id',
    size: 'md',
    theme: 'white'
  });
</script>
<div id="login-container"></div>

React Component (JSX/TSX)

Import (JSX or TypeScript)

import { LoginButton } from '@lpti/unpam-sso/react';

function App() {
  return (
    <div>
      {/* Basic usage */}
      <LoginButton />
      {/* With options */}
      <LoginButton
        env="prod"
        lang="en"
        size="lg"
        theme="black"
        width="300px"
        className="my-login-widget"
        onLoad={() => console.log('Login button loaded')}
        onError={error => console.error('Login button error:', error)}
      />
    </div>
  );
}

React Hook Usage

import { useLoginButton } from '@lpti/unpam-sso/react';

function CustomLoginComponent() {
  const { iframeUrl, isLoading, hasError, reload } = useLoginButton({
    env: 'prod',
    lang: 'id',
    size: 'md',
    theme: 'white'
  });

  if (isLoading) return <div>Loading login button...</div>;
  if (hasError) return <div>Error loading login button. <button onClick={reload}>Retry</button></div>;

  return (
    <iframe
      src={iframeUrl}
      width="100%"
      height="40px"
      frameBorder="0"
      scrolling="no"
    />
  );
}

API

Vanilla JavaScript

embedButtonLogin(elementId, options)

Embeds an iframe-based login button/widget into a target element.

Parameters:

  • elementId (string): The id of the target HTML element
  • options (object, optional):
    • env (string): 'dev' or 'prod'
    • url (string): Custom iframe src URL (overrides env)
    • width (string): CSS width (e.g. '300px')
    • height (string): CSS height (e.g. '80px')
    • className (string): Additional CSS class for the iframe
    • style (object): Inline style object for the iframe
    • sandbox (string): Sandbox attribute value
    • title (string): Title attribute for accessibility
    • lang (string): 'id' or 'en' (default: 'id')
    • size (string): 'sm', 'md', or 'lg' (default: 'md')
      • sm: 32px height
      • md: 40px height
      • lg: 48px height
    • theme (string): 'white' or 'black' (default: 'white')

React Component

<LoginButton /> Props

All the same options as the vanilla JS version, plus:

  • onLoad (function): Callback when iframe loads successfully
  • onError (function): Callback when iframe fails to load
  • All standard iframe props are supported

useLoginButton(options) Hook

Returns an object with:

  • iframeUrl (string): The generated iframe URL
  • isLoading (boolean): Whether the URL is being validated
  • hasError (boolean): Whether there was an error loading
  • reload (function): Function to retry loading the URL

Environment URLs

  • Development: https://devsso.unpam.ac.id/login-button
  • Production: https://satu.unpam.ac.id/login-button

Features

  • ✅ No dependencies for vanilla JS
  • ✅ Native JavaScript ES6 modules
  • ✅ React component (JSX/TSX) and TypeScript support
  • ✅ React hooks for advanced usage
  • ✅ Automatic domain detection
  • ✅ Multiple language support (Indonesian/English)
  • ✅ Theme support (white/black)
  • ✅ Responsive sizing options
  • ✅ URL validation before iframe creation
  • ✅ Error handling and logging
  • ✅ Loading states for React components

File Structure (npm-package)

  • index.js — Native JavaScript (no dependencies)
  • react.jsx — React component (JSX, JavaScript)
  • react.tsx — React component (TypeScript, recommended for TS/modern React)

License

MIT