@authn-sh/sdk-js
v0.7.1
Published
Vanilla JS/TS runtime for authn.sh.
Readme
@authn-sh/sdk-js
Vanilla JavaScript / TypeScript runtime for authn.sh. The browser/Node SDK that powers @authn-sh/sdk-react and other framework bindings; embed it directly when you want headless auth without a UI framework.
Status: types and infrastructure are stable. The bodies of
Authn.load(), the FAPI fetcher, and theSignIn/SignUpstate machines land in JS-3.
Install
npm install @authn-sh/sdk-jsUsage (preview)
import { Authn } from '@authn-sh/sdk-js';
const authn = new Authn({
publishableKey: 'pk_test_…',
});
await authn.load();
if (authn.session) {
const token = await authn.session.getToken();
// ... call your backend with `Authorization: Bearer ${token}`
}Subpath exports
| Import | Contents |
| --- | --- |
| @authn-sh/sdk-js | Authn, AuthnError, every resource class + type. |
| @authn-sh/sdk-js/errors | AuthnError and the ErrorDetail shape, no runtime overhead. |
| @authn-sh/sdk-js/types | Re-export of @authn-sh/types for type-only consumers. |
Tree-shakeable, side-effect-free, zero runtime dependencies.
License
AGPL-3.0-only — see LICENSE.
