docs: add missing struct definitions to store-interfaces and document TOTPEncoding#182
Merged
veverkap merged 3 commits intoMay 3, 2026
Merged
Conversation
…ding to totp docs/auth/store-interfaces.md: each store interface section documented only the interface itself. Implementors and consumers also need the field layout of the structs that store methods accept or return. Add ### <Type> struct subsections for APIKey, Session, PasskeyCredential, PasskeyChallenge, MagicLink, EmailVerificationToken, TOTPSecret, and PasswordResetToken, mirroring the existing User struct block under UserStore. docs/auth/totp.md: TOTPEncoding() is an exported helper that returns the canonical base32 encoding used by every TOTP function in the library. Without this section, callers who need to encode or decode raw secret bytes outside of the built-in functions have no documented way to stay consistent. Add a 'Base32 encoding' section showing the encode/decode usage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the more detailed 'Secret encoding' section from main (PR #180) which includes unpadded base32 clarification and a validation example.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fills documentation gaps in the auth docs by adding missing struct layouts to the store interface reference and documenting the canonical base32 encoding used for TOTP secrets.
Changes:
- Added a “Base32 encoding” section to
docs/auth/totp.mddescribingauth.TOTPEncoding()usage. - Added struct definitions for store-returned types (e.g.,
APIKey,Session,PasskeyCredential,MagicLink, etc.) indocs/auth/store-interfaces.md.
Show a summary per file
| File | Description |
|---|---|
| docs/auth/totp.md | Documents the exact base32 encoding used by TOTP helpers via auth.TOTPEncoding(). |
| docs/auth/store-interfaces.md | Adds struct layouts for store-returned types to make field names/types discoverable for implementors. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
- PasskeyCredential.CredentialData: clarify as JSON-marshaled webauthn.Credential - PasskeyChallenge.SessionData: document exact handler-written JSON format - TOTPSecret.Secret: sync comment verbatim with auth/types.go source - totp.md: add EncodeToString example alongside DecodeString in Secret encoding section
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two documentation gaps identified and fixed:
1.
docs/auth/store-interfaces.md— missing struct definitionsThe store-interfaces reference documented every interface but only showed the
Userstruct layout. Implementors and consumers of the other stores had no canonical place to look up field names and types for the structs returned by those interfaces.Added
### <Type> structsubsections (matching the existing### User structpattern) for:APIKeyAPIKeyStoreSessionSessionStorePasskeyCredentialPasskeyStorePasskeyChallengePasskeyStoreMagicLinkMagicLinkStoreEmailVerificationTokenEmailVerificationStoreTOTPSecretTOTPStorePasswordResetTokenPasswordResetStoreAll struct definitions are taken verbatim from
auth/types.go, with brief inline comments where the source code already had them (e.g.PasswordHash,OIDCSubject,TOTPSecret.Secret).2.
docs/auth/totp.md—TOTPEncoding()undocumentedauth.TOTPEncoding()is an exported function that returns the specific base32 encoding (standard RFC 4648, no padding) used by every TOTP function in the library. Without documentation, callers who need to encode or decode raw secret bytes outside the built-in helpers have no way to know which encoding to use, risking subtle incompatibilities.Added a Base32 encoding section showing
EncodeToStringandDecodeStringusage.Files changed
docs/auth/store-interfaces.mddocs/auth/totp.mdGreptile Summary
This PR fills two documentation gaps: it backfills
### <Type> structsubsections for all 8 store-interface types previously missing fromdocs/auth/store-interfaces.md, and adds aEncodeToStringusage example to the TOTP secret-encoding section indocs/auth/totp.md. All struct field layouts matchauth/types.go; the only notable issue is that thePasskeyChallenge.SessionDatainline comment references the unexported internal typepasskeyChallengeDatafromhandler/passkey.go, which is an implementation detail that store implementors don't need and that could drift if the handler changes.Confidence Score: 5/5
Documentation-only PR with accurate struct definitions; safe to merge.
All changes are documentation. Struct definitions match the source. The single finding is a P2 style issue (referencing an unexported type in a field comment), which does not affect correctness or safety.
docs/auth/store-interfaces.md — PasskeyChallenge.SessionData comment references internal unexported type
Important Files Changed
Entity Relationship Diagram
%%{init: {'theme': 'neutral'}}%% erDiagram User { string ID string Name string Email string PasswordHash string OIDCSubject bool IsAdmin bool EmailVerified time CreatedAt } APIKey { string ID string UserID string Name string KeyHash string KeyPrefix time LastUsedAt time CreatedAt } Session { string ID string UserID string RefreshTokenHash string UserAgent string IPAddress time ExpiresAt time CreatedAt } PasskeyCredential { string ID string UserID string Name string CredentialID string CredentialData string AAGUID time CreatedAt } PasskeyChallenge { string ID string UserID string SessionData time ExpiresAt time CreatedAt } TOTPSecret { string ID string UserID string Secret time CreatedAt } PasswordResetToken { string ID string UserID string TokenHash time ExpiresAt time CreatedAt } User ||--o{ APIKey : "has" User ||--o{ Session : "has" User ||--o{ PasskeyCredential : "has" User ||--o| PasskeyChallenge : "initiates" User ||--o| TOTPSecret : "has" User ||--o{ PasswordResetToken : "has"Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "docs: address review comments on store-i..." | Re-trigger Greptile