Skip to content

Let users verify their email address and mobile number from their account - #39

Open
PasinduYeshan wants to merge 2 commits into
thunder-id:mainfrom
PasinduYeshan:self-attribute-verification
Open

PasinduYeshan wants to merge 2 commits into
thunder-id:mainfrom
PasinduYeshan:self-attribute-verification

Conversation

@PasinduYeshan

@PasinduYeshan PasinduYeshan commented Oct 29, 2026 •

Copy link
Copy Markdown

Purpose

Lets a signed-in user verify their own email address or mobile number from their account, using the server's SELF_SERVICE attribute verification flow (thunder-id/thunderid#6050).

  • Client: verifyAttribute starts the flow by handle (default default-self-attribute-verification-flow) with the user's token, and a payload variant continues it. A refused step surfaces as a verification error.
  • UserProfile exposes verifiedAttributes from /users/me.
  • SwiftUI VerifyAttribute and BaseVerifyAttribute render each step from the flow response, with a custom render through content. UserProfile shows each contact's verification status and offers Verify for an unverified one, including right after the user changes it.
  • Verification strings in every shipped locale, a capability check and playground stories with a Custom rendering variant.

Approach

Follows the specification in thunder-id/thunderid#5905 and matches the JavaScript port (thunder-id/javascript-sdks#145). Verification posts to /flow/execute through the shared HTTP client, like the other flows. A flow is started once per showing, since a start sends a message; overlapping submits are ignored; failures show a translated generic message.

Related Issues

Related PRs

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified. (Playground on the simulator against a local server running #6050)
  • Documentation provided. (Add links if there are any)
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.
  • Cross-SDK parity. Exactly one of parity/prs-raised or parity/prs-not-needed added.
    • If parity/prs-raised, the port links are posted as a reply on the parity check's comment.

SDK parity

Security checks

  • Followed secure coding standards.
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added email and mobile attribute verification for signed-in users, including code entry, resend, link confirmation, and completion states.
    • Profile screens now show verification status and offer verification when available. Email verification can begin after a successful profile update.
    • Added customizable verification views and Playground examples for standard and custom presentations.
  • Documentation
    • Updated Playground guidance to include attribute verification among available checks and clarify that interactive checks run when tapped.

…ount

Signed-off-by: Pasindu Yeshan <pasinduyeshan98@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Walkthrough

The SDK adds self-service attribute verification for email and mobile attributes. SwiftUI components provide verification flows and profile status. The Playground adds checks and examples for the feature.

Changes: Attribute verification SDK and flow

Layer / File(s) Summary
Verification contracts and SDK transport
Sources/ThunderID/AttributeVerification.swift, Sources/ThunderID/Models.swift, Sources/ThunderID/ThunderIDClient+Verification.swift, Sources/ThunderID/auth/FlowExecutionClient.swift, Sources/ThunderID/http/HTTPClient.swift, Sources/ThunderID/ThunderIDError.swift, Sources/ThunderID/ThunderIDClient.swift, Tests/ThunderIDTests/VerifyAttributeTests.swift
The SDK adds verification metadata and eligibility rules, self-service start and continuation requests, and response error mapping. Tests cover request payloads, authentication, errors, and decoding.
Verification flow state and rendering
Sources/ThunderIDSwiftUI/components/account/BaseVerifyAttribute.swift, Sources/ThunderIDSwiftUI/components/account/VerifyAttribute.swift, Sources/ThunderIDSwiftUI/i18n/DefaultStrings.swift, Tests/ThunderIDSwiftUITests/components/account/VerifyAttributeStateTests.swift
The SwiftUI components load the attribute schema, manage flow steps and callbacks, and render verification forms. Tests cover startup, submissions, resend, completion, and errors.
Profile verification and save integration
Sources/ThunderIDSwiftUI/components/account/BaseUserProfile.swift, Sources/ThunderIDSwiftUI/components/account/UserProfile.swift, Tests/ThunderIDSwiftUITests/components/account/UserProfileVerificationTests.swift, Tests/ThunderIDSwiftUITests/components/account/VerificationFollowsStoredValueTests.swift
Profile views show available verification status and offer a Verify action when eligible. A changed email can open verification after a successful save when the returned profile reports it as unverified.
Playground checks and examples
Playground/README.md, Playground/Sources/Capability.swift, Playground/Sources/CapabilityChecks.swift, Playground/Sources/CustomRenderCatalog.swift, Playground/Sources/CustomRenderPreview.swift, Playground/Sources/ExplorerCatalog.swift, Playground/Sources/ExplorerPreview.swift
The Playground adds an attribute-verification check, Explorer and custom-render stories, and documentation of the interactive check.

Priority: Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant UserProfile
  participant VerifyAttribute
  participant ThunderIDClient
  participant ProfileAPI
  User->>UserProfile: Select Verify for an eligible field
  UserProfile->>VerifyAttribute: Present verification for the field
  VerifyAttribute->>ThunderIDClient: Start or continue verification
  ThunderIDClient-->>VerifyAttribute: Return flow step
  VerifyAttribute->>ThunderIDClient: Submit action or resend
  ThunderIDClient-->>VerifyAttribute: Return updated flow step
  VerifyAttribute->>ProfileAPI: Read profile after completion
  ProfileAPI-->>VerifyAttribute: Return updated profile
  VerifyAttribute-->>UserProfile: Apply refreshed profile and close sheet
Loading

Suggested labels: enhancement

Suggested reviewers: brionmario, janithjay

Merge Risk: Minimal · up to 8db1d

The account verification change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 39.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title states the main change: signed-in users can verify their email address and mobile number from their account. The changeset adds the self-service attribute verification flow (client `verifyAt…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is complete and relevant. It includes the purpose, implementation approach, related issues and pull requests, testing details, security checks, SDK parity references, and checklist sta…
Full details: Title check

Explanation

The title states the main change: signed-in users can verify their email address and mobile number from their account. The changeset adds the self-service attribute verification flow (client verifyAttribute, VerifyAttribute and BaseVerifyAttribute SwiftUI components, UserProfile verification status, and verifiedAttributes on UserProfile), which matches this title.

Full details: Description check

Explanation

The description is complete and relevant. It includes the purpose, implementation approach, related issues and pull requests, testing details, security checks, SDK parity references, and checklist status. Documentation and the required parity label remain unchecked, but these are non-critical omissions because the PR includes documentation changes and lists parity pull requests.

Full details: Docstring Coverage

Explanation

Docstring coverage is 39.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 51 functions across 22 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🔀 Cross-SDK feature parity, ports raised

This pull request is labelled parity/prs-raised, so the capability it introduces is expected in the other ThunderID SDKs as well.

Ports (DO NOT EDIT)

  • thunder-id/javascript-sdks, JavaScript (React, Vue, Nuxt, Next.js, Express, React Router, TanStack Router, Browser, Node) => #145
  • thunder-id/android-sdks, Android => #47
  • thunder-id/flutter-sdks, Flutter => #60

3 of 3 sibling SDKs accounted for.

Every sibling SDK is accounted for.

The contract is in the SDK development specification.

Signed-off-by: Pasindu Yeshan <pasinduyeshan98@gmail.com>
@PasinduYeshan PasinduYeshan added the parity/prs-raised Ports exist in the other SDKs, or are recorded as not applying there label Oct 30, 2026
@PasinduYeshan

Copy link
Copy Markdown
Author

@coderabbitai review.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

@PasinduYeshan I’ll review the changes in this PR.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@PasinduYeshan

PasinduYeshan commented Oct 30, 2026 •

Copy link
Copy Markdown
Author

iOS verification workaround: The existing iOS SDK sign-in paths have two issues:

For verification only, I temporarily added a Proof sign-in button to the Playground to complete the authorization code + PKCE flow and store valid tokens. The verification feature was then tested against the unchanged SDK.

The workaround was removed and is not included in this PR.

iOS Verification Screenshots

Unverified profile Invalid verification code
Profile unverified Invalid code refused
Mobile verified Both attributes verified
Mobile verified Both attributes verified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parity/prs-raised Ports exist in the other SDKs, or are recorded as not applying there

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant