@microsoft/power-apps-native-auth 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/ExpoMsalIntuneModule.swift +6 -3
- package/lib/NOTICE.txt +1 -1
- package/lib/commonjs/index.js +45 -5
- package/lib/module/index.js +45 -5
- package/lib/typescript/commonjs/index.d.ts +3 -0
- package/lib/typescript/module/index.d.ts +3 -0
- package/package.json +2 -1
- package/plugin/index.js +40 -9
- package/plugin/withIntuneMAMSettings.js +58 -0
- package/plugin/withMsalBrokerURLSchemes.js +75 -0
|
@@ -216,10 +216,13 @@ public class ExpoMsalIntuneModule: Module {
|
|
|
216
216
|
guard let pca = self.pca else { throw MsalIntuneError.notInitialized }
|
|
217
217
|
let account = try self.findAccount(pca: pca, identifier: accountIdentifier)
|
|
218
218
|
|
|
219
|
+
if !signoutFromBrowser {
|
|
220
|
+
try pca.remove(account)
|
|
221
|
+
return
|
|
222
|
+
}
|
|
223
|
+
|
|
219
224
|
return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
|
|
220
|
-
//
|
|
221
|
-
// is true MSAL needs a view controller to present the browser; we obtain
|
|
222
|
-
// one from topViewController() which is also a UIKit operation.
|
|
225
|
+
// Browser sign-out must run on the main thread and needs a view controller.
|
|
223
226
|
DispatchQueue.main.async {
|
|
224
227
|
guard let viewController = self.topViewController() else {
|
|
225
228
|
continuation.resume(throwing: MsalIntuneError.intuneError("No top view controller for signout"))
|
package/lib/NOTICE.txt
CHANGED
package/lib/commonjs/index.js
CHANGED
|
@@ -29,6 +29,14 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
29
29
|
*
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
+
function isAccountNotFoundError(error) {
|
|
33
|
+
if (!(error instanceof Error)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const code = error.code;
|
|
37
|
+
return code === 'E_ACCOUNT_NOT_FOUND' || /not found in (?:the )?MSAL cache/i.test(error.message);
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
// ---------------------------------------------------------------------------
|
|
33
41
|
// PublicClientApplication
|
|
34
42
|
// ---------------------------------------------------------------------------
|
|
@@ -42,6 +50,8 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
42
50
|
*/
|
|
43
51
|
class PublicClientApplication {
|
|
44
52
|
_initialized = false;
|
|
53
|
+
_unvalidatedCachedAccountIds = new Set();
|
|
54
|
+
_forceAccountSelection = false;
|
|
45
55
|
constructor(config) {
|
|
46
56
|
this._config = config;
|
|
47
57
|
}
|
|
@@ -68,8 +78,11 @@ class PublicClientApplication {
|
|
|
68
78
|
if (!this._initialized) {
|
|
69
79
|
throw new Error('ExpoMsalIntune: call init() before acquiring tokens');
|
|
70
80
|
}
|
|
71
|
-
const native = await _ExpoMsalIntuneModule.default.acquireTokenInteractive(params.scopes, params.loginHint ?? null, params.prompt ?? null);
|
|
72
|
-
|
|
81
|
+
const native = await _ExpoMsalIntuneModule.default.acquireTokenInteractive(params.scopes, params.loginHint ?? null, params.prompt ?? (this._forceAccountSelection ? 'select_account' : null));
|
|
82
|
+
const result = (0, _ExpoMsalIntuneModule.mapNativeResult)(native);
|
|
83
|
+
this._forceAccountSelection = false;
|
|
84
|
+
this._unvalidatedCachedAccountIds.clear();
|
|
85
|
+
return result;
|
|
73
86
|
}
|
|
74
87
|
|
|
75
88
|
/**
|
|
@@ -82,14 +95,29 @@ class PublicClientApplication {
|
|
|
82
95
|
if (!this._initialized) {
|
|
83
96
|
throw new Error('ExpoMsalIntune: call init() before acquiring tokens');
|
|
84
97
|
}
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
try {
|
|
99
|
+
const native = await _ExpoMsalIntuneModule.default.acquireTokenSilent(params.scopes, params.account.identifier, params.forceRefresh ?? false);
|
|
100
|
+
this._unvalidatedCachedAccountIds.delete(params.account.identifier);
|
|
101
|
+
return (0, _ExpoMsalIntuneModule.mapNativeResult)(native);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (this._unvalidatedCachedAccountIds.has(params.account.identifier) && isAccountNotFoundError(error)) {
|
|
104
|
+
this._forceAccountSelection = true;
|
|
105
|
+
try {
|
|
106
|
+
await this.clearCachedAccounts();
|
|
107
|
+
} catch {
|
|
108
|
+
this._unvalidatedCachedAccountIds.clear();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
87
113
|
}
|
|
88
114
|
|
|
89
115
|
/** Return all accounts from the MSAL token cache. */
|
|
90
116
|
async getAccounts() {
|
|
91
117
|
const nativeAccounts = await _ExpoMsalIntuneModule.default.getAccounts();
|
|
92
|
-
|
|
118
|
+
const accounts = nativeAccounts.map(_ExpoMsalIntuneModule.mapNativeAccount);
|
|
119
|
+
this._unvalidatedCachedAccountIds = new Set(accounts.map(account => account.identifier));
|
|
120
|
+
return accounts;
|
|
93
121
|
}
|
|
94
122
|
|
|
95
123
|
/**
|
|
@@ -98,8 +126,20 @@ class PublicClientApplication {
|
|
|
98
126
|
*/
|
|
99
127
|
async signOut(params) {
|
|
100
128
|
await _ExpoMsalIntuneModule.default.signOut(params.account.identifier, params.signoutFromBrowser ?? false);
|
|
129
|
+
this._unvalidatedCachedAccountIds.delete(params.account.identifier);
|
|
101
130
|
return true;
|
|
102
131
|
}
|
|
132
|
+
async clearCachedAccounts() {
|
|
133
|
+
const nativeAccounts = await _ExpoMsalIntuneModule.default.getAccounts();
|
|
134
|
+
await Promise.all(nativeAccounts.map(async account => {
|
|
135
|
+
try {
|
|
136
|
+
await _ExpoMsalIntuneModule.default.signOut(account.identifier, false);
|
|
137
|
+
} catch {
|
|
138
|
+
// Continue clearing the remaining cached accounts.
|
|
139
|
+
}
|
|
140
|
+
}));
|
|
141
|
+
this._unvalidatedCachedAccountIds.clear();
|
|
142
|
+
}
|
|
103
143
|
}
|
|
104
144
|
|
|
105
145
|
// ---------------------------------------------------------------------------
|
package/lib/module/index.js
CHANGED
|
@@ -17,6 +17,14 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import ExpoMsalIntuneModule, { mapNativeAccount, mapNativeResult } from "./ExpoMsalIntuneModule.js";
|
|
20
|
+
function isAccountNotFoundError(error) {
|
|
21
|
+
if (!(error instanceof Error)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const code = error.code;
|
|
25
|
+
return code === 'E_ACCOUNT_NOT_FOUND' || /not found in (?:the )?MSAL cache/i.test(error.message);
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
// ---------------------------------------------------------------------------
|
|
21
29
|
// PublicClientApplication
|
|
22
30
|
// ---------------------------------------------------------------------------
|
|
@@ -30,6 +38,8 @@ import ExpoMsalIntuneModule, { mapNativeAccount, mapNativeResult } from "./ExpoM
|
|
|
30
38
|
*/
|
|
31
39
|
export class PublicClientApplication {
|
|
32
40
|
_initialized = false;
|
|
41
|
+
_unvalidatedCachedAccountIds = new Set();
|
|
42
|
+
_forceAccountSelection = false;
|
|
33
43
|
constructor(config) {
|
|
34
44
|
this._config = config;
|
|
35
45
|
}
|
|
@@ -56,8 +66,11 @@ export class PublicClientApplication {
|
|
|
56
66
|
if (!this._initialized) {
|
|
57
67
|
throw new Error('ExpoMsalIntune: call init() before acquiring tokens');
|
|
58
68
|
}
|
|
59
|
-
const native = await ExpoMsalIntuneModule.acquireTokenInteractive(params.scopes, params.loginHint ?? null, params.prompt ?? null);
|
|
60
|
-
|
|
69
|
+
const native = await ExpoMsalIntuneModule.acquireTokenInteractive(params.scopes, params.loginHint ?? null, params.prompt ?? (this._forceAccountSelection ? 'select_account' : null));
|
|
70
|
+
const result = mapNativeResult(native);
|
|
71
|
+
this._forceAccountSelection = false;
|
|
72
|
+
this._unvalidatedCachedAccountIds.clear();
|
|
73
|
+
return result;
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
/**
|
|
@@ -70,14 +83,29 @@ export class PublicClientApplication {
|
|
|
70
83
|
if (!this._initialized) {
|
|
71
84
|
throw new Error('ExpoMsalIntune: call init() before acquiring tokens');
|
|
72
85
|
}
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
try {
|
|
87
|
+
const native = await ExpoMsalIntuneModule.acquireTokenSilent(params.scopes, params.account.identifier, params.forceRefresh ?? false);
|
|
88
|
+
this._unvalidatedCachedAccountIds.delete(params.account.identifier);
|
|
89
|
+
return mapNativeResult(native);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (this._unvalidatedCachedAccountIds.has(params.account.identifier) && isAccountNotFoundError(error)) {
|
|
92
|
+
this._forceAccountSelection = true;
|
|
93
|
+
try {
|
|
94
|
+
await this.clearCachedAccounts();
|
|
95
|
+
} catch {
|
|
96
|
+
this._unvalidatedCachedAccountIds.clear();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
75
101
|
}
|
|
76
102
|
|
|
77
103
|
/** Return all accounts from the MSAL token cache. */
|
|
78
104
|
async getAccounts() {
|
|
79
105
|
const nativeAccounts = await ExpoMsalIntuneModule.getAccounts();
|
|
80
|
-
|
|
106
|
+
const accounts = nativeAccounts.map(mapNativeAccount);
|
|
107
|
+
this._unvalidatedCachedAccountIds = new Set(accounts.map(account => account.identifier));
|
|
108
|
+
return accounts;
|
|
81
109
|
}
|
|
82
110
|
|
|
83
111
|
/**
|
|
@@ -86,8 +114,20 @@ export class PublicClientApplication {
|
|
|
86
114
|
*/
|
|
87
115
|
async signOut(params) {
|
|
88
116
|
await ExpoMsalIntuneModule.signOut(params.account.identifier, params.signoutFromBrowser ?? false);
|
|
117
|
+
this._unvalidatedCachedAccountIds.delete(params.account.identifier);
|
|
89
118
|
return true;
|
|
90
119
|
}
|
|
120
|
+
async clearCachedAccounts() {
|
|
121
|
+
const nativeAccounts = await ExpoMsalIntuneModule.getAccounts();
|
|
122
|
+
await Promise.all(nativeAccounts.map(async account => {
|
|
123
|
+
try {
|
|
124
|
+
await ExpoMsalIntuneModule.signOut(account.identifier, false);
|
|
125
|
+
} catch {
|
|
126
|
+
// Continue clearing the remaining cached accounts.
|
|
127
|
+
}
|
|
128
|
+
}));
|
|
129
|
+
this._unvalidatedCachedAccountIds.clear();
|
|
130
|
+
}
|
|
91
131
|
}
|
|
92
132
|
|
|
93
133
|
// ---------------------------------------------------------------------------
|
|
@@ -27,6 +27,8 @@ export type { AuthConfig, MsalAuthConfig, IntuneConfig } from './AuthConfig.type
|
|
|
27
27
|
export declare class PublicClientApplication {
|
|
28
28
|
private readonly _config;
|
|
29
29
|
private _initialized;
|
|
30
|
+
private _unvalidatedCachedAccountIds;
|
|
31
|
+
private _forceAccountSelection;
|
|
30
32
|
constructor(config: MSALPublicClientApplicationConfig);
|
|
31
33
|
/** True after `init()` has completed successfully. */
|
|
32
34
|
get isInitialized(): boolean;
|
|
@@ -53,6 +55,7 @@ export declare class PublicClientApplication {
|
|
|
53
55
|
* SSO session.
|
|
54
56
|
*/
|
|
55
57
|
signOut(params: MSALSignoutParams): Promise<boolean>;
|
|
58
|
+
private clearCachedAccounts;
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
58
61
|
* Register a signed-in account with Intune MAM and initiate device/app
|
|
@@ -27,6 +27,8 @@ export type { AuthConfig, MsalAuthConfig, IntuneConfig } from './AuthConfig.type
|
|
|
27
27
|
export declare class PublicClientApplication {
|
|
28
28
|
private readonly _config;
|
|
29
29
|
private _initialized;
|
|
30
|
+
private _unvalidatedCachedAccountIds;
|
|
31
|
+
private _forceAccountSelection;
|
|
30
32
|
constructor(config: MSALPublicClientApplicationConfig);
|
|
31
33
|
/** True after `init()` has completed successfully. */
|
|
32
34
|
get isInitialized(): boolean;
|
|
@@ -53,6 +55,7 @@ export declare class PublicClientApplication {
|
|
|
53
55
|
* SSO session.
|
|
54
56
|
*/
|
|
55
57
|
signOut(params: MSALSignoutParams): Promise<boolean>;
|
|
58
|
+
private clearCachedAccounts;
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
58
61
|
* Register a signed-in account with Intune MAM and initiate device/app
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/power-apps-native-auth",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Expo native module: MSAL authentication + Microsoft Intune MAM for iOS and Android",
|
|
5
5
|
"author": "Microsoft Corporation",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"android/src/",
|
|
31
31
|
"android/build.gradle",
|
|
32
32
|
"ios/",
|
|
33
|
+
"!ios/Frameworks/",
|
|
33
34
|
"plugin/",
|
|
34
35
|
"scripts/",
|
|
35
36
|
"app.plugin.js",
|
package/plugin/index.js
CHANGED
|
@@ -40,7 +40,9 @@ const { withProjectBuildGradle, withAppBuildGradle, withDangerousMod, withString
|
|
|
40
40
|
const fs = require('fs');
|
|
41
41
|
const path = require('path');
|
|
42
42
|
|
|
43
|
-
const withMsalRedirectScheme
|
|
43
|
+
const withMsalRedirectScheme = require('./withMsalRedirectScheme.js');
|
|
44
|
+
const withIntuneMAMSettings = require('./withIntuneMAMSettings.js');
|
|
45
|
+
const withMsalBrokerURLSchemes = require('./withMsalBrokerURLSchemes.js');
|
|
44
46
|
|
|
45
47
|
const IS_DEVELOPMENT_PLAYER = process.env.POWER_APPS_DEV_PLAYER === 'true' || process.env.DEV_CLIENT === 'true';
|
|
46
48
|
|
|
@@ -292,6 +294,17 @@ function withMsalBrowserTabActivity(config) {
|
|
|
292
294
|
return mod;
|
|
293
295
|
}
|
|
294
296
|
|
|
297
|
+
// For standalone builds (real ANDROID_PACKAGE set), use the real bundle ID
|
|
298
|
+
// and pathPrefix so any signing certificate's hash is matched by the OS;
|
|
299
|
+
// MSAL validates the hash programmatically at the SDK level.
|
|
300
|
+
// For wrap-pipeline builds (no env var), use placeholder values that the
|
|
301
|
+
// wrap script replaces at post-build patch time.
|
|
302
|
+
const realBundleId = process.env.ANDROID_PACKAGE;
|
|
303
|
+
const isStandalone = realBundleId && realBundleId !== MSAL_PLACEHOLDER_BUNDLE_ID;
|
|
304
|
+
const intentData = isStandalone
|
|
305
|
+
? [{ $: { 'android:scheme': 'msauth', 'android:host': realBundleId, 'android:pathPrefix': '/' } }]
|
|
306
|
+
: [{ $: { 'android:scheme': 'msauth', 'android:host': MSAL_PLACEHOLDER_BUNDLE_ID, 'android:path': `/${MSAL_PLACEHOLDER_SIG_HASH}` } }];
|
|
307
|
+
|
|
295
308
|
activities.push({
|
|
296
309
|
$: {
|
|
297
310
|
'android:name': BROWSER_TAB_ACTIVITY_NAME,
|
|
@@ -303,13 +316,7 @@ function withMsalBrowserTabActivity(config) {
|
|
|
303
316
|
{ $: { 'android:name': 'android.intent.category.DEFAULT' } },
|
|
304
317
|
{ $: { 'android:name': 'android.intent.category.BROWSABLE' } },
|
|
305
318
|
],
|
|
306
|
-
data:
|
|
307
|
-
$: {
|
|
308
|
-
'android:scheme': 'msauth',
|
|
309
|
-
'android:host': MSAL_PLACEHOLDER_BUNDLE_ID,
|
|
310
|
-
'android:path': `/${MSAL_PLACEHOLDER_SIG_HASH}`,
|
|
311
|
-
},
|
|
312
|
-
}],
|
|
319
|
+
data: intentData,
|
|
313
320
|
}],
|
|
314
321
|
});
|
|
315
322
|
|
|
@@ -348,7 +355,25 @@ function withWrapStringPlaceholders(config) {
|
|
|
348
355
|
return withStringsXml(config, (mod) => {
|
|
349
356
|
const strings = mod.modResults.resources.string ?? [];
|
|
350
357
|
|
|
351
|
-
|
|
358
|
+
// Use real ADAL values when env vars are set (standalone build-from-source
|
|
359
|
+
// flow via `npm run build:android`). Fall back to placeholder tags for the
|
|
360
|
+
// traditional AAB+protoc wrap pipeline which patches them post-build.
|
|
361
|
+
// adal_redirect_uri stays as a placeholder — the value depends on the signing
|
|
362
|
+
// certificate, which is unknown at prebuild time; MSAL computes it at runtime.
|
|
363
|
+
const resolvedStrings = WRAP_PLACEHOLDER_STRINGS.map(({ name, value }) => {
|
|
364
|
+
if (name === 'app_name' && process.env.APP_DISPLAY_NAME) {
|
|
365
|
+
return { name, value: process.env.APP_DISPLAY_NAME };
|
|
366
|
+
}
|
|
367
|
+
if (name === 'adal_client_id' && process.env.ADAL_CLIENT_ID) {
|
|
368
|
+
return { name, value: process.env.ADAL_CLIENT_ID };
|
|
369
|
+
}
|
|
370
|
+
if (name === 'adal_tenant_id' && process.env.ADAL_TENANT_ID) {
|
|
371
|
+
return { name, value: process.env.ADAL_TENANT_ID };
|
|
372
|
+
}
|
|
373
|
+
return { name, value };
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
for (const { name, value } of resolvedStrings) {
|
|
352
377
|
const existing = strings.find((s) => s.$?.name === name);
|
|
353
378
|
if (existing) {
|
|
354
379
|
existing._ = value;
|
|
@@ -501,6 +526,12 @@ function withExpoMsalIntune(config) {
|
|
|
501
526
|
config = withMsalIOSURLScheme(config);
|
|
502
527
|
config = withMsalIOSEntitlement(config);
|
|
503
528
|
|
|
529
|
+
// iOS: inject real IntuneMAMSettings and the full broker URL scheme list when
|
|
530
|
+
// ADAL env vars are set (standalone build-from-source via `npm run build:ios`).
|
|
531
|
+
// These are no-ops when the env vars are absent (dev builds, wrap pipeline).
|
|
532
|
+
config = withIntuneMAMSettings(config);
|
|
533
|
+
config = withMsalBrokerURLSchemes(config);
|
|
534
|
+
|
|
504
535
|
// In development-player builds, skip the MAM Gradle plugin (no bytecode instrumentation
|
|
505
536
|
// needed) and the proguard rules (R8 is disabled in debug anyway).
|
|
506
537
|
// Also remove any MAM artifacts left by a prior release prebuild so the
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Expo config plugin: inject IntuneMAMSettings into iOS Info.plist.
|
|
6
|
+
*
|
|
7
|
+
* In standalone build-from-source workflows the build script (build android /
|
|
8
|
+
* build ios) sets ADAL_CLIENT_ID, ADAL_TENANT_ID, and IOS_ADAL_REDIRECT_URI
|
|
9
|
+
* before running expo prebuild. This plugin reads those env vars and writes
|
|
10
|
+
* the real values directly into IntuneMAMSettings so no post-build binary
|
|
11
|
+
* patching is needed.
|
|
12
|
+
*
|
|
13
|
+
* When the env vars are absent (dev builds, wrap-pipeline builds) this plugin
|
|
14
|
+
* is a no-op and the placeholder tag values from the app config's ios.infoPlist
|
|
15
|
+
* section are left intact for the downstream wrap pipeline to replace.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { withInfoPlist } = require('@expo/config-plugins');
|
|
19
|
+
|
|
20
|
+
/** @param {import('@expo/config-plugins').ExpoConfig} config */
|
|
21
|
+
function withIntuneMAMSettings(config) {
|
|
22
|
+
return withInfoPlist(config, (mod) => {
|
|
23
|
+
const clientId = process.env.ADAL_CLIENT_ID;
|
|
24
|
+
const tenantId = process.env.ADAL_TENANT_ID;
|
|
25
|
+
const redirectUri = process.env.IOS_ADAL_REDIRECT_URI;
|
|
26
|
+
const bundleId = config.ios?.bundleIdentifier;
|
|
27
|
+
const isDevBuild = process.env.DEV_CLIENT === 'true' ||
|
|
28
|
+
process.env.POWER_APPS_DEV_PLAYER === 'true';
|
|
29
|
+
|
|
30
|
+
// Dev builds never call getWrapConfig() — skip entirely.
|
|
31
|
+
if (isDevBuild) return mod;
|
|
32
|
+
|
|
33
|
+
if (clientId && clientId !== 'ADAL_CLIENT_ID_TAG') {
|
|
34
|
+
// Standalone build-from-source: inject real values so no post-build
|
|
35
|
+
// patching is needed.
|
|
36
|
+
mod.modResults.IntuneMAMSettings = {
|
|
37
|
+
ADALClientId: clientId,
|
|
38
|
+
ADALRedirectUri: redirectUri ?? `msauth.${bundleId}://auth`,
|
|
39
|
+
ADALTenantId: tenantId ?? '',
|
|
40
|
+
ADALAuthority: `https://login.microsoftonline.com/${tenantId ?? ''}`,
|
|
41
|
+
};
|
|
42
|
+
} else {
|
|
43
|
+
// Release build without env vars (wrap pipeline base IPA).
|
|
44
|
+
// Write placeholder tags so the wrap script can locate and replace them
|
|
45
|
+
// with `plutil -replace IntuneMAMSettings.*`, preserving the original
|
|
46
|
+
// template behaviour.
|
|
47
|
+
mod.modResults.IntuneMAMSettings = {
|
|
48
|
+
ADALClientId: 'ADAL_CLIENT_ID_TAG',
|
|
49
|
+
ADALRedirectUri: 'ADAL_REDIRECT_URI_TAG',
|
|
50
|
+
ADALTenantId: 'ADAL_TENANT_ID_TAG',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return mod;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = withIntuneMAMSettings;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Expo config plugin: replace the minimal msauth URL scheme with the full set
|
|
6
|
+
* of MSAL auth-broker + Intune MAM URL schemes required for production builds.
|
|
7
|
+
*
|
|
8
|
+
* The minimal entry (msauth.<bundleId>) added by withMsalIOSURLScheme is
|
|
9
|
+
* sufficient for dev builds and satisfies MSAL's init-time check. For
|
|
10
|
+
* distribution (standalone build-from-source or wrap pipeline) the full
|
|
11
|
+
* scheme list mirrors what wrap-local Step 3 injects post-build.
|
|
12
|
+
*
|
|
13
|
+
* This plugin is a no-op when ADAL_CLIENT_ID is absent or a placeholder tag —
|
|
14
|
+
* i.e. in all `npm run dev` / `expo prebuild` calls not driven by build.js.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const { withInfoPlist } = require('@expo/config-plugins');
|
|
18
|
+
|
|
19
|
+
/** @param {import('@expo/config-plugins').ExpoConfig} config */
|
|
20
|
+
function withMsalBrokerURLSchemes(config) {
|
|
21
|
+
return withInfoPlist(config, (mod) => {
|
|
22
|
+
const clientId = process.env.ADAL_CLIENT_ID;
|
|
23
|
+
const bundleId = config.ios?.bundleIdentifier;
|
|
24
|
+
|
|
25
|
+
if (!clientId || clientId === 'ADAL_CLIENT_ID_TAG' || !bundleId) {
|
|
26
|
+
return mod; // dev build — keep minimal scheme entry
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const msauthScheme = `msauth.${bundleId}`;
|
|
30
|
+
const bundleIdDashes = bundleId.replace(/\./g, '-');
|
|
31
|
+
const bundleSpecificScheme = `ms-mobile-apps-${bundleIdDashes}`;
|
|
32
|
+
const xMsauthSchemes = [
|
|
33
|
+
`x-msauth-${bundleIdDashes}`,
|
|
34
|
+
`x-msauth-${bundleIdDashes}-intunemam`,
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
// Remove any existing minimal msauth.<bundleId> entries that were added by
|
|
38
|
+
// withMsalIOSURLScheme / withMsalRedirectScheme so we don't produce duplicates.
|
|
39
|
+
const remaining = (mod.modResults.CFBundleURLTypes ?? []).filter(
|
|
40
|
+
(t) =>
|
|
41
|
+
!Array.isArray(t.CFBundleURLSchemes) ||
|
|
42
|
+
!t.CFBundleURLSchemes.includes(msauthScheme),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
mod.modResults.CFBundleURLTypes = [
|
|
46
|
+
...remaining,
|
|
47
|
+
// Entry 0: all auth-broker + deep-link schemes (mirrors wrap-local Step 3)
|
|
48
|
+
{
|
|
49
|
+
CFBundleURLName: bundleId,
|
|
50
|
+
CFBundleURLSchemes: [
|
|
51
|
+
msauthScheme,
|
|
52
|
+
`${msauthScheme}-intunemam`,
|
|
53
|
+
'projectsiena',
|
|
54
|
+
'projectsiena-intunemam',
|
|
55
|
+
'ms-mobile-apps',
|
|
56
|
+
'ms-mobile-apps-intunemam',
|
|
57
|
+
bundleSpecificScheme,
|
|
58
|
+
`${bundleSpecificScheme}-intunemam`,
|
|
59
|
+
'ms-mobile-app',
|
|
60
|
+
'ms-mobile-app-intunemam',
|
|
61
|
+
'ms-app',
|
|
62
|
+
'ms-app-intunemam',
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
// Entries 1-3: x-msauth broker schemes (mirrors wrap-local production structure)
|
|
66
|
+
{ CFBundleURLName: bundleId, CFBundleURLSchemes: xMsauthSchemes },
|
|
67
|
+
{ CFBundleURLName: bundleId, CFBundleURLSchemes: xMsauthSchemes },
|
|
68
|
+
{ CFBundleURLName: bundleId, CFBundleURLSchemes: xMsauthSchemes },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
return mod;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = withMsalBrokerURLSchemes;
|