Skip to content

fix: read SDK results as { data, error } across the guides and lint against regressions - #67

Merged
Bccorb merged 4 commits into
mainfrom
fix/sdk-result-shape-examples
Oct 7, 2026
Merged

Bccorb merged 4 commits into
mainfrom
fix/sdk-result-shape-examples

Conversation

@Bccorb

@Bccorb Bccorb commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Every @seamless-auth/react and @seamless-auth/client request method resolves to SeamlessAuthResult<T> ({ data, error }, exactly one set). Several guides still read results as a Response or an old shape. Verified against seamless-auth-react main (packages/client/src/client/result.ts, createSeamlessAuthClient.ts, packages/react/src/AuthProvider.tsx, authRoutePaths.ts).

Testing

npm run lint (including the new check), npm run typecheck, and npm run build pass.

Closes #10
Closes #11
Closes #12
Closes #13
Closes #14
Closes #54

Bccorb added 4 commits October 6, 2026 22:15
PR #51 moved the react-sdk.mdx snippets to SeamlessAuthResult, but the
page still introduced the pattern after first using it and did not say
what the destructuring means. Add a Reading Results section next to the
first headless-client example: what data and error hold, a short
check-error-then-read-data example, and the two methods that do not
return a result (isPasskeyPrfSupported, authorizedFetch). Other guides
link back to it instead of repeating it.

Also add the TOTP client methods and logoutAllSessions to the coverage
list, make the finishOAuthLogin example check error before navigating,
and replace the stale note that TOTP step-up is only on the raw routes
with verifyStepUpWithTotp(code). The route list already matched
authRoutePaths, so it is unchanged.

Refs #10
The custom UI, OAuth, secure routes, and organizations guides still read
SDK results as a Response (response.ok, await response.json()) or as old
shapes (result.success, result.providers, status?.fresh). None of those
fields exist on SeamlessAuthResult, so the examples did not type-check
and branched on undefined at runtime.

The OAuth callback was a real bug: it wrapped finishOAuthLogin in a
try/catch, but the method never throws, so a failed callback still
navigated to the dashboard. It now surfaces error.message and returns.

Other changes:
- custom-auth-ui: login reads data.loginMethods, handlePasskeyLogin is
  checked by error rather than as a boolean, and the passkey
  registration section documents the real { credentialId, prfCapable }
  payload. Registration no longer claims a phone is required.
- secure-routes: drop the issuer option, which SeamlessAuthServerOptions
  does not have, and spell out the step-up check.
- organizations-memberships: same Response-style bug in two snippets,
  missed by #54's table; fixed so the new lint check can pass.

Refs #11, #12, #14, #54
The guide said TOTP was not wrapped by the React SDK or mounted by the
Express adapter, and told readers to hand-roll a backend bridge and call
/auth/totp/* with fetch. Both are out of date: the client exposes
getTotpStatus, startTotpEnrollment, verifyTotpEnrollment, disableTotp,
and verifyStepUpWithTotp, useAuth() exposes verifyStepUpWithTotp, and
the Express, Fastify, and Next.js adapters mount every TOTP route except
/totp/verify-login.

Enrollment, status, disable, and step-up now use the SDK. The step-up
snippets read { data, error } instead of status?.fresh and .success.
The backend bridge is kept as a section labelled as a fallback for
backends without an adapter, and the raw route table stays as wire
reference.

Refs #13
Adds scripts/check-sdk-results.mjs to npm run lint, next to
check-no-h1.mjs. Inside each code fence it finds values bound from a
@seamless-auth/client or @seamless-auth/react request method (await
assignment or a .then callback) and fails on any field read off them
other than data or error, which covers response.ok,
await response.json(), result.success, and result.providers. It also
catches the inline form, (await verifyStepUpWithPasskey()).success.

It only tracks SDK results, so raw fetch() and authorizedFetch()
examples, which really do return a Response, are not flagged. Against
the docs on main it reports every pattern listed in #54 plus the two in
organizations-memberships.mdx, and it passes on this branch.

Refs #54
@Bccorb
Bccorb merged commit 49ed3f9 into main Oct 7, 2026
3 checks passed
@Bccorb
Bccorb deleted the fix/sdk-result-shape-examples branch October 15, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment