@burnt-labs/abstraxion-js

中文文档
1.0.0-alpha.6发布于 2026/10/24MITTypeScriptESM + CJS构建来源已验证近 30 天下载 2864

The framework-agnostic runtime for XION account abstraction. Owns the per-mode auth state machine, controllers, strategies, and signing clients — with no React, no DOM, and no platform assumptions baked in.

原始使用文档
文档目录8 节
  1. Installation
  2. The runtime
  3. Authentication modes
  4. Strategy injection (running outside the browser)
  5. Direct signing
  6. Public surface (selected exports)
  7. Building a new framework wrapper
  8. License

@burnt-labs/abstraxion-js

The framework-agnostic runtime for XION account abstraction. Owns the per-mode auth state machine, controllers, strategies, and signing clients — with no React, no DOM, and no platform assumptions baked in.

You only need to depend on this package directly if you are:

  • Building a non-React/RN integration (Svelte, Vue, SolidJS, vanilla JS)
  • Implementing a custom host (e.g. an Electron preload, a service worker, a test harness) that needs to inject its own storage / redirect / iframe-transport behavior
  • Writing a new framework wrapper sibling to @burnt-labs/abstraxion-react or @burnt-labs/abstraxion-react-native

If you are building a React app, use @burnt-labs/abstraxion-react. If you are building a React Native app, use @burnt-labs/abstraxion-react-native. Both wrappers re-export the relevant pieces of this runtime, so you rarely need to import from abstraxion-js directly.

Installation

npm i @burnt-labs/abstraxion-js

The runtime

createAbstraxionRuntime(config, strategies?) is the single entry point. It returns a runtime object that owns one controller at a time (the one matching config.authentication.type) and exposes a small reactive API:

import { createAbstraxionRuntime } from "@burnt-labs/abstraxion-js";

const runtime = createAbstraxionRuntime({
  chainId: "xion-testnet-2",
  treasury: "xion1...",
  authentication: { type: "auto" },
});

const unsubscribe = runtime.subscribe((state) => {
  // state.isConnected, state.isConnecting, state.granterAddress, state.error, ...
});

await runtime.login();
const snapshot = runtime.getState();
await runtime.logout();
unsubscribe();

That's the entire surface a host framework needs to bind to. React's useSyncExternalStore, a Svelte readable store, a Vue ref — all are thin adapters around runtime.subscribe(listener) → unsubscribe plus runtime.getState().

Authentication modes

The authentication field of the config picks the controller:

ModeControllerWhat it does
popupPopupControllerOpens the dashboard in a popup window; communicates via postMessage.
redirectRedirectControllerFull-page redirect to the dashboard; returns to a callback URL.
embeddedIframeControllerRenders the dashboard in an embedded iframe; communicates via MessageChannel.
signerSignerControllerHeadless — caller supplies a signer (Turnkey / MetaMask / Keplr / custom).
autoresolved at initResolves to popup on desktop, redirect on mobile/PWA.

Each controller surfaces the same state shape via runtime.subscribe, so wrappers don't have to special-case modes.

Strategy injection (running outside the browser)

The runtime reaches the host environment through three injectable strategies:

import {
  createAbstraxionRuntime,
  type StorageStrategy,
  type RedirectStrategy,
  type IframeTransportStrategy,
} from "@burnt-labs/abstraxion-js";

const runtime = createAbstraxionRuntime(config, {
  strategies: {
    storageStrategy: myStorageStrategy, // implements StorageStrategy
    redirectStrategy: myRedirectStrategy, // implements RedirectStrategy
    iframeTransportStrategy: myIframeTransport, // implements IframeTransportStrategy
  },
});

Defaults are browser-native:

  • BrowserStorageStrategy — localStorage
  • BrowserRedirectStrategy — window.location + URLSearchParams
  • BrowserIframeTransportStrategy — DOM iframe + MessageChannel

You only override the ones whose default doesn't fit your environment — e.g. @burnt-labs/abstraxion-react-native injects an AsyncStorage-backed StorageStrategy, an Expo-WebBrowser-backed RedirectStrategy, and a react-native-webview-backed IframeTransportStrategy. Modes you don't use (signer doesn't need a redirect strategy, redirect doesn't need an iframe transport) can be left unset.

Direct signing

Two clients are exposed for direct signing (where the meta-account signs each transaction itself, paying its own gas):

  • RequireSigningClient — single client that handles popup / redirect / iframe transports. The transport is selected from the active controller; consumers don't pick it directly.
  • AAClient — used in signer mode; wraps the externally-supplied signer (MetaMask, Keplr, Turnkey, …).

Both expose the same signAndBroadcast / sendTokens / execute surface, so switching between session-key signing and direct signing is a one-line change in the consumer.

Public surface (selected exports)

export { createAbstraxionRuntime } from "@burnt-labs/abstraxion-js";
export type {
  AbstraxionRuntime,
  AbstraxionRuntimeOptions,
} from "@burnt-labs/abstraxion-js";

export {
  BaseController,
  IframeController,
  PopupController,
  RedirectController,
  SignerController,
  createController,
} from "@burnt-labs/abstraxion-js";

export {
  BrowserStorageStrategy,
  BrowserRedirectStrategy,
  BrowserIframeTransportStrategy,
} from "@burnt-labs/abstraxion-js";
export type {
  IframeTransportStrategy,
  // RedirectStrategy and StorageStrategy are re-exported from abstraxion-core
} from "@burnt-labs/abstraxion-js";

export { RequireSigningClient, AAClient } from "@burnt-labs/abstraxion-js";

export {
  ConnectorType,
  IframeMessageType,
  MessageTarget,
} from "@burnt-labs/abstraxion-js";
export { AUTHENTICATOR_TYPE } from "@burnt-labs/abstraxion-js";

For configuration types (AbstraxionConfig, AuthenticationConfig, etc.) see packages/abstraxion-js/src/types.ts — they are re-exported from the framework wrappers as well.

Building a new framework wrapper

The Svelte demo at demos/svelte/ is the worked example: it creates a runtime, subscribes from a Svelte writable, and renders against the resulting store. The same pattern works for Vue (ref + watchEffect), SolidJS (createStore), or any reactivity primitive that can mirror an external subscription.

License

MIT

版本与发布记录

@burnt-labs/abstraxion-js 共发布 6 个版本,首次发布于 2026/06/09;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.0-alpha.6latest2026/10/2416 天前
1.0.0-alpha.52026/10/081 个月前
1.0.0-alpha.42026/10/071 个月前
1.0.0-alpha.32026/08/102 个月前
1.0.0-alpha.22026/07/313 个月前
1.0.0-alpha.12026/06/094 个月前

关于 @burnt-labs/abstraxion-js 的常见问题

@burnt-labs/abstraxion-js 是什么?

The framework-agnostic runtime for XION account abstraction. Owns the per-mode auth state machine, controllers, strategies, and signing clients — with no React, no DOM, and no platform assumptions baked in.

如何安装 @burnt-labs/abstraxion-js?

在项目目录运行 npm install @burnt-labs/abstraxion-js,或使用 pnpm add / yarn add / bun add。

@burnt-labs/abstraxion-js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@burnt-labs/abstraxion-js 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@burnt-labs/abstraxion-js 可以商用吗?

@burnt-labs/abstraxion-js 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@burnt-labs/abstraxion-js 的下载量有多少?

根据 npm 官方下载统计,@burnt-labs/abstraxion-js 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,864 次,日均约 95 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@burnt-labs/abstraxion-js 还在维护吗?

最新版本 1.0.0-alpha.6 发布于 2026/10/24(16 天前);至今共发布 6 个版本,其中过去 12 个月发布了 6 个;首次发布于 2026/06/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。