@seams/wallet

中文文档
0.41.1发布于 2026/11/02Apache-2.0TypeScriptES Module构建来源已验证

Seams web and runtime TypeScript SDK for NEAR and EVM-family wallets

原始使用文档
文档目录12 节
  1. Install
  2. Current API
  3. Application sessions and fresh owner approval
  4. Bring your own Google authentication
  5. React quick start
  6. Signing and lifecycle
  7. Wallet settings
  8. Hosted boundary and regional homes
  9. Initial loading and registration
  10. Public entrypoints
  11. Develop from source
  12. License and support

Seams Wallet SDK

@seams/wallet 0.41.1 provides browser wallet lifecycle, NEAR and EVM-family threshold signing, React components, and hosted wallet runtime assets.

Install

pnpm add @seams/[email protected]

React and React DOM are optional peers with >=19.0.0, including future major versions. SDK development uses exact [email protected] and [email protected]. Application lockfiles select the installed React version. Import the provider and UI from @seams/wallet/react and its stylesheet from @seams/wallet/react/styles. Keep the application package, wallet-origin assets, and @seams/[email protected] on the matching release. The wallet iframe protocol is 23.0.0. The application and wallet host must use the same protocol version.

Current API

The public API groups calls under auth, connection, config, events, registration, and the chain namespaces. See the browser reference. Use auth.lock() to end the session while retaining valid durable presignatures.

Custom email unlock uses a host-owned challenge:

const requested = await seams.auth.requestEmailCode({
  method: 'google',
  idToken,
  target: { kind: 'wallet', walletId },
});
if (!requested.ok) throw new Error(requested.error.message);
const result = await seams.auth.unlockWithEmailCode({
  challenge: requested.value,
  code,
});
if (!result.ok) throw new Error(result.error.message);

For an existing local email method, request with { method: 'email', walletId, email }. The challenge supports resend() and cancel(). Use the replacement challenge returned by a successful resend. The SDK selects signers and completes pending activation internally.

Request email codes only after a user chooses that method. The wallet host owns the challenge and its expiry. The application receives the typed challenge handle.

Application sessions and fresh owner approval

SDK 0.41.1 accepts a handoff from an explicitly trusted application backend. Google and app-passkey login can use the same stable application user ID. Use registration.registerOwnerWallet for NEAR-only passkey onboarding and near.prepareOwnerTransaction for fresh approval of each transaction. These operations create no reusable signing authority. React read connections expose owner-operation handles separately from reusable signers. See the application-session guide.

Bring your own Google authentication

SDK 0.41.1 can reuse an application's Google ID token to open associated wallet settings. Configure the environment's Google client ID and let the owner associate their wallet once. Then pass the token after the application's existing Google login:

const result = await seams.auth.authenticate({ method: 'google', walletId, idToken });
if (!result.ok) throw new Error(result.code);

Apps that retain the token on their backend use prepareExternalAuth and a browser-bound handoff. Call seams.auth.lock() when the app logs out or switches accounts. These sessions grant settings reads. Signing, export, recovery, and security changes retain their owner authentication requirements. See the Google SSO guide for both exchange paths, association, expiry, and revocation.

React quick start

The three required values are the wallet origin, Gateway/relayer URL, and managed-registration publishable key. Obtain them from your project and allow your application's origin in that environment. Browser configuration is public.

import {
  HostedSeamsAuthMenu,
  SeamsWebProvider,
  seamsTestnetConfig,
  type HostedAuthMenuOutcome,
} from '@seams/wallet/react';
import '@seams/wallet/react/styles';

const config = seamsTestnetConfig({
  walletOrigin: import.meta.env.VITE_WALLET_ORIGIN,
  relayerUrl: import.meta.env.VITE_RELAYER_URL,
  publishableKey: import.meta.env.VITE_SEAMS_PUBLISHABLE_KEY,
});

function handleOutcome(outcome: HostedAuthMenuOutcome): void {
  console.log('Wallet authentication:', outcome);
}

export function App() {
  return (
    <SeamsWebProvider config={config}>
      <HostedSeamsAuthMenu onOutcome={handleOutcome} />
    </SeamsWebProvider>
  );
}

seamsTestnetConfig selects NEAR and Tempo testnets. Use defineSeamsConfig for another chain set. EVM-family chain records require their numeric chainId. An optional projectEnvironmentId cross-check rejects a publishable key for a different environment.

The hosted menu owns registration, sign-in, OTP prompts, recovery-code backup, and user presence. Supply externalAuthBroker when your application acquires Google identity evidence for the wallet host. Keep secret credentials and recovery material out of app configuration and logs.

Signing and lifecycle

useSeams() exposes authentication actions, lifecycle state, and the current wallet. The wallet is null while signed out. An authenticated wallet provides near, evm, and tempo signers bound to its identity. wallet.near is null until a NEAR account is ready. Check registration's pending branches and use registration.waitForNearAccount before signing NEAR.

const { unlock, lock, wallet } = useSeams();

Unlock updates the wallet in a subsequent React render. Use the authenticated render's wallet in signing handlers. wallet.walletId identifies that wallet.

The framework-neutral SeamsWeb client groups operations under registration, auth, near, evm, tempo, recovery, devices, and keys. Signing can use fresh authorization for one operation; unlock provisions a bounded reusable Wallet Session. An EVM-family signing or export call requires a chainTarget naming a configured chain.

keys.exportKey opens a wallet-origin viewer and returns { kind: 'exported' }. It does not return a private key to the application. recovery.syncAccount synchronizes a known wallet's account state; the hosted menu handles recovery codes and new-factor verification.

See the compiled examples for registration, unlock, signing, linked devices, export, recovery, and theming.

Wallet settings

WalletSettingsPage provides accounts, key export, recovery codes, authentication methods, device linking, linked devices, and transaction preferences. Signed-out users see the hosted authentication menu.

import {
  SeamsWebProvider,
  WalletSettingsPage,
  type SeamsConfigsInput,
} from '@seams/wallet/react';
import '@seams/wallet/react/styles';

export function WalletSettingsApp({ config }: { config: SeamsConfigsInput }) {
  return (
    <SeamsWebProvider config={config}>
      <WalletSettingsPage />
    </SeamsWebProvider>
  );
}

Keep the configured /wallet-service endpoint available. A bare service HTML asset needs the deployment's bootstrap and configuration before it can serve a complete settings application.

Hosted boundary and regional homes

The dedicated wallet origin serves /wallet-service and /sdk/*, including workers, WASM, and the export viewer. The SDK iframe delegates WebAuthn permissions to that origin. Credential creation and assertions execute there; there is no application-origin credential bridge.

Regional hosted deployments assign each wallet a home at registration. Wallets in one project can have different homes, while all devices of one wallet use the same home. Travel does not change it. The owner can move a wallet to another region with the wallet region setting. Automatic region relocation is a future capability.

For APAC, registration and relocation request Southeast Asia placement through apac-se. The hint does not guarantee a city or move existing objects. Operators must verify the actual object locations and database primaries.

Follow the upgrade guide before changing the application, wallet assets, or backend. An incompatible open client must reload matching assets before retrying.

Initial loading and registration

When the wallet origin stores no wallet, the host answers connection reads from its boot code. It loads the runtime when an operation needs it. Call seams.authMenu.prepare() on sign-in intent to download the sign-in code earlier. Mounting HostedSeamsAuthMenu starts that download without an additional call.

Opening the hosted registration view prepares its wallet and passkey challenge. authMenu.prepare() only downloads code. A direct registerWallet() call starts registration setup within that call. See the compiled hosted-menu examples.

Registration can sign before its completion appears in the Console directory. The Gateway retries pending directory publications. Until acknowledgment, the wallet can be absent from the Console list and unavailable for region moves.

Public entrypoints

  • @seams/wallet — browser client, config builders, public results and values.
  • @seams/wallet/react — providers, hooks, components, transaction review, and themes.
  • @seams/wallet/external-evm — browser EVM extension connector.
  • @seams/wallet/advanced — exact identity builders, RPC and encoding helpers.
  • @seams/wallet/threshold — session-policy helpers, PRF salts, and intent digests.
  • @seams/wallet/runtime — explicit platform ports and custom signing runtime.

Use the documented package exports. Agent-lane issuance remains planned. The VoiceID approval prototype is opt-in:

import { defineSeamsConfig } from '@seams/wallet';
import { voiceIdAuthMethod } from '@seams/voiceid';

const config = defineSeamsConfig({
  walletOrigin,
  relayerUrl,
  publishableKey,
  authMethods: [voiceIdAuthMethod()],
});

VoiceID is a separate optional package. The Wallet host operator must deploy its assets alongside the Wallet host. The descriptor alone downloads no implementation or models. VoiceID supports enrollment, Wallet Session unlock, and reviewed NEAR and Arc testnet signing. See @seams/voiceid for installation.

Develop from source

From the repository root:

pnpm install
pnpm build
pnpm -C packages/wallet dev
pnpm test:wallet-browser
pnpm -C packages/wallet type-check

With the required WASM and server artifacts already built, rebuild only the SDK with pnpm -C packages/wallet build:sdk. See the repository README for the full local stack and Console Lite example.

License and support

Apache-2.0. See the package's LICENSE.md and THIRD_PARTY_NOTICES.md.

版本与发布记录

@seams/wallet 共发布 82 个版本,首次发布于 2026/09/13;过去 12 个月发布了 82 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.41.1latest2026/11/021 天前
0.41.02026/11/011 天前
0.40.02026/11/012 天前
0.39.02026/11/012 天前
0.37.02026/11/012 天前
0.36.02026/10/312 天前

关于 @seams/wallet 的常见问题

@seams/wallet 是什么?

为NEAR和evm家族钱包提供web和运行时TypeScript SDK

如何安装 @seams/wallet?

在项目目录运行 npm install @seams/wallet,或使用 pnpm add / yarn add / bun add。

@seams/wallet 支持 TypeScript 吗?

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

@seams/wallet 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@seams/wallet 可以商用吗?

@seams/wallet 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@seams/wallet 还在维护吗?

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