@microsoft/power-apps-native-auth 0.3.2
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/LICENSE +112 -0
- package/README.md +54 -0
- package/android/build.gradle +79 -0
- package/android/src/main/AndroidManifest.xml +31 -0
- package/android/src/main/java/expo/modules/msalintune/ExpoMsalIntuneModule.kt +488 -0
- package/app.plugin.js +4 -0
- package/expo-module.config.json +9 -0
- package/ios/ExpoMsalIntune.podspec +27 -0
- package/ios/ExpoMsalIntuneAppDelegate.swift +31 -0
- package/ios/ExpoMsalIntuneModule.swift +382 -0
- package/lib/NOTICE.txt +5 -0
- package/lib/commonjs/AuthConfig.types.js +1 -0
- package/lib/commonjs/ExpoMsalIntune.types.js +1 -0
- package/lib/commonjs/ExpoMsalIntuneModule.js +50 -0
- package/lib/commonjs/index.js +217 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/AuthConfig.types.js +1 -0
- package/lib/module/ExpoMsalIntune.types.js +1 -0
- package/lib/module/ExpoMsalIntuneModule.js +44 -0
- package/lib/module/index.js +207 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/AuthConfig.types.d.ts +76 -0
- package/lib/typescript/commonjs/ExpoMsalIntune.types.d.ts +80 -0
- package/lib/typescript/commonjs/ExpoMsalIntuneModule.d.ts +92 -0
- package/lib/typescript/commonjs/index.d.ts +125 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/module/AuthConfig.types.d.ts +76 -0
- package/lib/typescript/module/ExpoMsalIntune.types.d.ts +80 -0
- package/lib/typescript/module/ExpoMsalIntuneModule.d.ts +92 -0
- package/lib/typescript/module/index.d.ts +125 -0
- package/lib/typescript/module/package.json +1 -0
- package/package.json +93 -0
- package/plugin/index.js +528 -0
- package/plugin/withMsalRedirectScheme.js +53 -0
- package/scripts/setup-android-sdk.js +122 -0
- package/scripts/setup-ios-frameworks.js +100 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Downloads the Microsoft Intune MAM SDK for Android and the accompanying
|
|
4
|
+
* Gradle build plugin from the official GitHub release and places them in
|
|
5
|
+
* android/libs/ (gitignored — binaries are too large for git).
|
|
6
|
+
*
|
|
7
|
+
* Files downloaded:
|
|
8
|
+
* Microsoft.Intune.MAM.SDK.aar — runtime SDK (classes + resources)
|
|
9
|
+
* Microsoft.Intune.MAM.SDK.DownlevelStubs.aar — stubs for pre-API-26 devices
|
|
10
|
+
* com.microsoft.intune.mam.build.jar — Gradle plugin that instruments
|
|
11
|
+
* Activity/Application bytecode
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* npm run setup:android (from packages/power-apps-native-auth/)
|
|
15
|
+
* node scripts/setup-android-sdk.js [version]
|
|
16
|
+
*
|
|
17
|
+
* The version defaults to INTUNE_ANDROID_SDK_VERSION below, or can be
|
|
18
|
+
* overridden via the first CLI argument or the INTUNE_ANDROID_SDK_VERSION
|
|
19
|
+
* env variable.
|
|
20
|
+
*
|
|
21
|
+
* After running, update INTUNE_ANDROID_SDK_VERSION in build.gradle if you
|
|
22
|
+
* change the version here, and upgrade the MAM Gradle plugin classpath in
|
|
23
|
+
* templates/expo-app/android/build.gradle to match.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const https = require('https');
|
|
27
|
+
const fs = require('fs');
|
|
28
|
+
const path = require('path');
|
|
29
|
+
const os = require('os');
|
|
30
|
+
|
|
31
|
+
const DEFAULT_VERSION = '12.0.3';
|
|
32
|
+
const version =
|
|
33
|
+
process.argv[2] || process.env.INTUNE_ANDROID_SDK_VERSION || DEFAULT_VERSION;
|
|
34
|
+
|
|
35
|
+
const REPO = 'microsoftconnect/ms-intune-app-sdk-android';
|
|
36
|
+
const RAW_BASE = `https://github.com/${REPO}/raw/refs/tags/${version}`;
|
|
37
|
+
|
|
38
|
+
// Files to download: [source path relative to repo root, dest filename in android/libs/]
|
|
39
|
+
const FILES = [
|
|
40
|
+
['Microsoft.Intune.MAM.SDK.aar', 'Microsoft.Intune.MAM.SDK.aar'],
|
|
41
|
+
['libs/Microsoft.Intune.MAM.SDK.DownlevelStubs.aar', 'Microsoft.Intune.MAM.SDK.DownlevelStubs.aar'],
|
|
42
|
+
['GradlePlugin/com.microsoft.intune.mam.build.jar', 'com.microsoft.intune.mam.build.jar'],
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const libsDir = path.join(__dirname, '..', 'android', 'libs');
|
|
46
|
+
|
|
47
|
+
// Check if all files are already present at the right version.
|
|
48
|
+
// Store the version in a sentinel file so re-running at a different version
|
|
49
|
+
// forces a re-download.
|
|
50
|
+
const sentinelPath = path.join(libsDir, '.sdk-version');
|
|
51
|
+
const currentVersion = fs.existsSync(sentinelPath)
|
|
52
|
+
? fs.readFileSync(sentinelPath, 'utf8').trim()
|
|
53
|
+
: null;
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
currentVersion === version &&
|
|
57
|
+
FILES.every(([, dest]) => fs.existsSync(path.join(libsDir, dest)))
|
|
58
|
+
) {
|
|
59
|
+
console.log(
|
|
60
|
+
`✅ Intune MAM SDK ${version} already present in android/libs/`
|
|
61
|
+
);
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fs.mkdirSync(libsDir, { recursive: true });
|
|
66
|
+
|
|
67
|
+
function download(url, destPath) {
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
function get(currentUrl, hops) {
|
|
70
|
+
if (hops > 5) return reject(new Error('Too many redirects'));
|
|
71
|
+
const file = fs.createWriteStream(destPath);
|
|
72
|
+
https
|
|
73
|
+
.get(currentUrl, (res) => {
|
|
74
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
75
|
+
file.close();
|
|
76
|
+
try { fs.unlinkSync(destPath); } catch {}
|
|
77
|
+
return get(res.headers.location, hops + 1);
|
|
78
|
+
}
|
|
79
|
+
if (res.statusCode !== 200) {
|
|
80
|
+
file.close();
|
|
81
|
+
try { fs.unlinkSync(destPath); } catch {}
|
|
82
|
+
return reject(new Error(`HTTP ${res.statusCode} downloading ${currentUrl}`));
|
|
83
|
+
}
|
|
84
|
+
res.pipe(file);
|
|
85
|
+
file.on('finish', () => file.close(resolve));
|
|
86
|
+
file.on('error', (err) => {
|
|
87
|
+
try { fs.unlinkSync(destPath); } catch {}
|
|
88
|
+
reject(err);
|
|
89
|
+
});
|
|
90
|
+
})
|
|
91
|
+
.on('error', (err) => {
|
|
92
|
+
try { fs.unlinkSync(destPath); } catch {}
|
|
93
|
+
reject(err);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
get(url, 0);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
(async () => {
|
|
101
|
+
console.log(`⬇️ Downloading Intune MAM SDK ${version} from GitHub...`);
|
|
102
|
+
console.log(` https://github.com/${REPO}/tree/${version}\n`);
|
|
103
|
+
|
|
104
|
+
for (const [srcPath, destName] of FILES) {
|
|
105
|
+
const url = `${RAW_BASE}/${srcPath}`;
|
|
106
|
+
const dest = path.join(libsDir, destName);
|
|
107
|
+
process.stdout.write(` ${destName} ... `);
|
|
108
|
+
await download(url, dest);
|
|
109
|
+
console.log('✅');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Write sentinel so we can skip re-download at the same version.
|
|
113
|
+
fs.writeFileSync(sentinelPath, version + '\n', 'utf8');
|
|
114
|
+
|
|
115
|
+
console.log(`\n✅ Intune MAM SDK ${version} installed to android/libs/`);
|
|
116
|
+
console.log(
|
|
117
|
+
' Add android/libs/ to your PATH or reference via local file deps in build.gradle.\n'
|
|
118
|
+
);
|
|
119
|
+
})().catch((err) => {
|
|
120
|
+
console.error(`\n❌ setup:android failed: ${err.message}`);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Downloads IntuneMAMSwift xcframeworks from the official GitHub release and
|
|
4
|
+
* places them in ios/Frameworks/ (gitignored — binaries are too large for git).
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* npm run setup:ios (from packages/power-apps-native-auth/)
|
|
8
|
+
* node scripts/setup-ios-frameworks.js [version]
|
|
9
|
+
*
|
|
10
|
+
* The version defaults to INTUNE_IOS_SDK_VERSION below, or can be overridden
|
|
11
|
+
* via the first CLI argument or the INTUNE_IOS_SDK_VERSION env variable.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const https = require('https');
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const { execSync } = require('child_process');
|
|
18
|
+
const os = require('os');
|
|
19
|
+
|
|
20
|
+
const DEFAULT_VERSION = '20.9.2';
|
|
21
|
+
const version = process.argv[2] || process.env.INTUNE_IOS_SDK_VERSION || DEFAULT_VERSION;
|
|
22
|
+
|
|
23
|
+
const REPO = 'microsoftconnect/ms-intune-app-sdk-ios';
|
|
24
|
+
const DOWNLOAD_URL = `https://github.com/${REPO}/archive/refs/tags/${version}.zip`;
|
|
25
|
+
|
|
26
|
+
const FRAMEWORKS = ['IntuneMAMSwift.xcframework', 'IntuneMAMSwiftStub.xcframework'];
|
|
27
|
+
|
|
28
|
+
const frameworksDir = path.join(__dirname, '..', 'ios', 'Frameworks');
|
|
29
|
+
const tmpZip = path.join(os.tmpdir(), `intune-ios-sdk-${version}.zip`);
|
|
30
|
+
const tmpExtract = path.join(os.tmpdir(), `intune-ios-sdk-${version}`);
|
|
31
|
+
|
|
32
|
+
// Check if already present
|
|
33
|
+
const allPresent = FRAMEWORKS.every(f => fs.existsSync(path.join(frameworksDir, f)));
|
|
34
|
+
if (allPresent) {
|
|
35
|
+
console.log(`✅ IntuneMAMSwift ${version} xcframeworks already present in ios/Frameworks/`);
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fs.mkdirSync(frameworksDir, { recursive: true });
|
|
40
|
+
|
|
41
|
+
console.log(`⬇️ Downloading IntuneMAMSwift ${version} from GitHub...`);
|
|
42
|
+
console.log(` ${DOWNLOAD_URL}`);
|
|
43
|
+
|
|
44
|
+
function download(url, dest, redirects = 0) {
|
|
45
|
+
if (redirects > 5) throw new Error('Too many redirects');
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const file = fs.createWriteStream(dest);
|
|
48
|
+
https.get(url, (res) => {
|
|
49
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
50
|
+
file.close();
|
|
51
|
+
fs.unlinkSync(dest);
|
|
52
|
+
download(res.headers.location, dest, redirects + 1).then(resolve).catch(reject);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (res.statusCode !== 200) {
|
|
56
|
+
reject(new Error(`HTTP ${res.statusCode} from ${url}`));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
res.pipe(file);
|
|
60
|
+
file.on('finish', () => file.close(resolve));
|
|
61
|
+
}).on('error', (err) => {
|
|
62
|
+
fs.unlinkSync(dest);
|
|
63
|
+
reject(err);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
(async () => {
|
|
69
|
+
try {
|
|
70
|
+
await download(DOWNLOAD_URL, tmpZip);
|
|
71
|
+
console.log('📦 Extracting...');
|
|
72
|
+
|
|
73
|
+
execSync(`unzip -q -o "${tmpZip}" -d "${tmpExtract}"`, { stdio: 'inherit' });
|
|
74
|
+
|
|
75
|
+
const extractedRoot = path.join(tmpExtract, `ms-intune-app-sdk-ios-${version}`);
|
|
76
|
+
|
|
77
|
+
for (const framework of FRAMEWORKS) {
|
|
78
|
+
const src = path.join(extractedRoot, framework);
|
|
79
|
+
const dest = path.join(frameworksDir, framework);
|
|
80
|
+
if (!fs.existsSync(src)) {
|
|
81
|
+
throw new Error(`Expected ${framework} not found in the release archive at ${src}`);
|
|
82
|
+
}
|
|
83
|
+
if (fs.existsSync(dest)) {
|
|
84
|
+
execSync(`rm -rf "${dest}"`);
|
|
85
|
+
}
|
|
86
|
+
execSync(`cp -R "${src}" "${dest}"`);
|
|
87
|
+
console.log(`✅ Copied ${framework}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Cleanup
|
|
91
|
+
fs.unlinkSync(tmpZip);
|
|
92
|
+
execSync(`rm -rf "${tmpExtract}"`);
|
|
93
|
+
|
|
94
|
+
console.log(`\n✅ IntuneMAMSwift ${version} xcframeworks installed to ios/Frameworks/`);
|
|
95
|
+
console.log(' You can now run: npx expo run:ios\n');
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error(`\n❌ setup:ios failed: ${err.message}`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
})();
|