Skip to content

Adopt @seamless-auth/types for the API response shapes #115

Description

@Bccorb

The SDK's request and response types are written by hand and maintained in parallel with the api's Zod schemas. fells-code/seamless-auth-types#4 publishes them, so they can be imported instead.

src/types.ts:

  • User, Organization, and OrganizationMembership map to MeUser, Organization, and OrganizationMembership in the package.
  • Credential maps to CredentialResponse. The local one types lastUsedAt as Date | null, but the api returns an ISO string, so anything calling a Date method on it is relying on a type that does not match the wire value.

src/client/createSeamlessAuthClient.ts redeclares roughly twenty shapes that now exist upstream: LoginMethod, LoginStartResult, RegisterInput, CurrentUserResult, the four organization input types plus the five organization result types, OAuthProvider and its results, StartOAuthLoginResult, CredentialUpdateResult, StepUpMethod, StepUpStatus, TotpStatus, TotpEnrollmentStartResult, LogoutScope, and MessageResult.

src/client/errors.ts keeps OAuthErrorCode and OAUTH_ERROR_CODES as a hand-maintained pair. The package exports both, so getOAuthErrorCode can validate against OAuthErrorCodeSchema and the local Set goes away.

Two things worth keeping local, since they are SDK concerns rather than wire contracts: the PRF helpers in src/client/webauthnPrf.ts, and SeamlessAuthResult in src/client/result.ts.

One thing to decide as part of this: whether the package becomes a runtime dependency or a types-only one. Zod is the package's single dependency, and importing schemas rather than just types would let the SDK validate responses instead of casting them, at the cost of adding Zod to the browser bundle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions