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

@orcestr/auth-core

v0.4.1

Published

Framework-independent Orcestr authentication client and redirect helpers.

Downloads

727

Readme

@orcestr/auth-core

npm License: MPL 2.0

Независимый от framework browser-клиент авторизации для экосистемы Orcestr. В пакете нет зависимости от React, UI kit или Next.js.

Установка

npm install @orcestr/core @orcestr/auth-core

Что входит

  • AuthClient с cookie credentials, CSRF header и одним автоматическим refresh/retry;
  • typed contracts пользователя, методов, routes и OAuth;
  • проверка безопасного внутреннего next и helpers для auth URL;
  • OAuth authorize URL для GitHub, Google и Яндекса;
  • lifecycle browser state и PKCE verifier.
  • stateless OAuth 2.1 authorization-code + PKCE helpers для public/native clients.

Использование

import { AuthClient, safeRedirectPath } from '@orcestr/auth-core';

export const auth = new AuthClient({
    logging: {
        enabled: process.env.NODE_ENV !== 'production',
        label: 'AUTH',
        logRequestsDelay: true,
    },
    routes: {
        methods: '/api/v1/auth/methods/',
        login: '/api/v1/auth/login/',
        register: '/api/v1/auth/register/',
        me: '/api/v1/auth/me/',
        refresh: '/api/v1/auth/refresh/',
        logout: '/api/v1/auth/logout/',
        passwordResetRequest: '/api/v1/auth/password/reset/request/',
        passwordResetConfirm: '/api/v1/auth/password/reset/confirm/',
        emailVerificationCode: '/api/v1/auth/email/verification-code/',
        emailConfirm: '/api/v1/auth/email/confirm/',
        oauthCallback: (provider) => `/api/v1/auth/oauth/${provider}/callback/`,
    },
});

const next = safeRedirectPath(searchParams.get('next'), '/overview');

logging принимает true, false или настройки cutie-logs. Чувствительные поля, включая пароли и токены, автоматически скрываются.

Навигация и product-specific fallback targets остаются в приложении.

Альтернативный transport приложения

AuthClientContract<TUser> — полный структурный контракт, который используют React adapter и готовые формы. Стандартный AuthClient реализует его через browser cookies. Native-приложение может реализовать те же методы через доверенный IPC bridge, сохранив поддержку email/password и provider OAuth:

import type { AuthClientContract, AuthUser } from '@orcestr/auth-core';

export const nativeAuth: AuthClientContract<AuthUser> = createNativeAuthClient();

Реализация возвращает те же user/method contracts, включая oauthCallback, и отклоняет запросы через ApiError из @orcestr/core, чтобы React hooks и локализованные формы работали одинаково. Контракт не задаёт хранение токенов: native client должен держать access token вне renderer, а refresh token — в защищённом системном хранилище.

OAuth 2.1 для public/native clients

Desktop, mobile и другие public clients могут собрать authorization request и обменять код, не включая client secret в приложение:

import {
    OAuthTokenClient,
    createOAuthAuthorizationRequest,
    parseOAuthCallback,
} from '@orcestr/auth-core';

const redirectUri = 'com.example.desktop://oauth/callback';
const pending = await createOAuthAuthorizationRequest({
    authorizationEndpoint: 'https://auth.example.com/oauth/authorize',
    clientId: 'my-desktop-app',
    redirectUri,
    scope: ['profile'],
});

await openExternal(pending.authorizationUrl);

const callback = parseOAuthCallback(receivedDeepLink, {
    expectedState: pending.state,
    expectedRedirectUri: redirectUri,
});
const tokens = await new OAuthTokenClient({
    tokenEndpoint: 'https://auth.example.com/oauth/token',
    clientId: 'my-desktop-app',
}).exchangeAuthorizationCode({
    code: callback.code,
    redirectUri,
    codeVerifier: pending.codeVerifier,
});

createOAuthAuthorizationRequest использует криптографически стойкие state и PKCE S256. SDK не сохраняет state, verifier и полученные токены. Данные незавершённого flow хранятся только на время authorization round trip, а приложение само выбирает память или защищённое системное хранилище для токенов. Custom redirect scheme должен быть зарегистрирован в native-приложении и точно добавлен в allowlist его OAuth client на authorization server. При разборе полного callback URL всегда передавай expectedRedirectUri. Authorization и token endpoints должны использовать HTTPS; HTTP разрешён только для localhost, 127.0.0.1 и ::1 при локальной разработке. Встроенные credentials, query string и fragment отклоняются; authorization extensions передаются через additionalParameters.

Ошибки

При неуспешном запросе AuthClient выбрасывает ApiError из @orcestr/core. Для поведения и локализации используй стабильные auth-коды:

import { isApiError } from '@orcestr/core';
import { AUTH_ERROR_CODES } from '@orcestr/auth-core';

try {
    await auth.login(username, password);
} catch (error) {
    if (isApiError(error) && error.code === AUTH_ERROR_CODES.invalidCredentials) {
        showLoginError('Неверный email, логин или пароль.');
    }
}

Готовые формы уже содержат английский и русский auth catalog. Headless consumers должны передать собственный catalog и использовать серверный message только как безопасный диагностический fallback.

Репозиторий и полная архитектура: Orcestr Auth.