Skip to content

✨ (device-management-kit) [NO-ISSUE]: Detect onboarded device from GetOsVersion#1521

Draft
pdeville-ledger wants to merge 1 commit into
developfrom
feat/no-issue-onboarded-status-from-os-version
Draft

✨ (device-management-kit) [NO-ISSUE]: Detect onboarded device from GetOsVersion#1521
pdeville-ledger wants to merge 1 commit into
developfrom
feat/no-issue-onboarded-status-from-os-version

Conversation

@pdeville-ledger
Copy link
Copy Markdown
Contributor

📝 Description

GetDeviceStatusDeviceAction was returning isDeviceOnboarded: () => true, so DeviceNotOnboardedError could never trigger and UIs (e.g. Ledger Button) had no way to detect an unseeded device.

This PR replaces the stub by reading secureElementFlags.isOnboarded from GetOsVersionCommand (no secure channel required), following the existing pattern in ListInstalledAppsDeviceAction.

  • GetDeviceStatusDeviceAction:
    • OnboardingCheck reads cached firmwareVersion.metadata first; otherwise runs GetOsVersionCommand and branches on isOnboarded.
    • On success in a ready state, the session is updated with firmwareVersion (incl. metadata) and isSecureConnectionAllowed, so consumers reading getDeviceSessionState() get onboarding info without an extra command.
    • Removes the isDeviceOnboarded machine dependency / sync guard.
  • OpenAppDeviceAction:
    • Removes its duplicate stubbed OnboardingCheck; relies on the fixed GetDeviceStatus child machine.
  • Tests: mock GetOsVersionCommand instead of injecting isDeviceOnboarded; cover both the cached-metadata fast path and the live fetch path.

❓ Context

  • JIRA or GitHub link: NO-ISSUE
  • Feature: Real onboarded/seeded detection in DMK device actions

✅ Checklist

  • Covered by automatic tests
  • Changeset is provided
  • Documentation is up-to-date
  • Impact of the changes:
    • GetDeviceStatusDeviceAction may now return Left(DeviceNotOnboardedError) for unseeded devices.
    • OpenAppDeviceAction no longer emits its own pre-GetDeviceStatus onboarding step; consumers asserting on the state sequence may need updates.
    • MachineDependencies of both actions changed (isDeviceOnboarded removed; getOsVersion added on GetDeviceStatus).
    • Session state may now contain firmwareVersion.metadata and isSecureConnectionAllowed after GetDeviceStatus succeeds in a ready state.

Made with Cursor

…tOsVersion

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
device-sdk-ts-sample Ready Ready Preview, Comment May 27, 2026 2:48pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
doc-device-management-kit Ignored Ignored May 27, 2026 2:48pm

Request Review

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

Danger Check Results

Messages

Danger: All checks passed successfully! 🎉

Generated by 🚫 dangerJS against a8136e3

Comment on lines +135 to +137
if (state.sessionStateType === DeviceSessionStateType.Connected) {
return undefined;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that two other DeviceSessionType have the metadata, i don't know if we actually use them, but in case we're in those states, you'll miss the data.
Maybe replace by if "firmwareVersion" in state.

Comment on lines +122 to +124
if (currentState.sessionStateType === DeviceSessionStateType.Connected) {
return;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be unnecessary and not optimal (for instance when in state Connected, you're not updating firmwareVersion even though it could be undefined.
IMO you can always override as your data here is the most up to date.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants