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

@d0fi/account-sdk

v0.2.1

Published

D0 Account authentication and non-custodial L1 wallet SDK

Readme

@d0fi/account-sdk

This package owns the product-facing D0 Account API and keeps the L1 wallet provider behind an adapter boundary.

It provides authentication, Account session management, pairwise payer authorization, and non-custodial L1 wallet capabilities. Payment collection, payment method selection, Checkout Session execution, refunds, and disputes belong to the separate Checkout SDK and Checkout API.

npm install @d0fi/account-sdk

Use the smallest entry point required by the host:

import { D0AccountSdk, HttpAccountApiClient } from "@d0fi/account-sdk/core";
import { MagicL1WalletAdapter } from "@d0fi/account-sdk/magic";

React hosts import the component entry and its compiled stylesheet. The CSS contains only the Account Kit theme/utilities and does not include Tailwind's global Preflight reset.

import { D0AccountKit } from "@d0fi/account-sdk/react";
import "@d0fi/account-sdk/styles.css";

The root @d0fi/account-sdk entry remains available for compatibility. New integrations should use the explicit subpath entries so core-only hosts do not load Magic or React code.

const sdk = new D0AccountSdk({
  appId: "merchant-app",
  environment: "sandbox",
  adapter: new MagicL1WalletAdapter({ publishableKey }),
  verifyProviderToken: async (token) => {
    await fetch("/api/auth/magic/verify", {
      method: "POST",
      headers: { "content-type": "application/json" },
      body: JSON.stringify({ token }),
    });
  },
});

const challenge = await sdk.authentication.requestEmailOtp(email);
const session = await sdk.authentication.verifyEmailOtp(challenge.challengeId, otp);

const user = await sdk.user.getInfo();
const wallets = sdk.wallets.list();
const signature = await sdk.wallets.signMessage({ chain: "solana", message });
const typedSignature = await sdk.wallets.signTypedData({
  method: "eth_signTypedData_v4",
  typedData,
});

Production uses the D0 Account API as the identity authority. The browser never receives a global D0 account identifier; session.subject, accountId, and appScopedSubject are the same merchant-sector pairwise subject.

const sdk = new D0AccountSdk({
  appId: "merchant-production-account",
  environment: "production",
  adapter: new MagicL1WalletAdapter({ publishableKey }),
  accountApi: new HttpAccountApiClient({
    baseUrl: "https://account.d0fi.com",
  }),
});

Account environment selects the identity environment, not the wallet network. The Magic adapter defaults to Ethereum Sepolia and Solana devnet; configure evmNetworks and solanaRpcUrl explicitly for your deployment. Solana network metadata and the default SIWS chain use the same resolved RPC configuration.

Production initialization fails closed if accountApi is absent. Magic email and OAuth sessions exchange a short-lived DID token through the Account BFF. The SDK generates an RFC 7636 S256 verifier/challenge and nonce, receives a single-use authorization code, and keeps the resulting opaque access token only inside the API client instance. Public clients do not receive refresh tokens. In API-backed sessions, user.getInfo() replaces the provider subject with the D0 pairwise subject, while getIdToken() and generateIdToken() reject provider token export. Production SIWE uses the separate D0 wallet-proof flow. The adapter only connects the EIP-1193 wallet and signs the exact, short-lived D0 challenge; D0 verifies personal_sign, consumes the challenge once, and issues the same PKCE-bound authorization code used by other login methods. It does not trust a browser- supplied address or use Magic's SIWE message as D0 identity proof. Phantom uses the parallel SIWS flow: it signs the exact D0 message bytes, D0 verifies the detached Ed25519 signature against the Base58 Solana address, and consumes the PKCE-bound challenge once. Signatures and plaintext messages are not stored.

After API-backed SIWE, EVM message signing, Typed Data signing and transaction submission use the external wallet connection without requiring a Magic login. The adapter checks that the active address and chain still match the connection before requesting a signature. Reconnect and sign in after an account change; use wallets.switchNetwork() for an intentional switch to a configured network.

Identity linking uses the same-origin Account Portal session. Its HTTP client forwards the Portal CSRF cookie as x-d0-csrf; a missing or invalid cookie remains a server-side rejection. This is separate from the merchant public-client login flow.

For the complete embedded UI, the host application only controls visibility:

<D0AccountKit
  sdk={sdk}
  open={accountKitOpen}
  onClose={() => setAccountKitOpen(false)}
/>

To place the same kit directly in a page, use inline. Inline kits are always visible, ignore open, and do not create a backdrop, close control, focus trap, or body scroll lock:

<D0AccountKit
  sdk={sdk}
  inline
  open
  onClose={() => {}}
/>

Authentication screens, the authenticated account view, wallet discovery and message signing are implemented inside the SDK component rather than the host.

authentication, user, and wallets are separate public capability domains, matching the conceptual split in Magic while keeping D0-owned API names and UI. The UI never imports or calls Magic directly. MockL1WalletAdapter implements the same contract for isolated SDK development; the real integration demo does not fall back to mock mode.

Scope and execution boundary

  • Implemented: custom email + OTP flow, D0 account/session projection, EVM and Solana L1 wallet projection, Magic OAuth redirect, reusable React Login Kit, user/session methods, EVM personal and Typed Data v3/v4 signing, EVM transaction submission, Solana message signing, Magic wallet widgets, Magic and mock adapters.
  • Implemented server boundary: Magic token exchange, SIWE and SIWS wallet-proof exchange, persistent identity resolution, replay protection, and merchant-sector pairwise subjects.
  • External execution still required: KYC provider, Cashier/Indexer callbacks, payment-rail execution, chain broadcast, notifications, and production infrastructure.
  • Never accepted by the browser SDK: a Magic secret key.

Settings, MFA, recovery, private-key export, transactions, and hosted wallet UI must remain explicit product-policy decisions. The adapter exposes the provider capability; it does not make the action safe or authorized for production.