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

@palantir/pack.auth.foundry

v0.3.0

Published

Foundry-specific authentication implementations for PACK applications

Readme

@palantir/pack.auth-foundry

Foundry-specific authentication implementations for PACK applications.

Overview

This package provides concrete authentication services that implement the @palantir/pack.auth interfaces for Palantir Foundry platforms. It includes support for various authentication methods including OAuth flows and static token providers.

Authentication Services

StaticTokenService

For applications with pre-existing tokens (CLI tools, service accounts, etc.):

import { createStaticTokenService } from "@palantir/pack.auth-foundry";

const tokenProvider = () => Promise.resolve("your-existing-token");
const service = createStaticTokenService(tokenProvider, baseUrl);

// Starts authenticated immediately
console.log(service.isAuthenticated()); // true
console.log(service.isValidated()); // false (until explicitly validated)

// Validate when needed
await service.validateToken(); // Calls platform API to verify token
console.log(service.getCurrentUser()); // UserRef with platform data

PublicOauthService

For browser applications requiring user login:

import { createPublicOauthClient } from "@osdk/oauth";
import { createPublicOauthService } from "@palantir/pack.auth-foundry";

const oauthClient = createPublicOauthClient(clientId, baseUrl, redirectUrl);
const service = createPublicOauthService(oauthClient, baseUrl);

// Starts unauthenticated
console.log(service.isAuthenticated()); // false

// User must sign in
await service.signIn(); // Redirects to OAuth flow
console.log(service.isAuthenticated()); // true (after successful OAuth)

// Validate to get user data
await service.validateToken();
console.log(service.getCurrentUser()); // UserRef with platform data

ConfidentialOauthService

For server-side applications with client credentials:

import { createConfidentialOauthClient } from "@osdk/oauth";
import { createConfidentialOauthService } from "@palantir/pack.auth-foundry";

const oauthClient = createConfidentialOauthClient(
  clientId,
  clientSecret,
  baseUrl,
);
const service = createConfidentialOauthService(oauthClient, baseUrl);

// Starts authenticated after initial token fetch
await service.signIn(); // Performs client credentials flow
console.log(service.isAuthenticated()); // true

// Validate to get user data (may not be available for service accounts)
await service.validateToken();

Authentication vs Validation

All services follow the same pattern:

  • Authenticated: Has a token available locally
  • Validated: Token has been verified with the Foundry platform

This separation allows for:

  • Fast startup: No blocking API calls during initialization
  • Explicit validation: Apps control when validation occurs
  • Token reuse: Works with existing/cached tokens
  • User data access: Only available after validation
// Immediately after creation
service.isAuthenticated(); // May be true (static/confidential) or false (public)
service.isValidated(); // Always false initially
service.getCurrentUser(); // Always undefined initially

// After validation
await service.validateToken();
service.isValidated(); // true if token is valid
service.getCurrentUser(); // UserRef if validation succeeded

Integration

This package is typically used through @palantir/pack.app's initPackApp() function, which automatically creates the appropriate service based on the OSDK client's authentication:

import { createClient } from "@osdk/client";
import {
  createConfidentialOauthClient,
  createPublicOauthClient,
} from "@osdk/oauth";
import { initPackApp } from "@palantir/pack.app";

// Public OAuth (browser apps)
const publicAuth = createPublicOauthClient(
  "your-client-id",
  "https://your-foundry-instance.com",
  "http://localhost:3000/callback",
);
const publicClient = createClient(baseUrl, ontologyRid, publicAuth);
const app = initPackApp(publicClient, { app: { appId: "your-app" } });

// Static token (CLI/service)
const tokenProvider = () => Promise.resolve("your-token");
const tokenClient = createClient(baseUrl, ontologyRid, tokenProvider);
const app = initPackApp(tokenClient, { app: { appId: "your-app" } });

// Confidential OAuth (server apps)
const confidentialAuth = createConfidentialOauthClient(
  "your-client-id",
  "your-client-secret",
  "https://your-foundry-instance.com",
);
const confidentialClient = createClient(baseUrl, ontologyRid, confidentialAuth);
const app = initPackApp(confidentialClient, { app: { appId: "your-app" } });

// Override auth with custom token provider
const app = initPackApp(client, {
  app: { appId: "your-app" },
  auth: customTokenProvider, // Override client's auth
});

The services handle platform-specific details like:

  • OAuth flow management
  • Token refresh and expiration
  • Platform API integration for validation
  • User data fetching and caching
  • State change notifications

Platform APIs

Token validation uses the Foundry platform API:

  • Endpoint: ${baseUrl}/multipass/api/users/me
  • Purpose: Verify token validity and fetch user information
  • Caching: User data cached for 5 minutes via UserRef
  • Error handling: Network errors and invalid tokens handled gracefully