SEP-10

The @colibri/sep10 package provides SEP-10 Web Authenticationarrow-up-right for Stellar.

Installation

deno add jsr:@colibri/sep10

Quick Start

import { Sep10Client } from "@colibri/sep10";
import { StellarToml } from "@colibri/core";
import { Keypair } from "stellar-sdk";

// Fetch and parse stellar.toml
const toml = await StellarToml.fromDomain("anchor.example.com");

// Create client directly from StellarToml instance
const client = Sep10Client.fromToml(toml);

const keypair = Keypair.fromSecret("S...");
const jwt = await client.authenticate({
  account: keypair.publicKey(),
  signer: keypair,
});

// Use jwt.token for authenticated requests

Sep10Client

Constructor

fromToml(toml, networkPassphrase?)

Create client from a StellarToml instance:

The client extracts webAuthEndpoint, signingKey, domain, and networkPassphrase from the StellarToml instance.

Throws:

  • INVALID_TOML if domain is missing

  • MISSING_AUTH_ENDPOINT if WEB_AUTH_ENDPOINT is missing

  • INVALID_TOML if SIGNING_KEY is missing

  • INVALID_TOML if WEB_AUTH_ENDPOINT is not a valid URL

  • INVALID_TOML if NETWORK_PASSPHRASE is missing and not provided

authenticate(options)

Complete authentication flow in one call:

getChallenge(options)

Fetch and verify a challenge transaction:

submitChallenge(challenge)

Submit a signed challenge for a JWT:

SEP10Challenge

Parse and manipulate challenge transactions directly.

fromXDR(xdr, networkPassphrase)

Parse a challenge from XDR:

build(options)

Build a challenge transaction (server-side):

Properties

Property
Type
Description

clientAccount

string

Client's Stellar account

serverAccount

string

Server's Stellar account

homeDomain

string

Home domain from challenge

webAuthDomain

string?

Web auth domain if present

clientDomain

string?

Client domain if present

memo

string?

Memo if present

timeBounds

{ minTime, maxTime }

Challenge validity period

isExpired

boolean

Whether challenge has expired

nonce

Buffer

48-byte random nonce

signatures

xdr.DecoratedSignature[]

Current signatures

Methods

Verify Options

Sep10Jwt

Decode and inspect JWT tokens.

fromToken(token)

Parse a JWT token:

Properties

Property
Type
Description

token

string

Raw JWT string

subject

string?

Account (G... or G...:memo)

issuer

string?

Token issuer

expiresAt

Date?

Expiration time

issuedAt

Date?

Issue time

jti

string?

JWT ID

homeDomain

string?

SEP-10 home domain

webAuthDomain

string?

SEP-10 web auth domain

clientDomain

string?

SEP-10 client domain

memo

string?

Memo if present

muxedAccountId

string?

Muxed account ID if present

isExpired

boolean

Whether token has expired

timeUntilExpiration

number?

Milliseconds until expiration

claims

Record<string, unknown>

All claims

Error Handling

Errors follow the SEP10_CHAL_XXX format for challenge errors and SEP10_CLI_XXX for client errors. Import error classes from:

Last updated