Refactor getCredential function to support shorthand credential types: 'd' for Default, 'cs' for ClientSecret, and 'dc' for DeviceCode. Remove obsolete client-secret-login script.

This commit is contained in:
2026-02-03 22:06:39 +01:00
parent 0806a2b588
commit a8725a7c22
3 changed files with 4 additions and 34 deletions

View File

@@ -11,8 +11,10 @@ import { DefaultAzureCredential, ClientSecretCredential, DeviceCodeCredential }
export async function getCredential(credentialType, options) {
switch (credentialType) {
case "d":
case "default":
return new DefaultAzureCredential();
case "cs":
case "clientSecret":
if (!options.tenantId || !options.clientId || !options.clientSecret) {
throw new Error("tenantId, clientId, and clientSecret are required for ClientSecretCredential");
@@ -22,6 +24,7 @@ export async function getCredential(credentialType, options) {
options.clientId,
options.clientSecret
);
case "dc":
case "deviceCode":
if (!options.tenantId || !options.clientId) {
throw new Error("tenantId and clientId are required for DeviceCodeCredential");