@microsoft/power-apps-native-auth
v1.1.0
Published
Expo native module: MSAL authentication + Microsoft Intune MAM for iOS and Android
Readme
@microsoft/power-apps-native-auth
Expo native module providing MSAL authentication and Microsoft Intune MAM (Mobile Application Management) integration for iOS and Android React Native / Expo applications.
Installation
npm install @microsoft/power-apps-native-authAfter install, run the SDK setup to download the Microsoft Intune MAM SDK binaries (not redistributed via npm — fetched from the official Microsoft GitHub release at build time):
npm run setup --workspace @microsoft/power-apps-native-authSDK versions and compatibility
| Platform | Default Intune SDK | Requirements | | --- | --- | --- | | iOS | 21.8.0 | Xcode 26.4, iOS 17 or later | | Android | 12.4.0 | Android 5.0 / API 21 or later; this module defaults to API 26 |
The platforms have independent SDK version numbers. The Android runtime AARs, downlevel stubs, and MAM Gradle plugin are downloaded from the same release. Intune 20.x must not be used with Xcode 26, and Intune 22.x requires Xcode 27. See the iOS 21.8.0 release notes and Android 12.4.0 release notes.
Android setup pins the upstream commit and SHA-256 digest of each AAR/JAR in
scripts/android-sdk-integrity.json.
It verifies cached files on every run and stages and verifies all downloads
before replacing the installation. Integrity failures stop setup without
installing the downloaded files.
CLI and INTUNE_ANDROID_SDK_VERSION overrides require reviewed pins in that file
(currently 12.4.0 and 12.0.3); unpinned versions fail before downloading.
An override still requires its own native compatibility validation.
The Expo config plugin raises the generated iOS deployment target to at least 17.0, preserving higher customer targets. Apps that do not use the plugin must set their deployment target to iOS 17 or later themselves. This upgrade drops support for iOS 16 and earlier.
To replace previously downloaded SDK binaries on both platforms, rerun:
npm run setup --workspace @microsoft/power-apps-native-authThe setup scripts check the installed SDK versions and replace outdated
binaries. The wrap command performs these checks before building, too.
Rerun Expo prebuild and rebuild the native apps after upgrading; a
JavaScript-only update does not replace the SDK.
Peer dependencies
expo>= 57.0.21expo-modules-core>= 57.0.17react-native>= 0.86.3 and < 0.87@expo/config-plugins>= 57.0.9
iOS build requirements
The Expo 57 target uses Xcode 26.4 (macOS Tahoe 26.2 or later) and iOS 17
or later. SDK setup pins Intune iOS SDK 21.8.0,
whose published Swift interface was built with Swift 6.2.4. Intune 21.9.0
was built with Swift 6.3.3 and is not assumed compatible with the selected
Xcode 26.4 / Swift 6.3 toolchain without a separate build validation.
Intune 20.x targets Xcode 16 and must not be reused
with this build. MSAL is pinned to CocoaPods version 2.16.0, whose upstream
source tag is available. The 2.16.1 podspec references an unavailable source
tag and fails on clean installs; do not replace the pin with a floating 2.x
constraint. Authentication and MAM are not disabled by pre-release diagnostics.
Run npm run setup:ios --workspace @microsoft/power-apps-native-auth before
installing pods. Setup replaces an older cached SDK and records the new version
only after both frameworks have been installed. Overrides through the first
argument or INTUNE_IOS_SDK_VERSION must be exact 21.x versions and require
their own native compatibility validation; they are not automatic upgrades.
Selecting a supported SDK and passing setup tests do not certify a native build. Simulator/device launch, sign-in, broker return and MAM behavior still need validation with the selected Xcode toolchain.
SDK setup script responsibilities
scripts/setup-ios-frameworks.js is run by
native-build developers/CI before CocoaPods and wrapping. It downloads the
selected framework release into the auth package's ignored ios/Frameworks/
directory; it is not part of /check-updates or a running customer's app.
| Function | Purpose and safety boundary |
|---|---|
| assertSupportedVersion | Require an exact supported 21.x SDK version; reject incompatible families/ranges rather than selecting a floating release |
| frameworksPresent | Check both required framework directories, not just a version marker |
| isInstalled | Reuse a matching installation only when its sentinel and both frameworks agree |
| download | Download the selected archive with bounded redirects/timeout; propagate transport/HTTP failures |
| installFrameworks | Require both extracted framework directories, invalidate the old success marker, copy both frameworks, then record the version |
| main | Select explicit/environment/default version, use valid cached contents or download/extract/install, and remove its own temporary directory |
The runtime fingerprint includes this script's complete source because its SDK pin selects native binaries. These function notes live here to avoid changing that fingerprint merely to add comments to the script. Changing its implementation or selected SDK still requires intentional native compatibility preparation and rebuilt binaries.
Android fingerprinting likewise includes the complete
scripts/setup-android-sdk.js source and excludes
its downloaded android/libs/ contents, including the version marker. Running
SDK setup must not change compatibility metadata; changing the setup pin still
does. Authored Android sources and Gradle declarations remain fingerprinted.
Usage
import { initializeFromConfig } from '@microsoft/power-apps-native-auth';
await initializeFromConfig({
msal: {
clientId: '<your-msal-client-id>',
tenantId: '<your-tenant-id>',
},
intune: { enabled: false },
});See src/index.ts for the full exported API.
Optional Intune management
Plain PublicClientApplication and initializeFromConfig calls default to
Intune disabled. Set intuneEnabled: true on a PCA configuration, or
intune.enabled: true with initializeFromConfig, to enable native enrollment
and App Protection Conditional Access remediation. Broker authentication is a
separate option and continues to work without opting into Intune.
The host AuthProvider also defaults to Intune disabled in both release and
development builds. With PowerAppsProvider, enable management in app.json:
{
"expo": {
"extra": {
"intuneConfig": { "enabled": true }
}
}
}The provider reads the supplied appConfig, falling back to
Constants.expoConfig only when appConfig is omitted. An explicit
intuneConfig prop takes precedence, including { enabled: false }.
No layout or auth.config.json changes are needed. When using AuthProvider
directly, pass intuneConfig={{ enabled: true }}.
This setting applies to both single-tenant authentication and the multi-tenant
environment discovery and selected-environment authentication stages.
Broker authentication defaults are unchanged and independent of Intune.
Disabled clients do not register MAM token callbacks,
attempt enrollment, or initiate compliance remediation. Native startup restores
the last explicit opt-in so SDK token callbacks do not depend on JS being alive.
Disabling the flag does not remove an existing management enrollment or override
administrator policy; sign out while management is enabled to unenroll normally.
Build-time DEV_CLIENT=true or POWER_APPS_DEV_PLAYER=true omits the Android
MAM AARs and bytecode instrumentation, not MSAL. These flags use the exact string
true; false or an unset flag preserves an Intune-capable build. iOS retains
the shared framework linkage; non-Intune operation is controlled by runtime
opt-out rather than removing the framework.
MSALAccount.identifier remains the MSAL cache lookup ID. The separate aadId
field contains the Entra object ID required by Intune. For manual enrollment:
const result = await registerAndEnrollAccount({
upn: account.username,
aadId: account.aadId,
tenantId: account.tenantId,
// Enable only from an explicit user sign-in action, not cached restoration.
allowInteractiveRecovery: true,
});
// result.status: 'enrolled', 'notTargeted', or 'notLicensed'
await deRegisterAndUnenrollAccount({
upn: account.username,
aadId: account.aadId,
});The legacy UPN-only unenrollment call resolves the tenant-specific identity from
the native MSAL cache and Android SDK registrations. Ambiguous identities reject
instead of selecting a different tenant's home account; pass aadId explicitly
for those accounts. Unenroll before clearing the cache.
Enrollment and unenrollment wait for SDK completion, reject explicit SDK
failures, and have finite deadlines. Accounts that are not licensed or not
targeted by policy can still sign in. The host registers restored cached
accounts as well as newly signed-in accounts and reports actual enrollment
outcomes rather than treating registration as success.
If iOS already has a registration but no confirmed enrollment outcome (for
example after an interrupted attempt), cached restoration fails promptly with
E_INTUNE_ENROLLMENT_RECOVERY_REQUIRED. It does not wait for a duplicate
registration callback or silently prompt for credentials. An explicit user
sign-in enables allowInteractiveRecovery and uses the SDK's
loginAndEnrollAccount API to start a fresh request without deregistering or
wiping the account. The host manages this distinction automatically.
Enabled clients handle policy-required MSAL errors natively, wait for compliance
completion, and retry the token request once. Failures and cancellation are
surfaced; disabled clients retain ordinary MSAL error handling.
Reconfiguring authentication invalidates pending Android silent-token callbacks:
they cannot publish stale results, start remediation, or retry the old request.
SDK compliance failures reject with an exported IntuneComplianceError containing
the localized title and message. The host displays both as documented by the
Android
and iOS
SDK guidance; ordinary MSAL errors retain the generic authentication message.
Android waits for an outstanding native
resource-token update before treating a missing-token compliance error as final.
Delayed missing-token notifications cannot discard a resumed remediation attempt;
if remediation never completes, its deadline reports the SDK's failure details.
Changing the host's authentication or Intune configuration immediately gates the previous session until the new configuration is validated. Both explicit sign-out and required-token session invalidation unenroll before removing MSAL credentials. If unenrollment fails, native credentials remain available for recovery.
The focused tests include native Swift lifecycle/identity scenarios and error
transport through Expo's real Promise/Exception implementations on macOS.
Compile the Android auth module before running npm test to also execute the JVM
notification-ordering tests against its compiled coordinator; without a current
native build, that test is explicitly skipped.
Expo config plugin
This module ships an Expo config plugin that wires up the MSAL redirect URI
scheme. Add it to your app.config.js / app.json:
{
"plugins": ["@microsoft/power-apps-native-auth"]
}The plugin preserves customer IntuneMAMSettings options while injecting auth
keys, adds the app, Intune MAM, and MSAL keychain groups on iOS, and installs the
enabled-gated Android startup hook. Rebuild the native app after updating this
package; a JS-only deployment cannot add these native lifecycle hooks.
