Skip to content

Add @dfx.swiss/core package#140

Merged
TaprootFreak merged 6 commits intodevelopfrom
feature/core-package
Mar 19, 2026
Merged

Add @dfx.swiss/core package#140
TaprootFreak merged 6 commits intodevelopfrom
feature/core-package

Conversation

@TaprootFreak
Copy link
Contributor

Summary

  • New @dfx.swiss/core package: framework-agnostic API client and TypeScript type definitions
  • Extracted all 24 type definition files from @dfx.swiss/react (zero React dependency)
  • DfxApiClient class with typed methods for all DFX API endpoints (auth, buy, sell, swap, asset, fiat, country, user, kyc, transaction, support, payment links/routes, settings, bank accounts)
  • Zero external dependencies — only requires a global fetch function
  • Added monorepo tsconfig path alias for @dfx.swiss/core

Motivation

Currently, any non-React consumer (Edge Wallet, CLI tools, React Native apps, Node.js backends) must reimplement DFX API types and HTTP calls from scratch. This package provides a single source of truth for the DFX API contract.

Usage

import { DfxApiClient, Blockchain } from '@dfx.swiss/core';

const client = new DfxApiClient({ apiUrl: 'https://api.dfx.swiss/v1' });
const assets = await client.asset.list({ blockchains: [Blockchain.BITCOIN] });

const msg = await client.auth.getSignMessage(address);
const { accessToken } = await client.auth.authenticate({ address, signature, wallet: 'edge' });
client.setToken(accessToken);

const quote = await client.buy.quote({ currency, asset, amount: 100 });

Follow-ups

  • Refactor @dfx.swiss/react to consume types/client from core
  • Move Utils and Validations to core (currently still in react)
  • Migrate Edge Wallet plugin to use @dfx.swiss/core

Test plan

  • tsc build succeeds with zero errors
  • All 24 definition files match current @dfx.swiss/react types (synced with latest develop)
  • Review API method signatures against actual DFX API
  • Integration test with Edge Wallet plugin

Framework-agnostic API client and type definitions extracted from
@dfx.swiss/react. Provides DfxApiClient class with typed methods
for all DFX API endpoints (auth, buy, sell, swap, asset, fiat,
country, user, kyc, transaction, support, payment links/routes,
settings, bank accounts).

Zero external dependencies — only requires a global fetch function.
Enables non-React consumers (React Native, Node.js, CLI tools) to
integrate with DFX API without reimplementing types and HTTP logic.
- KycApi: add all step data methods with x-kyc-code header auth
  (setContactData, setPersonalData, setFinancialData, etc.)
- KycApi: add kycRequest() using requestAbsolute() for full URLs
- DfxHttpClient: add custom headers support and specialHandling
  callback for status-code-specific actions (e.g. HTTP 202)
- DfxHttpClient: add requestAbsolute() for non-versioned URLs
- UserApi: fix changeAddress (POST v1, returns SignIn)
- UserApi: add updateCallSettings(), fix return types (User)
- BankAccountApi: add active/default to UpdateBankAccount
- TransactionApi: fix invoice/receipt to return PdfDocument,
  fix history/CSV to use TEXT response type, add date serialization
- Add Utils module (groupBy, formatAmount, isJwt, buildQueryParams)
- Add Validations module (Mail, Phone, Iban with blocked list)
- Add blocked-iban.json data file
- Add ibantools and libphonenumber-js dependencies
- BuyPaymentInfo: add targetAddress field (used by wallet integrations)
- SellPaymentInfo: make iban optional, add sourceAddress and
  paymentMethod fields (wallet integrations send address, not IBAN)
- AuthApi: replace catch(e: any) with proper ApiException type guard,
  add typed SignUpRequest interface instead of Record<string, any>
- TransactionApi: fix empty query string on getSingle, exportCsv,
  getHistory when no params provided
- Remove unused CustomFile import from TransactionApi
- Fix Asset export in definitions/index.ts (export type, not value)
- Move typescript from dependencies to devDependencies
@TaprootFreak TaprootFreak marked this pull request as ready for review March 18, 2026 18:58
- TransactionRefundTarget.refundTarget: required -> optional
  (matches react's optional field)
- UserKyc: add missing phoneCallAccepted field
- PhoneCallStatus: remove ACCEPTED/REJECTED values not in react
- AuthApi.authenticate: first call now uses default auth token,
  retry on 409 uses token: false (was no-op before, both had
  token: false)
- PaymentLinksApi.list: add missing externalPaymentId parameter,
  fix return type to PaymentLink | PaymentLink[]
- SellUrl.confirm / SwapUrl.confirm: change from string with :id
  placeholder to template literal function, consistent with
  BuyUrl.confirm pattern
- Regenerate package-lock.json (typescript now in devDependencies)
@TaprootFreak TaprootFreak merged commit 3b9a0bb into develop Mar 19, 2026
1 check passed
@TaprootFreak TaprootFreak deleted the feature/core-package branch March 19, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant