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

@atlasauth/capacitor

v0.3.0

Published

The official Atlas SDK for **Capacitor / Ionic** — the cross-platform (iOS · Android · web) native-auth sibling of [`@atlasauth/electron`](../electron) and [`@atlasauth/expo`](../expo). It gives a Capacitor app the **native-session sign-in flow**: system

Downloads

352

Readme

@atlasauth/capacitor

The official Atlas SDK for Capacitor / Ionic — the cross-platform (iOS · Android · web) native-auth sibling of @atlasauth/electron and @atlasauth/expo. It gives a Capacitor app the native-session sign-in flow: system browser → deep-link callback → PKCE → a cookie-free Atlas session that auto-refreshes and persists in secure storage.

A Capacitor app is a web layer (a WebView on device, a real browser on the web target) with no cookie against the Atlas FAPI origin, so it cannot carry a session the way a web page does. Instead it signs in through the system browser, catches the deep-link callback, completes PKCE, trades the code for an Atlas session, and carries that session itself as a bearer — wrapping the same @atlasauth/js NativeSessionManager / exchangeForSession / refreshNativeSession core the Electron and Expo SDKs use.

Install

npm install @atlasauth/capacitor
npx cap sync
# the Capacitor plugins it drives (all optional peers — install what you use):
npm install @capacitor/browser @capacitor/app @capacitor/preferences

@capacitor/core, @capacitor/browser, @capacitor/app and @capacitor/preferences are optional peers. The package compiles and runs without them (falling back gracefully), but the native sign-in flow needs @capacitor/browser + @capacitor/app, and persistence needs a token store.

Deep-link setup

Register your custom scheme so the authorize redirect reopens the app, and route appUrlOpen to Atlas:

  • iOS: add the scheme under CFBundleURLTypes in Info.plist.
  • Android: add an intent-filter with your scheme to the main activity.

Your redirectUri is that scheme, e.g. com.acme.app://auth.

Quick start

import { createAtlasCapacitor } from '@atlasauth/capacitor';

export const atlas = await createAtlasCapacitor({
  publishableKey: 'pk_live_…',
  frontendApi: 'https://fapi.your-instance.atlasauth.net',
  clientId: 'client_…',            // your first-party native OAuth client
  redirectUri: 'com.acme.app://auth',
});

// Sign in (opens the system browser; resolves once the deep link returns).
await atlas.signIn();

// Call your own API with the live, auto-refreshing session.
const res = await fetch('/api/thing', { headers: await atlas.authHeaders() });

atlas.onChange((session) => console.log('session rotated', session.sessionId));
await atlas.signOut();

frontendApi is required — the publishable key encodes the instance id but not a host. Use https://atlasauth.net before you verify a custom domain, your custom domain after.

The handle

| Method | What it does | | --- | --- | | signIn({ redirectUri?, scope? }) | System browser → deep-link callback → PKCE → session. On the web target, falls back to the standard redirect (see below). | | handleRedirectCallback(url?) | Finish a web redirect sign-in on app load. | | signOut() | Forget the session and clear the store. | | getToken() | The current session JWT, auto-refreshed near expiry. | | authHeaders() | { Authorization, 'x-publishable-key' } for /v1/client/me/* and your API. | | getSession() | The current NativeSession, or null. | | onChange(listener) | Fires on every session change; returns an unsubscribe. |

Web target (PWA)

On the web, there is no deep link, so signIn() falls back to the standard redirect: it stashes the PKCE verifier and navigates to the authorize URL. Finish on the next load:

// on app boot, when the URL looks like your callback:
const session = await atlas.handleRedirectCallback(); // defaults to window.location.href

Secure storage

By default the session is persisted with @capacitor/preferences when that plugin is present, else a non-persistent in-memory store.

⚠️ @capacitor/preferences is plaintext at rest (UserDefaults / SharedPreferences). For production, back the store with a secure-storage community plugin (e.g. @capacitor-community/secure-storage) behind the same TokenStore interface:

import { createAtlasCapacitor, type TokenStore } from '@atlasauth/capacitor';

const secureStore: TokenStore = {
  getToken: () => SecureStorage.get('atlas.session'),
  setToken: (v) => SecureStorage.set('atlas.session', v),
  clearToken: () => SecureStorage.remove('atlas.session'),
};

const atlas = await createAtlasCapacitor({ /* … */ storage: secureStore });

Policy acceptance (terms of service, privacy)

The system-browser sign-in (atlas.signIn()) happens on Atlas's hosted pages, which already collect the acceptances at sign-up and hold a sign-in until a newer version is accepted. For screens in your own WebView:

// A custom sign-up form
const policies = await atlas.policies();
mountPolicyConsent(consentHost, policies, { t: policyText() });
// on submit: send policies.build() as policy_acceptances

// A signed-in user whose policies changed
mountPolicyGate(gateHost, atlas.policyGate(), { onAccepted: () => refresh() });

Pass locale to createAtlasCapacitor to get translated policy versions.

Driving the pieces yourself

The flow is also exposed à la carte: createPkcePair, buildAuthorizeUrl, parseAuthCallback, redeemAuthorizationCode, exchangeAuthCode, signInWithBrowser, completeRedirectSignIn, plus createNativeSessionManager / exchangeForSession / refreshNativeSession re-exported from @atlasauth/js.