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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mission_sciences/provider-sdk

v0.1.2

Published

Provider SDK for JWT-based marketplace session management

Readme

Marketplace Provider SDK

JWT-based session management for application providers in the General Wisdom marketplace ecosystem

License: MIT TypeScript npm version GitHub Actions

📦 Migration Complete: This package has been migrated from Bitbucket to GitHub and renamed from @marketplace/provider-sdk to @mission_sciences/provider-sdk. Now available on public npm with cryptographic provenance! See Migration Guide below.

🚀 Quick Start

# Install
npm install @mission_sciences/provider-sdk

# Initialize
import MarketplaceSDK from '@mission_sciences/provider-sdk';

const sdk = new MarketplaceSDK({
  jwtParamName: 'jwt',
  applicationId: 'your-app-id',
  jwksUrl: 'https://api.generalwisdom.com/.well-known/jwks.json',
  onSessionStart: async (context) => {
    // Your auth logic
  },
  onSessionEnd: async (context) => {
    // Cleanup logic
  },
});

await sdk.initialize();

📚 Documentation

Example Integrations

✨ Features

Core Features

  • Zero Dependencies: Self-contained with minimal external deps
  • Framework Agnostic: Works with vanilla JS, React, Vue, and more
  • TypeScript First: Full type definitions included
  • Lightweight: < 10KB gzipped
  • Secure: RS256 JWT verification with JWKS
  • Customizable: Flexible styling and event handling

Advanced Features (Phase 2)

  • ❤️ Heartbeat System: Automatic server sync
  • 🔄 Multi-Tab Sync: Master tab election with BroadcastChannel API
  • Session Extension: Self-service renewal
  • Early Completion: End sessions early with refund calculation
  • 👁️ Visibility API: Auto-pause when tab hidden
  • 🔐 Backend Validation: Alternative to JWKS for sensitive apps

🎯 How It Works

Marketplace → JWT in URL → SDK validates → Your app authenticates → Session active

When users launch your app from the marketplace:

  1. URL Detection: SDK checks for JWT parameter (?jwt=...)
  2. JWT Validation: Verifies signature using RS256 and JWKS
  3. Session Start: Calls your onSessionStart hook
  4. Timer Start: Countdown begins
  5. Session Active: User interacts with your app
  6. Warning: Alert at 5 minutes remaining (configurable)
  7. Session End: Calls your onSessionEnd hook
  8. Redirect: Returns to marketplace (optional)

🔒 Secure Publishing & Provenance

This package is published with cryptographic provenance attestation:

  • Dual Publishing: Available on both npm (public) and AWS CodeArtifact (private)
  • Cryptographic Signatures: All releases signed with GitHub Actions OIDC
  • Provenance Transparency: Build provenance recorded in Sigstore transparency log
  • No Hardcoded Secrets: CI/CD uses OIDC for AWS and npm authentication
  • Automated CI/CD: GitHub Actions workflow with comprehensive testing and security checks

Verify package provenance:

npm view @mission_sciences/provider-sdk --json | jq .dist

📦 Installation

NPM (Public Registry)

npm install @mission_sciences/provider-sdk

AWS CodeArtifact (Private Registry)

# Configure CodeArtifact
aws codeartifact login \
  --tool npm \
  --domain general-wisdom-dev \
  --repository sdk-packages \
  --region us-east-1

# Install
npm install @mission_sciences/provider-sdk

Yarn

yarn add @mission_sciences/provider-sdk

PNPM

pnpm add @mission_sciences/provider-sdk

🏗️ Basic Usage

Vanilla JavaScript

import MarketplaceSDK from '@mission_sciences/provider-sdk';

const sdk = new MarketplaceSDK({
  jwtParamName: 'jwt',
  applicationId: 'my-app',
  jwksUrl: 'https://api.generalwisdom.com/.well-known/jwks.json',
  
  onSessionStart: async (context) => {
    // Store user info
    localStorage.setItem('user_id', context.userId);
    localStorage.setItem('session_id', context.sessionId);
    
    // Show app UI
    document.getElementById('app').style.display = 'block';
  },
  
  onSessionEnd: async (context) => {
    // Clear storage
    localStorage.clear();
    
    // Hide app UI
    document.getElementById('app').style.display = 'none';
  },
});

await sdk.initialize();

// Mount session header
const header = sdk.createSessionHeader();
header.mount('#session-header');

React

import { useEffect } from 'react';
import MarketplaceSDK from '@mission_sciences/provider-sdk';

function useMarketplaceSession() {
  useEffect(() => {
    const sdk = new MarketplaceSDK({
      jwtParamName: 'jwt',
      applicationId: 'my-react-app',
      jwksUrl: 'https://api.generalwisdom.com/.well-known/jwks.json',
      
      onSessionStart: async (context) => {
        // Call your auth API
        await authenticateUser(context);
      },
      
      onSessionEnd: async (context) => {
        // Clear auth state
        await logout();
      },
    });

    sdk.initialize();

    return () => sdk.destroy();
  }, []);
}

See INTEGRATION_GUIDE.md for Vue, Chrome Extensions, and more.

🎨 Session Header Component

Pre-built UI component for displaying session timer:

const header = sdk.createSessionHeader({
  containerId: 'session-header',
  theme: 'dark', // 'light' | 'dark' | 'auto'
  showControls: true,
  showEndButton: true,
});

header.mount('#session-header');

Custom Styling:

.gw-session-header {
  background: #1a1a1a;
  padding: 12px 24px;
}

.gw-session-timer {
  font-size: 18px;
  color: #00ff88;
}

.gw-session-timer--warning {
  color: #ff6b00;
}

🔐 Authentication Integration

Exchange JWT for Your App's Tokens

onSessionStart: async (context) => {
  // Send marketplace JWT to your backend
  const response = await fetch('https://api.your-app.com/auth/marketplace', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${context.jwt}`,
    },
  });
  
  const { token } = await response.json();
  
  // Store your app's auth token
  localStorage.setItem('auth_token', token);
},

Backend Example (Python/Flask):

@app.route('/auth/marketplace', methods=['POST'])
def marketplace_auth():
    jwt_token = request.headers.get('Authorization').replace('Bearer ', '')
    
    # Validate JWT
    claims = validate_marketplace_jwt(jwt_token)
    
    # Create/update user
    user = get_or_create_user(claims['userId'], claims.get('email'))
    
    # Generate your app's token
    app_token = generate_app_token(user)
    
    return jsonify({'token': app_token})

See INTEGRATION_GUIDE.md#authentication-integration for Cognito, Firebase, Auth0 examples.

⚙️ Configuration

SDK Options

interface SDKOptions {
  // Required
  jwtParamName: string;              // URL parameter name
  applicationId: string;             // Your app ID
  jwksUrl: string;                   // JWKS endpoint
  onSessionStart: (context) => Promise<void>;
  onSessionEnd: (context) => Promise<void>;
  
  // Optional
  onSessionWarning?: (context) => Promise<void>;
  onSessionExtend?: (context) => Promise<void>;
  marketplaceUrl?: string;           // Redirect after session end
  warningThresholdMinutes?: number;  // Default: 5
  debug?: boolean;                   // Enable logging
  pauseWhenHidden?: boolean;         // Auto-pause when tab hidden
}

JWT Structure

{
  "sessionId": "35iiYDoY1fSwSpYX22H8GP7x61o",
  "applicationId": "your-app-id",
  "userId": "a47884c8-50d1-7040-2de8-b7801699643c",
  "orgId": "org-123",
  "email": "[email protected]",
  "startTime": 1763599337,
  "durationMinutes": 60,
  "exp": 1763602937,
  "iat": 1763599337
}

🧪 Testing

Generate Test JWT

npm run generate-keys     # Create RSA key pair (dev only)
npm run generate-jwt 60   # Generate 60-minute JWT

Test Server

npm run test-server       # Start dev server at localhost:3000

Open: http://localhost:3000?jwt=<YOUR_JWT>

See TESTING_GUIDE.md for unit, integration, and E2E testing.

🛠️ Development

Build

npm run build         # Build for production
npm run dev           # Watch mode

Code Quality

npm run lint          # ESLint
npm run format        # Prettier
npm run type-check    # TypeScript

Examples

cd examples/vanilla-js
npm install
npm run dev

🏗️ Infrastructure & CI/CD

GitHub Actions Workflow

The package is built and published using a comprehensive 8-job GitHub Actions pipeline:

  1. Test & Build - Unit tests, type checking, linting, and production build
  2. Terraform Plan - Review infrastructure changes (CodeArtifact setup)
  3. Terraform Apply - Create/update AWS infrastructure
  4. Publish CodeArtifact - Publish to private AWS registry
  5. Verify CodeArtifact - Confirm successful publication
  6. Publish npm - Publish to public npm with provenance
  7. Verify npm - Confirm successful publication
  8. Create Release - Generate GitHub release with artifacts

Authentication:

  • AWS: OIDC via IAM role GitHubActions-ProviderSDK (no access keys)
  • npm: Trusted Publishing with cryptographic provenance (no tokens)

Planning Documentation

Comprehensive migration and setup documentation available in planning/:

📖 API Reference

MarketplaceSDK

class MarketplaceSDK {
  constructor(options: SDKOptions)
  
  // Initialize SDK
  async initialize(): Promise<void>
  
  // Session management
  hasActiveSession(): boolean
  getSession(): Session | null
  async endSession(reason: string): Promise<void>
  async extendSession(minutes: number): Promise<void>
  
  // UI components
  createSessionHeader(options?: HeaderOptions): SessionHeader
  
  // Timer control
  pauseTimer(): void
  resumeTimer(): void
  isTimerPaused(): boolean
  
  // Cleanup
  destroy(): void
}

Context Types

interface SessionStartContext {
  sessionId: string;
  applicationId: string;
  userId: string;
  orgId?: string;
  email?: string;
  startTime: number;
  expiresAt: number;
  durationMinutes: number;
  jwt: string;
}

interface SessionEndContext {
  sessionId: string;
  userId: string;
  reason: 'expired' | 'manual' | 'error';
  actualDurationMinutes: number;
}

See INTEGRATION_GUIDE.md#api-reference for complete API documentation.

🚀 Production Deployment

Checklist

  • [ ] Update jwksUrl to production endpoint
  • [ ] Set correct applicationId
  • [ ] Enable HTTPS for all endpoints
  • [ ] Configure proper CORS headers
  • [ ] Set up secrets management
  • [ ] Enable rate limiting
  • [ ] Configure monitoring and logging
  • [ ] Test with production JWT
  • [ ] Load test auth endpoints

See INTEGRATION_GUIDE.md#production-deployment for complete checklist.

🐛 Troubleshooting

Common Issues

JWT validation failed

  • Check JWKS URL is correct
  • Verify applicationId matches
  • Ensure JWT not expired

Session header not showing

  • Verify mount element exists
  • Check SDK initialized
  • Confirm active session

Auth server 500 error

  • Check Cognito configuration
  • Verify client secret (if required)
  • Review server logs

See INTEGRATION_GUIDE.md#troubleshooting for detailed solutions.

📚 Resources

📦 Migration from @marketplace/provider-sdk

Repository Migration

This package has been migrated from Bitbucket to GitHub with enhanced security and public availability:

Old:

  • Repository: Bitbucket (private)
  • Package: @marketplace/provider-sdk
  • Registry: AWS CodeArtifact only (private)
  • CI/CD: Bitbucket Pipelines with hardcoded credentials

New:

  • Repository: GitHub/Mission-Sciences/provider-sdk (public)
  • Package: @mission_sciences/provider-sdk
  • Registry: npm (public) + AWS CodeArtifact (private)
  • CI/CD: GitHub Actions with OIDC (zero secrets)
  • Security: Cryptographic provenance attestation

Migration Steps

Step 1: Update package.json

npm uninstall @marketplace/provider-sdk
npm install @mission_sciences/provider-sdk

Step 2: Update imports

// Old
import MarketplaceSDK from '@marketplace/provider-sdk';

// New
import MarketplaceSDK from '@mission_sciences/provider-sdk';

Step 3: Simplify registry config

If using npm (public registry):

# Remove .npmrc - use default npm registry (no configuration needed!)

If using CodeArtifact (private registry):

# Update your .npmrc
@mission_sciences:registry=https://general-wisdom-dev-540845145946.d.codeartifact.us-east-1.amazonaws.com/npm/sdk-packages/

Note: The API is 100% compatible. No code changes required beyond the package name!

Benefits of Migration

Public Availability: Install from npm without AWS credentials ✅ Provenance Attestation: Cryptographic proof of build integrity ✅ Enhanced Security: OIDC authentication, no hardcoded secrets ✅ Open Source Workflow: Public CI/CD pipeline on GitHub Actions ✅ Dual Publishing: Available on both public npm and private CodeArtifact

🤝 Contributing

Contributions welcome! Please read CONTRIBUTING.md first.

📄 License

MIT License - see LICENSE file for details

🆘 Support

📊 Changelog

v0.1.2 (2025-01-11) - Migration Release

  • 🏗️ Migrated from Bitbucket to GitHub
  • 📦 Package renamed: @marketplace/provider-sdk@mission_sciences/provider-sdk
  • 🔒 Added cryptographic provenance attestation
  • ☁️ Dual publishing: npm (public) + AWS CodeArtifact (private)
  • 🔐 Zero-secret CI/CD with OIDC authentication
  • 📝 Comprehensive migration documentation
  • 🚀 GitHub Actions workflow with 8-job pipeline

v0.1.1 (2024) - Pre-Migration

  • Initial Bitbucket release
  • CodeArtifact-only distribution
  • Bitbucket Pipelines CI/CD

v2.0.0 (Planned - Phase 2)

  • Heartbeat system
  • Multi-tab coordination
  • Session extension
  • Early completion
  • Visibility API integration

v1.0.0 (Phase 1)

  • JWT validation with JWKS
  • Session timer management
  • Lifecycle hooks
  • Session header component

Built with ❤️ by the General Wisdom team