Compare commits

..

5 Commits

7 changed files with 95 additions and 4 deletions

7
.editorconfig Normal file
View File

@@ -0,0 +1,7 @@
[*.{js,mjs}]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env node #!/usr/bin/env node
import { loginInteractive } from "../src/auth.js"; import { loginInteractive } from "../src/azure.js";
import { config } from "../public-config.js"; import { config } from "../public-config.js";
import { createHash } from "crypto"; import { createHash } from "crypto";

47
bin/list-apps.mjs Executable file
View File

@@ -0,0 +1,47 @@
#! /usr/bin/env node
import { loginInteractive } from "../src/azure.js";
import { Client } from "@microsoft/microsoft-graph-client";
const scopes = [
"https://graph.microsoft.com/.default"
];
const { config } = await import("../public-config.js");
async function main(config) {
const token = await loginInteractive({
tenantId: config.tenantId,
clientId: config.clientId,
scopes,
});
console.log("Successfully logged in.");
const accessToken = token.accessToken;
const client = Client.init({
authProvider: (done) => {
done(null, accessToken);
},
});
const me = await client
.api("/me")
.get();
console.log("User Information:", me);
const apps = await client
.api("/applications")
.select("displayName,appId,createdDateTime")
.top(50)
.get();
console.log("Applications:");
apps.value.forEach((app) => {
console.log(`- ${app.displayName} (App ID: ${app.appId}, Created: ${app.createdDateTime})`);
});
}
main(config).catch((err) => {
console.error("Error in listing applications:", err);
process.exit(1);
});

View File

@@ -2,7 +2,6 @@
import { exec, execSync, spawnSync } from "child_process"; import { exec, execSync, spawnSync } from "child_process";
import { writeFileSync } from "fs"; import { writeFileSync } from "fs";
import { env } from "process";
import { parseArgs } from "util"; import { parseArgs } from "util";
const args = parseArgs({ const args = parseArgs({

39
package-lock.json generated
View File

@@ -9,7 +9,8 @@
"version": "1.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"@azure/identity": "^4.13.0", "@azure/identity": "^4.13.0",
"@azure/msal-node": "^5.0.2" "@azure/msal-node": "^5.0.2",
"@microsoft/microsoft-graph-client": "^3.0.7"
}, },
"engines": { "engines": {
"node": ">=24.0.0" "node": ">=24.0.0"
@@ -196,6 +197,42 @@
"node": ">=0.8.0" "node": ">=0.8.0"
} }
}, },
"node_modules/@babel/runtime": {
"version": "7.28.6",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz",
"integrity": "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@microsoft/microsoft-graph-client": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/@microsoft/microsoft-graph-client/-/microsoft-graph-client-3.0.7.tgz",
"integrity": "sha512-/AazAV/F+HK4LIywF9C+NYHcJo038zEnWkteilcxC1FM/uK/4NVGDKGrxx7nNq1ybspAroRKT4I1FHfxQzxkUw==",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.12.5",
"tslib": "^2.2.0"
},
"engines": {
"node": ">=12.0.0"
},
"peerDependenciesMeta": {
"@azure/identity": {
"optional": true
},
"@azure/msal-browser": {
"optional": true
},
"buffer": {
"optional": true
},
"stream-browserify": {
"optional": true
}
}
},
"node_modules/@typespec/ts-http-runtime": { "node_modules/@typespec/ts-http-runtime": {
"version": "0.3.2", "version": "0.3.2",
"resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.2.tgz", "resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.2.tgz",

View File

@@ -7,6 +7,7 @@
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@azure/identity": "^4.13.0", "@azure/identity": "^4.13.0",
"@azure/msal-node": "^5.0.2" "@azure/msal-node": "^5.0.2",
"@microsoft/microsoft-graph-client": "^3.0.7"
} }
} }