I've read the documentation about the SEP-10 Authentication Protocol of the network but is kinda overwhelming for me.
Do have any available code snippets for the said process able to study thoroughly. Much appreciated if you are using the JS SDK.
Stellar Stack Exchange is a question and answer site for developers and users of Stellar and the Stellar Distributed Exchange. It only takes a minute to sign up.
Sign up to join this communityI've read the documentation about the SEP-10 Authentication Protocol of the network but is kinda overwhelming for me.
Do have any available code snippets for the said process able to study thoroughly. Much appreciated if you are using the JS SDK.
Satoshipay has an open source SEP-10 library implementation: https://github.com/satoshipay/stellar-sep-10
Example from their README.md:
// Look up the stellar.toml for an issuing account, parse it, return data
import { Server } from "stellar-sdk"
import { fetchWebAuthData } from "@satoshipay/stellar-sep-10"
const horizon = new Server("https://stellar-horizon.satoshipay.io/")
const issuingAccountID =
"GABWHTAVRYF2MCNDR5YC5SC3JTZQBGDZ3HKI4QAREV5533VU43W4HJUX"
const webauth = fetchWebAuthData(horizon, issuingAccountID)
// typeof webauth = { endpointURL: string, signingKey: string } | undefined
import { Keypair } from "stellar-sdk"
import { authenticate } from "@satoshipay/stellar-sep-10"
const accountKeypair = Keypair.fromSecret("S...")
const jwt = await authenticate(
webauth.endpointURL,
webauth.signingKey,
accountKeypair,
Network.current()
)