@microsoft/yarn-plugin-ado-auth 0.2.2 → 0.2.3

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.
@@ -327,10 +327,12 @@ var plugin = (() => {
327
327
  return await invokeCredentialProvider(toolPath, nugetFeedUrl);
328
328
  }
329
329
  function toNugetUrl(registry) {
330
- if (!registry.endsWith("/npm/registry/")) {
330
+ const normalized = registry.endsWith("/") ? registry : registry + "/";
331
+ if (!normalized.endsWith("/npm/registry/")) {
331
332
  throw new Error(`Registry URL ${registry} is not a valid Azure Artifacts npm registry URL. Expected it to end with '/npm/registry/'`);
332
333
  }
333
- return "https://" + registry.replace("/npm/registry/", "/nuget/v3/index.json");
334
+ const nugetPath = normalized.replace("/npm/registry/", "/nuget/v3/index.json");
335
+ return /^[a-z]+:\/\//i.test(nugetPath) ? nugetPath : "https://" + nugetPath;
334
336
  }
335
337
  async function invokeCredentialProvider(toolPath, nugetFeedUrl) {
336
338
  let response = "";
@@ -499,6 +501,7 @@ var plugin = (() => {
499
501
  */
500
502
  async fetchToken(registry, ident) {
501
503
  const configuration = this.configuration;
504
+ let token = null;
502
505
  await import_core2.StreamReport.start(
503
506
  { configuration, stdout: process.stdout },
504
507
  async (report) => {
@@ -510,6 +513,7 @@ var plugin = (() => {
510
513
  const authConfig = this.getAuthConfiguration(registry, ident);
511
514
  const tokenFromYarnrc = getConfigString(authConfig, "npmAuthToken");
512
515
  if (tokenFromYarnrc) {
516
+ token = tokenFromYarnrc;
513
517
  this.cache[registry] = tokenFromYarnrc;
514
518
  report.reportInfo(
515
519
  null,
@@ -523,24 +527,24 @@ var plugin = (() => {
523
527
  `Could not determine organization from registry URL: ${registry}`
524
528
  );
525
529
  }
526
- const pat2 = await generateNpmrcPat(
530
+ const pat = await generateNpmrcPat(
527
531
  organization,
528
532
  registry,
529
533
  false,
530
534
  this.azureAuthPath
531
535
  );
532
- this.cache[registry] = pat2;
536
+ token = pat;
537
+ this.cache[registry] = pat;
533
538
  report.reportInfo(
534
539
  null,
535
540
  `Authenticated to: ${prettyRegistry} (via ADO CLI)`
536
541
  );
537
542
  }
538
543
  );
539
- const pat = this.cache[registry];
540
- if (pat == null) {
544
+ if (token == null) {
541
545
  throw new Error(`Failed to authenticate to: ${registry}`);
542
546
  }
543
- return pat;
547
+ return token;
544
548
  }
545
549
  /**
546
550
  * Get the authentication configuration for the given registry and ident. This code was
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/plugin.ts", "../src/tokenCache.ts", "../../ado-npm-auth-lib/src/utils/get-organization-from-feed-url.ts", "../../ado-npm-auth-lib/src/utils/encoding.ts", "../../ado-npm-auth-lib/src/utils/request.ts", "../../ado-npm-auth-lib/src/npmrc/generate-npmrc-pat.ts", "../../ado-npm-auth-lib/src/azureauth/ado.ts", "../../ado-npm-auth-lib/src/utils/exec.ts", "../../ado-npm-auth-lib/src/azureauth/is-supported-platform-and-architecture.ts", "../../ado-npm-auth-lib/src/utils/is-wsl.ts", "../../ado-npm-auth-lib/src/azureauth/azureauth-command.ts", "../../ado-npm-auth-lib/src/azureauth/is-azureauth-installed.ts", "../../ado-npm-auth-lib/src/npmrc/nugetCredentialProvider.ts", "../src/configuration.ts", "../src/utils.ts", "../src/getToken.ts"],
4
- "sourcesContent": ["import { type Plugin } from \"@yarnpkg/core\";\nimport { type GetAuthHeaderOptions, getToken } from \"./getToken.ts\";\nimport { getConfiguration } from \"./configuration.ts\";\n\n/**\n * Called when getting the authentication header for a request to the npm registry.\n * You can use this mechanism to dynamically query a CLI for the credentials for a\n * specific registry.\n */\nasync function getNpmAuthenticationHeader(\n currentHeader: string | undefined,\n registry: string,\n options: GetAuthHeaderOptions,\n): Promise<string | undefined> {\n const customToken = getToken(options, registry);\n if (customToken !== undefined) {\n const token =\n typeof customToken === \"string\" ? customToken : await customToken;\n return `Bearer ${token}`;\n }\n return currentHeader;\n}\n\n/**\n * The plugin definition.\n */\nconst plugin: Plugin = {\n /**\n * Add the plugin configuration options\n */\n configuration: getConfiguration(),\n\n /**\n * Add a hook to authenticate on demand with npm feeds\n */\n hooks: {\n getNpmAuthenticationHeader,\n },\n};\n\n// eslint-disable-next-line no-restricted-exports\nexport default plugin;\n", "import {\n type Configuration,\n type Ident,\n StreamReport,\n formatUtils,\n} from \"@yarnpkg/core\";\nimport {\n getOrganizationFromFeedUrl,\n generateNpmrcPat,\n} from \"@microsoft/ado-npm-auth-lib\";\nimport { loadConfiguration } from \"./configuration.ts\";\nimport { getConfigMap, getConfigString, type MapLike } from \"./utils.ts\";\nimport { spawnSync } from \"node:child_process\";\nimport os from \"node:os\";\n\n/**\n * A simple in-memory cache for tokens per registry. This will attempt to load tokens from the\n * existing settings first, and if not found, will use the ADO CLI to get a new token.\n */\nexport class TokenCache {\n private configuration: Configuration;\n private prefix: string;\n private azureAuthPath?: string;\n private cache: Record<string, string | Promise<string>> = {};\n\n constructor(\n configuration: Configuration,\n loadConfig: typeof loadConfiguration = loadConfiguration,\n ) {\n this.configuration = configuration;\n const settings = loadConfig(configuration);\n this.prefix = settings.adoNpmAuthFeedPrefix ?? \"\";\n this.azureAuthPath = settings.adoNpmAuthToolPath || findAzureAuthPath();\n }\n\n /**\n * Will return the token for the given registry, either from cache or by fetching a new one. If it is in\n * the cache already, it will return it directly. Otherwise it will return a promise that resolves to the token\n * @param registry the registry/feed that we need to authenticate against\n */\n getToken(\n registry: string,\n ident?: Ident,\n ): string | Promise<string> | undefined {\n if (!this.prefix || registry.startsWith(this.prefix)) {\n return (this.cache[registry] ??= this.fetchToken(registry, ident));\n }\n return undefined;\n }\n\n /**\n * Do the work to fetch a token for the given registry. This will attempt to get it from yarnrc/env first,\n * and if not found, will use the ADO CLI to get a new token.\n *\n * @param registry registry to authenticate to\n * @param ident optional ident, used for configuration lookups (yarn pass through)\n * @returns a promise that resolves to a string\n */\n private async fetchToken(registry: string, ident?: Ident): Promise<string> {\n const configuration = this.configuration;\n await StreamReport.start(\n { configuration, stdout: process.stdout },\n async (report) => {\n const prettyRegistry = formatUtils.pretty(\n configuration,\n registry,\n formatUtils.Type.URL,\n );\n // first see if a token is set via .yarnrc, either hardcoded or via environment variable\n const authConfig = this.getAuthConfiguration(registry, ident);\n const tokenFromYarnrc = getConfigString(authConfig, \"npmAuthToken\");\n if (tokenFromYarnrc) {\n this.cache[registry] = tokenFromYarnrc;\n report.reportInfo(\n null,\n `Authenticated to: ${prettyRegistry} (via configuration)`,\n );\n return;\n }\n\n const organization = getOrganizationFromFeedUrl(registry);\n if (!organization) {\n throw new Error(\n `Could not determine organization from registry URL: ${registry}`,\n );\n }\n\n const pat = await generateNpmrcPat(\n organization,\n registry,\n false,\n this.azureAuthPath,\n );\n this.cache[registry] = pat;\n report.reportInfo(\n null,\n `Authenticated to: ${prettyRegistry} (via ADO CLI)`,\n );\n },\n );\n\n const pat = this.cache[registry];\n if (pat == null) {\n throw new Error(`Failed to authenticate to: ${registry}`);\n }\n return pat;\n }\n\n /**\n * Get the authentication configuration for the given registry and ident. This code was\n * taken from Yarn's npm plugin to match their logic. Importing that package directly results in\n * a massive bundle, so extracted just this logic.\n */\n private getAuthConfiguration(registry: string, ident?: Ident): MapLike {\n const scopeConfiguration = ident && this.getScopeConfiguration(ident.scope);\n\n if (scopeConfiguration?.get(`npmAuthToken`)) {\n return scopeConfiguration;\n }\n\n const registryConfiguration = this.getRegistryConfiguration(registry);\n\n return registryConfiguration ?? this.configuration;\n }\n\n /**\n * Return the auth configuration for the given scope if one has been set\n * @param scope package scope to use for lookups\n */\n private getScopeConfiguration(scope: string | null): MapLike | null {\n if (scope != null) {\n const scopeConfigurations = getConfigMap(this.configuration, `npmScopes`);\n const scopeConfiguration = getConfigMap(scopeConfigurations, scope);\n if (scopeConfiguration) {\n return scopeConfiguration;\n }\n }\n return null;\n }\n\n /**\n * Return the auth configuration for the given registry if one has been set\n * @param registry registry to get configuration for\n */\n private getRegistryConfiguration(registry: string): MapLike | null {\n // get the npmRegistries configuration map\n const registryConfigurations = getConfigMap(\n this.configuration,\n `npmRegistries`,\n );\n // normalize the registry url for lookups, same as yarn does internally\n const normalizedRegistry = registry.replace(/\\/$/, ``);\n\n // first try to get an exact match\n const exactEntry = getConfigMap(registryConfigurations, normalizedRegistry);\n if (typeof exactEntry !== `undefined`) {\n return exactEntry;\n }\n\n // then try without protocol\n const noProtocolEntry = getConfigMap(\n registryConfigurations,\n normalizedRegistry.replace(/^[a-z]+:/, ``),\n );\n\n return noProtocolEntry ?? null;\n }\n}\n\nfunction findAzureAuthPath(): string | undefined {\n const isWin = os.platform() === \"win32\";\n const execName = isWin ? \"azureauth.exe\" : \"azureauth\";\n const cmd = isWin ? \"where\" : \"which\";\n\n try {\n const result = spawnSync(cmd, [execName], { encoding: \"utf-8\" });\n if (result.status === 0 && result.stdout) {\n const line = result.stdout.split(/\\r?\\n/).find(Boolean);\n return line ? line.trim() : undefined;\n }\n } catch {\n // Ignore errors, fall through to undefined\n }\n\n return undefined;\n}\n", "/**\n * Extracts the organization and project details from a given Azure DevOps URL.\n * The function differentiates between the \"new style\" URLs that use 'dev.azure.com'\n * and \"old style\" URLs that use a subdomain of 'visualstudio.com'.\n *\n * @param {string} url - The Azure DevOps URL from which to extract details.\n * @returns {Object} An object containing the `organization` and `project` extracted from the URL.\n * @throws {Error} Throws an error if the URL is invalid, not in the expected format,\n * or does not contain the necessary information for extraction.\n *\n * @example\n * // New style URL\n * extractAdoDetails(\"https://dev.azure.com/contoso/WebsiteRedesign\");\n * // returns { organization: \"contoso\", project: \"WebsiteRedesign\" }\n *\n * // Old style URL\n * extractAdoDetails(\"https://contoso.visualstudio.com/WebsiteRedesign\");\n * // returns { organization: \"contoso\", project: \"WebsiteRedesign\" }\n *\n * // Invalid URL\n * extractAdoDetails(\"https://invalid.url.com\");\n * // throws Error\n */\nconst extractAdoDetails = (url: string) => {\n try {\n if (!url.startsWith(\"https://\")) {\n url = \"https://\" + url;\n }\n const parsedUrl = new URL(url);\n const hostname = parsedUrl.hostname;\n const pathname = parsedUrl.pathname;\n\n // Check for new style URLs (dev.azure.com)\n if (hostname.endsWith(\"dev.azure.com\")) {\n const pathSegments = pathname.split(\"/\").filter(Boolean); // Remove empty strings from the split result\n if (pathSegments.length >= 2) {\n return {\n organization: pathSegments[0],\n project: pathSegments[1],\n };\n } else {\n throw new Error(\n \"Not enough segments in path for a valid organization and project extraction.\",\n );\n }\n }\n\n // Check for old style URLs (visualstudio.com)\n if (hostname.endsWith(\"visualstudio.com\")) {\n const subdomain = hostname.split(\".\")[0];\n const pathSegments = pathname.split(\"/\").filter(Boolean);\n if (subdomain && pathSegments.length >= 1) {\n return {\n organization: subdomain,\n project: pathSegments[0],\n };\n } else {\n throw new Error(\n \"Not enough segments in path or missing subdomain for a valid organization and project extraction.\",\n );\n }\n }\n\n // If the URL does not match expected formats\n throw new Error(\n \"URL format not recognized or does not contain enough information.\",\n );\n } catch {\n throw new Error(\"Invalid URL or unsupported format\");\n }\n};\n\n/**\n * Get the ADO Org for a npm feed\n * @param {string} feedUrl URL of the feed to get the ADO organization from\n * @param {string} [defaultOrg] Backup org in case it cannot be determined from the feed url\n * @returns ADO Organization for the feed\n */\nexport const getOrganizationFromFeedUrl = (\n feedUrl: string,\n defaultOrg = \"\",\n) => {\n try {\n const { organization } = extractAdoDetails(feedUrl);\n return organization;\n } catch {\n return defaultOrg;\n }\n};\n", "/**\n * Create a base64 encoded string from a string\n * @param {string} input\n * @returns {string}\n */\nexport function toBase64(input: string | undefined): string {\n return Buffer.from(input || \"\").toString(\"base64\");\n}\n\n/**\n * Decode a base64 encoded string\n * @param {string} base64string\n * @returns\n */\nexport const fromBase64 = (base64string: string) =>\n Buffer.from(base64string, \"base64\").toString(\"utf8\");\n", "import https, { type RequestOptions } from \"node:https\";\nimport type { OutgoingHttpHeaders } from \"node:http\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nconst defaultOptions: RequestOptions = {\n port: 443,\n method: \"GET\",\n};\n\n/**\n *\n * @param {import(\"http\").RequestOptions} options\n * @returns\n */\nexport const makeRequest = async (options: RequestOptions) => {\n return new Promise((resolve, reject) => {\n const mergedOptions = {\n ...defaultOptions,\n ...options,\n };\n\n const req = https.request(mergedOptions, (res) => {\n let data = \"\";\n let dataJson = {};\n const ok = res.statusCode === 200;\n\n res.on(\"data\", (d) => {\n data += d;\n });\n\n res.on(\"end\", () => {\n if (\n data &&\n hasAcceptHeaderValue(mergedOptions?.headers, \"application/json\")\n ) {\n dataJson = JSON.parse(data.toString().trim());\n }\n\n if (ok) {\n resolve(dataJson || data);\n } else {\n if (dataJson) {\n dataJson = { ...dataJson, statusCode: res.statusCode };\n }\n reject(\n dataJson || data || new Error(`Error code: ${res.statusCode}.`),\n );\n }\n });\n\n res.on(\"error\", (/** @type {string} */ error) => {\n reject(new Error(error as any));\n });\n });\n\n req.end();\n });\n};\n\nfunction hasAcceptHeaderValue(\n headers: OutgoingHttpHeaders | readonly string[] | undefined,\n acceptHeaderValueToCheck: string,\n): boolean {\n if (!headers) {\n return false;\n }\n\n if (Array.isArray(headers)) {\n for (const header of headers) {\n const indx = header.toLowerCase().indexOf(\"accept:\");\n if (indx === 0) {\n const acceptHeaderValue = header.slice(indx + 7).trim();\n const acceptHeaderValues = acceptHeaderValue\n .split(\",\")\n .map((value: string) => value.trim());\n if (acceptHeaderValues.includes(acceptHeaderValueToCheck)) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n const normalizedHeaders = headers as OutgoingHttpHeaders;\n const acceptHeaderValue = Object.entries(normalizedHeaders).find(\n ([key]) => key.toLowerCase() === \"accept\",\n )?.[1];\n\n if (typeof acceptHeaderValue === \"string\") {\n return acceptHeaderValue === acceptHeaderValueToCheck;\n } else if (Array.isArray(acceptHeaderValue)) {\n return acceptHeaderValue.includes(acceptHeaderValueToCheck);\n } else {\n return false;\n }\n}\n\n/**\n * Downloads a file from a URL to a local path.\n * @param url The URL of the file to download.\n * @param downloadPath The local path to save the downloaded file.\n * @returns A promise that resolves when the download is complete.\n */\nexport async function downloadFile(\n url: string,\n downloadPath: string,\n): Promise<void> {\n return new Promise((resolve, reject) => {\n https\n .get(url, (response) => {\n // Handle redirects\n if (response.statusCode === 301 || response.statusCode === 302) {\n const redirectUrl = response.headers.location;\n if (redirectUrl) {\n downloadFile(redirectUrl, downloadPath).then(resolve).catch(reject);\n return;\n } else {\n reject(new Error(\"Redirect without location header\"));\n return;\n }\n }\n\n // Check for successful response\n if (response.statusCode !== 200) {\n reject(\n new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`),\n );\n return;\n }\n\n let downloadStream: fs.WriteStream;\n try {\n const downloadDir = path.dirname(downloadPath);\n if (!fs.existsSync(downloadDir)) {\n fs.mkdirSync(downloadDir, { recursive: true });\n }\n\n downloadStream = fs.createWriteStream(downloadPath);\n } catch (error) {\n reject(error);\n return;\n }\n\n // Handle stream errors\n downloadStream.on(\"error\", (error) => {\n reject(error);\n });\n\n // Pipe the response to the file stream\n response.pipe(downloadStream);\n\n // The whole response has been received and written\n downloadStream.on(\"finish\", () => {\n resolve();\n });\n })\n .on(\"error\", (error) => {\n reject(error); // Reject on request error\n });\n });\n}\n", "import { hostname, platform } from \"node:os\";\nimport type { AdoPatResponse } from \"../azureauth/ado.js\";\nimport { adoPat } from \"../azureauth/ado.js\";\nimport { toBase64 } from \"../utils/encoding.js\";\nimport { credentialProviderPat } from \"./nugetCredentialProvider.js\";\n\n/**\n * Generates a valid ADO PAT, scoped for vso.packaging in the given ado organization, 30 minute timeout\n * @returns { string } a valid ADO PAT\n */\nexport const generateNpmrcPat = async (\n organization: string,\n feed: string,\n encode = false,\n azureAuthLocation?: string,\n): Promise<string> => {\n const name = `${hostname()}-${organization}`;\n const rawToken = await getRawToken(\n name,\n organization,\n feed,\n azureAuthLocation,\n );\n\n if (encode) {\n return toBase64(rawToken);\n }\n\n return rawToken;\n};\n\nasync function getRawToken(\n name: string,\n organization: string,\n feed: string,\n azureAuthLocation?: string,\n): Promise<string> {\n /**\n * Use vso.packaging_write to include \"Collaborator\" (Feed and Upstream Reader) permissions.\n * vso.packaging only provides \"Reader\" access (view/download packages).\n * vso.packaging_write provides \"Contributor\" access (publish/promote/deprecate) which includes\n * Collaborator permissions (save packages from upstream sources).\n * Reference: https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth#available-scopes\n *\n * I filed feedback on VSO to add this: https://developercommunity.visualstudio.com/t/the-scope-for-vsopackaging-SHOULD-inclu/10998135\n */\n const patScope = \"vso.packaging_write\";\n\n switch (platform()) {\n case \"win32\":\n case \"darwin\": {\n const pat = await adoPat(\n {\n promptHint: `Authenticate to ${organization} to generate a temporary token for npm`,\n organization,\n displayName: name,\n scope: [patScope],\n timeout: \"30\",\n output: \"json\",\n },\n azureAuthLocation,\n );\n return (pat as AdoPatResponse).token;\n }\n case \"linux\": {\n const cpPat = await credentialProviderPat(feed);\n return cpPat.Password;\n }\n default:\n throw new Error(\n `Platform ${platform()} is not supported for ADO authentication`,\n );\n }\n}\n", "import { arch, platform } from \"node:os\";\nimport { spawnSync } from \"node:child_process\";\nimport { exec } from \"../utils/exec.js\";\nimport { isSupportedPlatformAndArchitecture } from \"./is-supported-platform-and-architecture.js\";\nimport { azureAuthCommand } from \"./azureauth-command.js\";\nimport { isWsl } from \"../utils/is-wsl.js\";\nimport { isAzureAuthInstalled } from \"./is-azureauth-installed.js\";\n\nexport type AdoPatOptions = {\n promptHint: string;\n organization: string;\n displayName: string;\n scope: string[];\n output?: string;\n mode?: string;\n domain?: string;\n timeout?: string;\n};\n\nexport type AdoPatResponse = {\n displayName: string;\n validTo: string;\n scope: string[];\n targetAccounts: string[];\n validFrom: string;\n authorizationId: string;\n token: string;\n};\n\n/**\n * Wrapper for `azureauth ado pat`. Please run `azureauth ado pat --help` for full command options and description\n * @param options Options for PAT generation\n * @returns ADO PAT details\n */\nexport const adoPat = async (\n options: AdoPatOptions,\n azureAuthLocation?: string,\n): Promise<AdoPatResponse | string> => {\n if (!isSupportedPlatformAndArchitecture()) {\n throw new Error(\n `AzureAuth is not supported for platform ${platform()} and architecture ${arch()}`,\n );\n }\n\n const { command: authCommand, env } = azureAuthLocation\n ? {\n command: [azureAuthLocation],\n env: process.env,\n }\n : azureAuthCommand();\n\n const command = [\n ...authCommand,\n `ado`,\n `pat`,\n `--prompt-hint ${isWsl() ? options.promptHint : `\"${options.promptHint}\"`}`, // We only use spawn for WSL. spawn does not does not require prompt hint to be wrapped in quotes. exec does.\n `--organization ${options.organization}`,\n `--display-name ${options.displayName}`,\n ...options.scope.map((scope) => `--scope ${scope}`),\n ];\n\n if (options.output) {\n command.push(`--output ${options.output}`);\n }\n\n if (options.mode) {\n command.push(`--mode ${options.mode}`);\n }\n\n if (options.domain) {\n command.push(`--domain ${options.domain}`);\n }\n\n if (options.timeout) {\n command.push(`--timeout ${options.timeout}`);\n }\n\n try {\n let result;\n if (isWsl()) {\n try {\n result = spawnSync(command[0], command.slice(1), { encoding: \"utf-8\" });\n\n if (result.status !== 0 || (result.stderr && !result.stdout)) {\n throw new Error(\n `Azure Auth failed with exit code ${result.status}: ${result.stderr}`,\n );\n }\n } catch (error: any) {\n throw new Error(\n `Failed to get Ado Pat from system AzureAuth: ${error.message}`,\n );\n }\n } else {\n try {\n result = await exec(command.join(\" \"), { env });\n\n if (result.stderr && !result.stdout) {\n throw new Error(result.stderr);\n }\n } catch (error: any) {\n throw new Error(\n `Failed to get Ado Pat from npx AzureAuth: ${error.message}`,\n );\n }\n }\n\n if (options.output === \"json\") {\n try {\n return JSON.parse(result.stdout) as AdoPatResponse;\n } catch {\n throw new Error(`Failed to parse JSON output: ${result.stdout}`);\n }\n }\n\n return result.stdout;\n } catch (error: any) {\n if (!(await isAzureAuthInstalled())) {\n throw new Error(`AzureAuth is not installed: ${error}`);\n }\n\n throw new Error(error.message);\n }\n};\n", "import { exec as _exec, spawn } from \"node:child_process\";\nimport { promisify } from \"node:util\";\n\nexport const exec = promisify(_exec);\n\n/**\n * Executes a command as a child process.\n * @param tool The command to run.\n * @param args The arguments to pass to the command.\n * @param options Options for the child process.\n * @returns A promise that resolves when the process exits.\n */\nexport function execProcess(\n tool: string,\n args: string[],\n options?: {\n cwd?: string;\n env?: Record<string, string>;\n stdio?: \"pipe\" | \"inherit\" | \"ignore\";\n shell?: boolean | string;\n processStdOut?: (data: string) => void;\n processStdErr?: (data: string) => void;\n },\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const cwd = options?.cwd || process.cwd();\n console.log(`🚀 Launching [${tool} ${args.join(\" \")}] in ${cwd}`);\n const result = spawn(tool, args, {\n cwd: cwd,\n env: options?.env || process.env,\n stdio: options?.stdio || \"inherit\",\n shell: options?.shell || false,\n });\n\n if (options?.stdio === \"pipe\") {\n result.stdout?.setEncoding(\"utf8\");\n result.stdout?.on(\"data\", function (data: Buffer) {\n const strData = data.toString(\"utf8\");\n options?.processStdOut?.(strData);\n });\n\n result.stderr?.setEncoding(\"utf8\");\n result.stderr?.on(\"data\", function (data: Buffer) {\n const strData = data.toString(\"utf8\");\n options?.processStdErr?.(strData);\n });\n }\n result.on(\"exit\", (code) => {\n if (code == 0) {\n resolve();\n } else {\n reject(new Error(`Process ${tool} exited with code ${code}`));\n }\n });\n });\n}\n", "import { arch, platform } from \"node:os\";\nimport { isWsl } from \"../utils/is-wsl.js\";\n\n/**\n * Determines if the currently running platform is supported by azureauth. Currently, supported platforms are Windows, Mac & WSL\n * @returns { boolean } if the current platform is supported by azureauth\n */\nexport const isSupportedPlatformAndArchitecture = (): boolean => {\n const supportedPlatformsAndArchitectures: Record<string, string[]> = {\n win32: [\"x64\"],\n darwin: [\"x64\", \"arm64\"],\n };\n\n return (\n isWsl() ||\n (supportedPlatformsAndArchitectures[platform()] &&\n supportedPlatformsAndArchitectures[platform()].includes(arch()))\n );\n};\n", "import { release, platform } from \"node:os\";\n\n/**\n * Determine if the current machine's platform is WSL\n * @returns { boolean } if the current platform is WSL\n */\nexport const isWsl = () => {\n return platform() === \"linux\" && release().toLowerCase().includes(\"wsl\");\n};\n", "import { isWsl } from \"../utils/is-wsl.js\";\n\nlet memo: string[] | undefined = undefined;\n\nexport const clearMemo = () => {\n memo = void 0;\n};\n\nconst npxAzureAuthCommand: string[] = [\n \"npm\",\n \"exec\",\n \"--silent\",\n \"--yes\",\n \"azureauth\",\n \"--\",\n];\nconst npxEnv = {\n ...process.env,\n // Use the version from the public registry to avoid a cycle\n npm_config_registry: \"https://registry.npmjs.org\",\n};\n\n/**\n * Get the executable path of azureauth command\n * @returns the string of the executable command to run azureauth, and any\n * necessary environment variables if using npx\n */\nexport const azureAuthCommand = (): {\n command: string[];\n env: Record<string, string>;\n} => {\n if (!memo) {\n memo = isWsl() ? [\"azureauth.exe\"] : npxAzureAuthCommand;\n }\n\n return { command: memo, env: npxEnv };\n};\n", "import { exec } from \"../utils/exec.js\";\nimport { azureAuthCommand } from \"./azureauth-command.js\";\n\nlet memo: boolean | undefined = undefined;\n\nexport const clearMemo = () => {\n memo = void 0;\n};\n\n/**\n * Determine if a valid version (>=0.8.0.0) is installed\n * @returns { boolean } Whether a valid version of azureauth is installed\n */\nexport const isAzureAuthInstalled = async (): Promise<boolean> => {\n if (memo === undefined) {\n const { command: authCommand, env } = azureAuthCommand();\n const command = `${authCommand.join(\" \")} --version`;\n\n try {\n const result = await exec(command, { env });\n // version must be >=0.8.0.0\n const [, minor] = result.stdout.split(\".\");\n memo = parseInt(minor) >= 8;\n } catch {\n // azureauth not installed\n memo = false;\n }\n }\n\n return memo;\n};\n", "import os from \"node:os\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { downloadFile } from \"../utils/request.js\";\nimport { execProcess } from \"../utils/exec.js\";\n\nconst CredentialProviderVersion = \"1.4.1\";\nconst OutputDir = path.resolve(\n \"..\",\n \".bin\",\n \"CredentialProvider.Microsoft\",\n \"v\" + CredentialProviderVersion,\n);\n\ntype CredentialProviderResponse = {\n Username: string;\n Password: string;\n};\n\nexport async function credentialProviderPat(\n registry: string,\n): Promise<CredentialProviderResponse> {\n const nugetFeedUrl = toNugetUrl(registry);\n const toolPath = await getCredentialProvider();\n return await invokeCredentialProvider(toolPath, nugetFeedUrl);\n}\n\nfunction toNugetUrl(registry: string): string {\n if (!registry.endsWith(\"/npm/registry/\")) {\n throw new Error(\n `Registry URL ${registry} is not a valid Azure Artifacts npm registry URL. Expected it to end with '/npm/registry/'`,\n );\n }\n return (\n \"https://\" + registry.replace(\"/npm/registry/\", \"/nuget/v3/index.json\")\n );\n}\n\nasync function invokeCredentialProvider(\n toolPath: string,\n nugetFeedUrl: string,\n): Promise<CredentialProviderResponse> {\n let response = \"\";\n await execProcess(toolPath, [\"-U\", nugetFeedUrl, \"-I\", \"-F\", \"Json\"], {\n stdio: \"pipe\",\n processStdOut: (data: string) => {\n response += data;\n },\n processStdErr: (data: string) => {\n console.error(data);\n },\n });\n try {\n const value = JSON.parse(response);\n return value as CredentialProviderResponse;\n } catch {\n throw new Error(`Failed to parse CredentialProvider output: ${response}`);\n }\n}\n\nfunction tryFileExists(executable: string): string | undefined {\n if (fs.existsSync(executable)) {\n return executable;\n } else if (fs.existsSync(executable + \".exe\")) {\n return executable + \".exe\";\n }\n return undefined;\n}\n\nasync function getCredentialProvider(): Promise<string> {\n let toolPath = tryFileExists(\n path.join(\n os.homedir(),\n \".nuget\",\n \"plugins\",\n \"netcore\",\n \"CredentialProvider.Microsoft\",\n \"CredentialProvider.Microsoft\",\n ),\n );\n if (toolPath) {\n return toolPath;\n }\n\n const downloadedFilePath = path.join(\n OutputDir,\n \"plugins\",\n \"netcore\",\n \"CredentialProvider.Microsoft\",\n \"CredentialProvider.Microsoft\",\n );\n toolPath = tryFileExists(downloadedFilePath);\n if (toolPath) {\n return toolPath;\n }\n\n await downloadCredentialProvider();\n toolPath = tryFileExists(downloadedFilePath);\n if (toolPath) {\n fs.chmodSync(toolPath, 0o755);\n } else {\n throw new Error(\n `CredentialProvider was not found at expected path after download: ${toolPath}`,\n );\n }\n\n return toolPath;\n}\n\nasync function downloadCredentialProvider(): Promise<void> {\n const downloadUrl = `https://github.com/microsoft/artifacts-credprovider/releases/download/v${CredentialProviderVersion}/Microsoft.Net8.${os.platform()}-${os.arch()}.NuGet.CredentialProvider.tar.gz`;\n const downloadPath = path.join(\n OutputDir,\n \"CredentialProvider.Microsoft.tar.gz\",\n );\n\n console.log(`🌐 Downloading ${downloadUrl}`);\n await downloadFile(downloadUrl, downloadPath);\n await execProcess(\"tar\", [\"-xzf\", downloadPath, \"-C\", OutputDir], {\n stdio: \"inherit\",\n });\n}\n", "import { type Configuration, type Plugin, SettingsType } from \"@yarnpkg/core\";\nimport { getConfigString } from \"./utils.ts\";\n\nexport type AuthPluginConfigurationValueMap = {\n adoNpmAuthToolPath?: string;\n adoNpmAuthFeedPrefix: string;\n};\n\nexport function getConfiguration() {\n return {\n adoNpmAuthToolPath: {\n description: `The path to the ADO authentication tool`,\n type: SettingsType.STRING,\n default: null,\n },\n adoNpmAuthFeedPrefix: {\n description: `The prefix to use for ADO NPM feed URLs`,\n type: SettingsType.STRING,\n default: `https://pkgs.dev.azure.com/`,\n },\n } as Plugin[\"configuration\"];\n}\n\nexport function loadConfiguration(\n configuration: Configuration,\n): AuthPluginConfigurationValueMap {\n return {\n adoNpmAuthToolPath: getConfigString(configuration, \"adoNpmAuthToolPath\"),\n adoNpmAuthFeedPrefix: getConfigString(\n configuration,\n \"adoNpmAuthFeedPrefix\",\n true,\n ),\n };\n}\n", "export function ifString(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nexport function asString(value: unknown): string {\n if (typeof value === \"string\") {\n return value;\n }\n throw new Error(`Expected a string but got: ${JSON.stringify(value)}`);\n}\n\nexport type MapLike = {\n get(key: string): unknown;\n};\n\nexport function getConfigString(\n config: MapLike | undefined,\n key: string,\n required: true,\n): string;\nexport function getConfigString(\n config: MapLike | undefined,\n key: string,\n required?: false,\n): string | undefined;\nexport function getConfigString(\n config: MapLike | undefined,\n key: string,\n required = false,\n): string | undefined {\n const value = config?.get(key);\n if (typeof value === \"string\") {\n return value;\n } else if (required) {\n throw new Error(`Expected configuration key \"${key}\" to be a string`);\n }\n return undefined;\n}\n\nexport function getConfigMap(\n config: MapLike | undefined,\n key: string,\n): MapLike | undefined {\n const value = config?.get(key);\n if (value && (value as MapLike).get !== undefined) {\n return value as MapLike;\n }\n return undefined;\n}\n", "import { type Configuration, type Ident } from \"@yarnpkg/core\";\nimport { TokenCache } from \"./tokenCache.ts\";\n\n/** not correctly exported so redefined here */\nexport type GetAuthHeaderOptions = {\n configuration: Configuration;\n ident?: Ident;\n};\n\n/**\n * Get the token for the given registry, using caching to avoid multiple calls, initializing\n * the cache on first use.\n */\nexport const getToken = (() => {\n let tokenCache: TokenCache | undefined = undefined;\n return (options: GetAuthHeaderOptions, registry: string) => {\n tokenCache ??= new TokenCache(options.configuration);\n return tokenCache.getToken(registry, options.ident);\n };\n})();\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;;;ACAA,MAAAA,eAKO;;;ACkBP,MAAM,oBAAoB,CAAC,QAAe;AACxC,QAAI;AACF,UAAI,CAAC,IAAI,WAAW,UAAU,GAAG;AAC/B,cAAM,aAAa;MACrB;AACA,YAAM,YAAY,IAAI,IAAI,GAAG;AAC7B,YAAMC,YAAW,UAAU;AAC3B,YAAM,WAAW,UAAU;AAG3B,UAAIA,UAAS,SAAS,eAAe,GAAG;AACtC,cAAM,eAAe,SAAS,MAAM,GAAG,EAAE,OAAO,OAAO;AACvD,YAAI,aAAa,UAAU,GAAG;AAC5B,iBAAO;YACL,cAAc,aAAa,CAAC;YAC5B,SAAS,aAAa,CAAC;;QAE3B,OAAO;AACL,gBAAM,IAAI,MACR,8EAA8E;QAElF;MACF;AAGA,UAAIA,UAAS,SAAS,kBAAkB,GAAG;AACzC,cAAM,YAAYA,UAAS,MAAM,GAAG,EAAE,CAAC;AACvC,cAAM,eAAe,SAAS,MAAM,GAAG,EAAE,OAAO,OAAO;AACvD,YAAI,aAAa,aAAa,U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L;AAAA,IACF;AAAA,EACF;AAGA,MAAO,iBAAQ;",
6
- "names": ["import_core", "hostname", "https", "path", "fs", "import_node_os", "import_node_os", "import_node_child_process", "_exec", "_a", "import_node_os", "memo", "memo", "import_node_os", "import_node_fs", "import_node_path", "path", "fs", "os", "import_node_child_process", "import_node_os", "pat", "os"]
4
+ "sourcesContent": ["import { type Plugin } from \"@yarnpkg/core\";\nimport { type GetAuthHeaderOptions, getToken } from \"./getToken.ts\";\nimport { getConfiguration } from \"./configuration.ts\";\n\n/**\n * Called when getting the authentication header for a request to the npm registry.\n * You can use this mechanism to dynamically query a CLI for the credentials for a\n * specific registry.\n */\nasync function getNpmAuthenticationHeader(\n currentHeader: string | undefined,\n registry: string,\n options: GetAuthHeaderOptions,\n): Promise<string | undefined> {\n const customToken = getToken(options, registry);\n if (customToken !== undefined) {\n const token =\n typeof customToken === \"string\" ? customToken : await customToken;\n return `Bearer ${token}`;\n }\n return currentHeader;\n}\n\n/**\n * The plugin definition.\n */\nconst plugin: Plugin = {\n /**\n * Add the plugin configuration options\n */\n configuration: getConfiguration(),\n\n /**\n * Add a hook to authenticate on demand with npm feeds\n */\n hooks: {\n getNpmAuthenticationHeader,\n },\n};\n\n// eslint-disable-next-line no-restricted-exports\nexport default plugin;\n", "import {\n type Configuration,\n type Ident,\n StreamReport,\n formatUtils,\n} from \"@yarnpkg/core\";\nimport {\n getOrganizationFromFeedUrl,\n generateNpmrcPat,\n} from \"@microsoft/ado-npm-auth-lib\";\nimport { loadConfiguration } from \"./configuration.ts\";\nimport { getConfigMap, getConfigString, type MapLike } from \"./utils.ts\";\nimport { spawnSync } from \"node:child_process\";\nimport os from \"node:os\";\n\n/**\n * A simple in-memory cache for tokens per registry. This will attempt to load tokens from the\n * existing settings first, and if not found, will use the ADO CLI to get a new token.\n */\nexport class TokenCache {\n private configuration: Configuration;\n private prefix: string;\n private azureAuthPath?: string;\n private cache: Record<string, string | Promise<string>> = {};\n\n constructor(\n configuration: Configuration,\n loadConfig: typeof loadConfiguration = loadConfiguration,\n ) {\n this.configuration = configuration;\n const settings = loadConfig(configuration);\n this.prefix = settings.adoNpmAuthFeedPrefix ?? \"\";\n this.azureAuthPath = settings.adoNpmAuthToolPath || findAzureAuthPath();\n }\n\n /**\n * Will return the token for the given registry, either from cache or by fetching a new one. If it is in\n * the cache already, it will return it directly. Otherwise it will return a promise that resolves to the token\n * @param registry the registry/feed that we need to authenticate against\n */\n getToken(\n registry: string,\n ident?: Ident,\n ): string | Promise<string> | undefined {\n if (!this.prefix || registry.startsWith(this.prefix)) {\n return (this.cache[registry] ??= this.fetchToken(registry, ident));\n }\n return undefined;\n }\n\n /**\n * Do the work to fetch a token for the given registry. This will attempt to get it from yarnrc/env first,\n * and if not found, will use the ADO CLI to get a new token.\n *\n * @param registry registry to authenticate to\n * @param ident optional ident, used for configuration lookups (yarn pass through)\n * @returns a promise that resolves to a string\n */\n private async fetchToken(registry: string, ident?: Ident): Promise<string> {\n const configuration = this.configuration;\n let token: string | null = null;\n\n await StreamReport.start(\n { configuration, stdout: process.stdout },\n async (report) => {\n const prettyRegistry = formatUtils.pretty(\n configuration,\n registry,\n formatUtils.Type.URL,\n );\n // first see if a token is set via .yarnrc, either hardcoded or via environment variable\n const authConfig = this.getAuthConfiguration(registry, ident);\n const tokenFromYarnrc = getConfigString(authConfig, \"npmAuthToken\");\n if (tokenFromYarnrc) {\n token = tokenFromYarnrc;\n this.cache[registry] = tokenFromYarnrc;\n report.reportInfo(\n null,\n `Authenticated to: ${prettyRegistry} (via configuration)`,\n );\n return;\n }\n\n const organization = getOrganizationFromFeedUrl(registry);\n if (!organization) {\n throw new Error(\n `Could not determine organization from registry URL: ${registry}`,\n );\n }\n\n const pat = await generateNpmrcPat(\n organization,\n registry,\n false,\n this.azureAuthPath,\n );\n token = pat;\n this.cache[registry] = pat;\n report.reportInfo(\n null,\n `Authenticated to: ${prettyRegistry} (via ADO CLI)`,\n );\n },\n );\n\n if (token == null) {\n throw new Error(`Failed to authenticate to: ${registry}`);\n }\n return token;\n }\n\n /**\n * Get the authentication configuration for the given registry and ident. This code was\n * taken from Yarn's npm plugin to match their logic. Importing that package directly results in\n * a massive bundle, so extracted just this logic.\n */\n private getAuthConfiguration(registry: string, ident?: Ident): MapLike {\n const scopeConfiguration = ident && this.getScopeConfiguration(ident.scope);\n\n if (scopeConfiguration?.get(`npmAuthToken`)) {\n return scopeConfiguration;\n }\n\n const registryConfiguration = this.getRegistryConfiguration(registry);\n\n return registryConfiguration ?? this.configuration;\n }\n\n /**\n * Return the auth configuration for the given scope if one has been set\n * @param scope package scope to use for lookups\n */\n private getScopeConfiguration(scope: string | null): MapLike | null {\n if (scope != null) {\n const scopeConfigurations = getConfigMap(this.configuration, `npmScopes`);\n const scopeConfiguration = getConfigMap(scopeConfigurations, scope);\n if (scopeConfiguration) {\n return scopeConfiguration;\n }\n }\n return null;\n }\n\n /**\n * Return the auth configuration for the given registry if one has been set\n * @param registry registry to get configuration for\n */\n private getRegistryConfiguration(registry: string): MapLike | null {\n // get the npmRegistries configuration map\n const registryConfigurations = getConfigMap(\n this.configuration,\n `npmRegistries`,\n );\n // normalize the registry url for lookups, same as yarn does internally\n const normalizedRegistry = registry.replace(/\\/$/, ``);\n\n // first try to get an exact match\n const exactEntry = getConfigMap(registryConfigurations, normalizedRegistry);\n if (typeof exactEntry !== `undefined`) {\n return exactEntry;\n }\n\n // then try without protocol\n const noProtocolEntry = getConfigMap(\n registryConfigurations,\n normalizedRegistry.replace(/^[a-z]+:/, ``),\n );\n\n return noProtocolEntry ?? null;\n }\n}\n\nfunction findAzureAuthPath(): string | undefined {\n const isWin = os.platform() === \"win32\";\n const execName = isWin ? \"azureauth.exe\" : \"azureauth\";\n const cmd = isWin ? \"where\" : \"which\";\n\n try {\n const result = spawnSync(cmd, [execName], { encoding: \"utf-8\" });\n if (result.status === 0 && result.stdout) {\n const line = result.stdout.split(/\\r?\\n/).find(Boolean);\n return line ? line.trim() : undefined;\n }\n } catch {\n // Ignore errors, fall through to undefined\n }\n\n return undefined;\n}\n", "/**\n * Extracts the organization and project details from a given Azure DevOps URL.\n * The function differentiates between the \"new style\" URLs that use 'dev.azure.com'\n * and \"old style\" URLs that use a subdomain of 'visualstudio.com'.\n *\n * @param {string} url - The Azure DevOps URL from which to extract details.\n * @returns {Object} An object containing the `organization` and `project` extracted from the URL.\n * @throws {Error} Throws an error if the URL is invalid, not in the expected format,\n * or does not contain the necessary information for extraction.\n *\n * @example\n * // New style URL\n * extractAdoDetails(\"https://dev.azure.com/contoso/WebsiteRedesign\");\n * // returns { organization: \"contoso\", project: \"WebsiteRedesign\" }\n *\n * // Old style URL\n * extractAdoDetails(\"https://contoso.visualstudio.com/WebsiteRedesign\");\n * // returns { organization: \"contoso\", project: \"WebsiteRedesign\" }\n *\n * // Invalid URL\n * extractAdoDetails(\"https://invalid.url.com\");\n * // throws Error\n */\nconst extractAdoDetails = (url: string) => {\n try {\n if (!url.startsWith(\"https://\")) {\n url = \"https://\" + url;\n }\n const parsedUrl = new URL(url);\n const hostname = parsedUrl.hostname;\n const pathname = parsedUrl.pathname;\n\n // Check for new style URLs (dev.azure.com)\n if (hostname.endsWith(\"dev.azure.com\")) {\n const pathSegments = pathname.split(\"/\").filter(Boolean); // Remove empty strings from the split result\n if (pathSegments.length >= 2) {\n return {\n organization: pathSegments[0],\n project: pathSegments[1],\n };\n } else {\n throw new Error(\n \"Not enough segments in path for a valid organization and project extraction.\",\n );\n }\n }\n\n // Check for old style URLs (visualstudio.com)\n if (hostname.endsWith(\"visualstudio.com\")) {\n const subdomain = hostname.split(\".\")[0];\n const pathSegments = pathname.split(\"/\").filter(Boolean);\n if (subdomain && pathSegments.length >= 1) {\n return {\n organization: subdomain,\n project: pathSegments[0],\n };\n } else {\n throw new Error(\n \"Not enough segments in path or missing subdomain for a valid organization and project extraction.\",\n );\n }\n }\n\n // If the URL does not match expected formats\n throw new Error(\n \"URL format not recognized or does not contain enough information.\",\n );\n } catch {\n throw new Error(\"Invalid URL or unsupported format\");\n }\n};\n\n/**\n * Get the ADO Org for a npm feed\n * @param {string} feedUrl URL of the feed to get the ADO organization from\n * @param {string} [defaultOrg] Backup org in case it cannot be determined from the feed url\n * @returns ADO Organization for the feed\n */\nexport const getOrganizationFromFeedUrl = (\n feedUrl: string,\n defaultOrg = \"\",\n) => {\n try {\n const { organization } = extractAdoDetails(feedUrl);\n return organization;\n } catch {\n return defaultOrg;\n }\n};\n", "/**\n * Create a base64 encoded string from a string\n * @param {string} input\n * @returns {string}\n */\nexport function toBase64(input: string | undefined): string {\n return Buffer.from(input || \"\").toString(\"base64\");\n}\n\n/**\n * Decode a base64 encoded string\n * @param {string} base64string\n * @returns\n */\nexport const fromBase64 = (base64string: string) =>\n Buffer.from(base64string, \"base64\").toString(\"utf8\");\n", "import https, { type RequestOptions } from \"node:https\";\nimport type { OutgoingHttpHeaders } from \"node:http\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nconst defaultOptions: RequestOptions = {\n port: 443,\n method: \"GET\",\n};\n\n/**\n *\n * @param {import(\"http\").RequestOptions} options\n * @returns\n */\nexport const makeRequest = async (options: RequestOptions) => {\n return new Promise((resolve, reject) => {\n const mergedOptions = {\n ...defaultOptions,\n ...options,\n };\n\n const req = https.request(mergedOptions, (res) => {\n let data = \"\";\n let dataJson = {};\n const ok = res.statusCode === 200;\n\n res.on(\"data\", (d) => {\n data += d;\n });\n\n res.on(\"end\", () => {\n if (\n data &&\n hasAcceptHeaderValue(mergedOptions?.headers, \"application/json\")\n ) {\n dataJson = JSON.parse(data.toString().trim());\n }\n\n if (ok) {\n resolve(dataJson || data);\n } else {\n if (dataJson) {\n dataJson = { ...dataJson, statusCode: res.statusCode };\n }\n reject(\n dataJson || data || new Error(`Error code: ${res.statusCode}.`),\n );\n }\n });\n\n res.on(\"error\", (/** @type {string} */ error) => {\n reject(new Error(error as any));\n });\n });\n\n req.end();\n });\n};\n\nfunction hasAcceptHeaderValue(\n headers: OutgoingHttpHeaders | readonly string[] | undefined,\n acceptHeaderValueToCheck: string,\n): boolean {\n if (!headers) {\n return false;\n }\n\n if (Array.isArray(headers)) {\n for (const header of headers) {\n const indx = header.toLowerCase().indexOf(\"accept:\");\n if (indx === 0) {\n const acceptHeaderValue = header.slice(indx + 7).trim();\n const acceptHeaderValues = acceptHeaderValue\n .split(\",\")\n .map((value: string) => value.trim());\n if (acceptHeaderValues.includes(acceptHeaderValueToCheck)) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n const normalizedHeaders = headers as OutgoingHttpHeaders;\n const acceptHeaderValue = Object.entries(normalizedHeaders).find(\n ([key]) => key.toLowerCase() === \"accept\",\n )?.[1];\n\n if (typeof acceptHeaderValue === \"string\") {\n return acceptHeaderValue === acceptHeaderValueToCheck;\n } else if (Array.isArray(acceptHeaderValue)) {\n return acceptHeaderValue.includes(acceptHeaderValueToCheck);\n } else {\n return false;\n }\n}\n\n/**\n * Downloads a file from a URL to a local path.\n * @param url The URL of the file to download.\n * @param downloadPath The local path to save the downloaded file.\n * @returns A promise that resolves when the download is complete.\n */\nexport async function downloadFile(\n url: string,\n downloadPath: string,\n): Promise<void> {\n return new Promise((resolve, reject) => {\n https\n .get(url, (response) => {\n // Handle redirects\n if (response.statusCode === 301 || response.statusCode === 302) {\n const redirectUrl = response.headers.location;\n if (redirectUrl) {\n downloadFile(redirectUrl, downloadPath).then(resolve).catch(reject);\n return;\n } else {\n reject(new Error(\"Redirect without location header\"));\n return;\n }\n }\n\n // Check for successful response\n if (response.statusCode !== 200) {\n reject(\n new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`),\n );\n return;\n }\n\n let downloadStream: fs.WriteStream;\n try {\n const downloadDir = path.dirname(downloadPath);\n if (!fs.existsSync(downloadDir)) {\n fs.mkdirSync(downloadDir, { recursive: true });\n }\n\n downloadStream = fs.createWriteStream(downloadPath);\n } catch (error) {\n reject(error);\n return;\n }\n\n // Handle stream errors\n downloadStream.on(\"error\", (error) => {\n reject(error);\n });\n\n // Pipe the response to the file stream\n response.pipe(downloadStream);\n\n // The whole response has been received and written\n downloadStream.on(\"finish\", () => {\n resolve();\n });\n })\n .on(\"error\", (error) => {\n reject(error); // Reject on request error\n });\n });\n}\n", "import { hostname, platform } from \"node:os\";\nimport type { AdoPatResponse } from \"../azureauth/ado.js\";\nimport { adoPat } from \"../azureauth/ado.js\";\nimport { toBase64 } from \"../utils/encoding.js\";\nimport { credentialProviderPat } from \"./nugetCredentialProvider.js\";\n\n/**\n * Generates a valid ADO PAT, scoped for vso.packaging in the given ado organization, 30 minute timeout\n * @returns { string } a valid ADO PAT\n */\nexport const generateNpmrcPat = async (\n organization: string,\n feed: string,\n encode = false,\n azureAuthLocation?: string,\n): Promise<string> => {\n const name = `${hostname()}-${organization}`;\n const rawToken = await getRawToken(\n name,\n organization,\n feed,\n azureAuthLocation,\n );\n\n if (encode) {\n return toBase64(rawToken);\n }\n\n return rawToken;\n};\n\nasync function getRawToken(\n name: string,\n organization: string,\n feed: string,\n azureAuthLocation?: string,\n): Promise<string> {\n /**\n * Use vso.packaging_write to include \"Collaborator\" (Feed and Upstream Reader) permissions.\n * vso.packaging only provides \"Reader\" access (view/download packages).\n * vso.packaging_write provides \"Contributor\" access (publish/promote/deprecate) which includes\n * Collaborator permissions (save packages from upstream sources).\n * Reference: https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth#available-scopes\n *\n * I filed feedback on VSO to add this: https://developercommunity.visualstudio.com/t/the-scope-for-vsopackaging-SHOULD-inclu/10998135\n */\n const patScope = \"vso.packaging_write\";\n\n switch (platform()) {\n case \"win32\":\n case \"darwin\": {\n const pat = await adoPat(\n {\n promptHint: `Authenticate to ${organization} to generate a temporary token for npm`,\n organization,\n displayName: name,\n scope: [patScope],\n timeout: \"30\",\n output: \"json\",\n },\n azureAuthLocation,\n );\n return (pat as AdoPatResponse).token;\n }\n case \"linux\": {\n const cpPat = await credentialProviderPat(feed);\n return cpPat.Password;\n }\n default:\n throw new Error(\n `Platform ${platform()} is not supported for ADO authentication`,\n );\n }\n}\n", "import { arch, platform } from \"node:os\";\nimport { spawnSync } from \"node:child_process\";\nimport { exec } from \"../utils/exec.js\";\nimport { isSupportedPlatformAndArchitecture } from \"./is-supported-platform-and-architecture.js\";\nimport { azureAuthCommand } from \"./azureauth-command.js\";\nimport { isWsl } from \"../utils/is-wsl.js\";\nimport { isAzureAuthInstalled } from \"./is-azureauth-installed.js\";\n\nexport type AdoPatOptions = {\n promptHint: string;\n organization: string;\n displayName: string;\n scope: string[];\n output?: string;\n mode?: string;\n domain?: string;\n timeout?: string;\n};\n\nexport type AdoPatResponse = {\n displayName: string;\n validTo: string;\n scope: string[];\n targetAccounts: string[];\n validFrom: string;\n authorizationId: string;\n token: string;\n};\n\n/**\n * Wrapper for `azureauth ado pat`. Please run `azureauth ado pat --help` for full command options and description\n * @param options Options for PAT generation\n * @returns ADO PAT details\n */\nexport const adoPat = async (\n options: AdoPatOptions,\n azureAuthLocation?: string,\n): Promise<AdoPatResponse | string> => {\n if (!isSupportedPlatformAndArchitecture()) {\n throw new Error(\n `AzureAuth is not supported for platform ${platform()} and architecture ${arch()}`,\n );\n }\n\n const { command: authCommand, env } = azureAuthLocation\n ? {\n command: [azureAuthLocation],\n env: process.env,\n }\n : azureAuthCommand();\n\n const command = [\n ...authCommand,\n `ado`,\n `pat`,\n `--prompt-hint ${isWsl() ? options.promptHint : `\"${options.promptHint}\"`}`, // We only use spawn for WSL. spawn does not does not require prompt hint to be wrapped in quotes. exec does.\n `--organization ${options.organization}`,\n `--display-name ${options.displayName}`,\n ...options.scope.map((scope) => `--scope ${scope}`),\n ];\n\n if (options.output) {\n command.push(`--output ${options.output}`);\n }\n\n if (options.mode) {\n command.push(`--mode ${options.mode}`);\n }\n\n if (options.domain) {\n command.push(`--domain ${options.domain}`);\n }\n\n if (options.timeout) {\n command.push(`--timeout ${options.timeout}`);\n }\n\n try {\n let result;\n if (isWsl()) {\n try {\n result = spawnSync(command[0], command.slice(1), { encoding: \"utf-8\" });\n\n if (result.status !== 0 || (result.stderr && !result.stdout)) {\n throw new Error(\n `Azure Auth failed with exit code ${result.status}: ${result.stderr}`,\n );\n }\n } catch (error: any) {\n throw new Error(\n `Failed to get Ado Pat from system AzureAuth: ${error.message}`,\n );\n }\n } else {\n try {\n result = await exec(command.join(\" \"), { env });\n\n if (result.stderr && !result.stdout) {\n throw new Error(result.stderr);\n }\n } catch (error: any) {\n throw new Error(\n `Failed to get Ado Pat from npx AzureAuth: ${error.message}`,\n );\n }\n }\n\n if (options.output === \"json\") {\n try {\n return JSON.parse(result.stdout) as AdoPatResponse;\n } catch {\n throw new Error(`Failed to parse JSON output: ${result.stdout}`);\n }\n }\n\n return result.stdout;\n } catch (error: any) {\n if (!(await isAzureAuthInstalled())) {\n throw new Error(`AzureAuth is not installed: ${error}`);\n }\n\n throw new Error(error.message);\n }\n};\n", "import { exec as _exec, spawn } from \"node:child_process\";\nimport { promisify } from \"node:util\";\n\nexport const exec = promisify(_exec);\n\n/**\n * Executes a command as a child process.\n * @param tool The command to run.\n * @param args The arguments to pass to the command.\n * @param options Options for the child process.\n * @returns A promise that resolves when the process exits.\n */\nexport function execProcess(\n tool: string,\n args: string[],\n options?: {\n cwd?: string;\n env?: Record<string, string>;\n stdio?: \"pipe\" | \"inherit\" | \"ignore\";\n shell?: boolean | string;\n processStdOut?: (data: string) => void;\n processStdErr?: (data: string) => void;\n },\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const cwd = options?.cwd || process.cwd();\n console.log(`🚀 Launching [${tool} ${args.join(\" \")}] in ${cwd}`);\n const result = spawn(tool, args, {\n cwd: cwd,\n env: options?.env || process.env,\n stdio: options?.stdio || \"inherit\",\n shell: options?.shell || false,\n });\n\n if (options?.stdio === \"pipe\") {\n result.stdout?.setEncoding(\"utf8\");\n result.stdout?.on(\"data\", function (data: Buffer) {\n const strData = data.toString(\"utf8\");\n options?.processStdOut?.(strData);\n });\n\n result.stderr?.setEncoding(\"utf8\");\n result.stderr?.on(\"data\", function (data: Buffer) {\n const strData = data.toString(\"utf8\");\n options?.processStdErr?.(strData);\n });\n }\n result.on(\"exit\", (code) => {\n if (code == 0) {\n resolve();\n } else {\n reject(new Error(`Process ${tool} exited with code ${code}`));\n }\n });\n });\n}\n", "import { arch, platform } from \"node:os\";\nimport { isWsl } from \"../utils/is-wsl.js\";\n\n/**\n * Determines if the currently running platform is supported by azureauth. Currently, supported platforms are Windows, Mac & WSL\n * @returns { boolean } if the current platform is supported by azureauth\n */\nexport const isSupportedPlatformAndArchitecture = (): boolean => {\n const supportedPlatformsAndArchitectures: Record<string, string[]> = {\n win32: [\"x64\"],\n darwin: [\"x64\", \"arm64\"],\n };\n\n return (\n isWsl() ||\n (supportedPlatformsAndArchitectures[platform()] &&\n supportedPlatformsAndArchitectures[platform()].includes(arch()))\n );\n};\n", "import { release, platform } from \"node:os\";\n\n/**\n * Determine if the current machine's platform is WSL\n * @returns { boolean } if the current platform is WSL\n */\nexport const isWsl = () => {\n return platform() === \"linux\" && release().toLowerCase().includes(\"wsl\");\n};\n", "import { isWsl } from \"../utils/is-wsl.js\";\n\nlet memo: string[] | undefined = undefined;\n\nexport const clearMemo = () => {\n memo = void 0;\n};\n\nconst npxAzureAuthCommand: string[] = [\n \"npm\",\n \"exec\",\n \"--silent\",\n \"--yes\",\n \"azureauth\",\n \"--\",\n];\nconst npxEnv = {\n ...process.env,\n // Use the version from the public registry to avoid a cycle\n npm_config_registry: \"https://registry.npmjs.org\",\n};\n\n/**\n * Get the executable path of azureauth command\n * @returns the string of the executable command to run azureauth, and any\n * necessary environment variables if using npx\n */\nexport const azureAuthCommand = (): {\n command: string[];\n env: Record<string, string>;\n} => {\n if (!memo) {\n memo = isWsl() ? [\"azureauth.exe\"] : npxAzureAuthCommand;\n }\n\n return { command: memo, env: npxEnv };\n};\n", "import { exec } from \"../utils/exec.js\";\nimport { azureAuthCommand } from \"./azureauth-command.js\";\n\nlet memo: boolean | undefined = undefined;\n\nexport const clearMemo = () => {\n memo = void 0;\n};\n\n/**\n * Determine if a valid version (>=0.8.0.0) is installed\n * @returns { boolean } Whether a valid version of azureauth is installed\n */\nexport const isAzureAuthInstalled = async (): Promise<boolean> => {\n if (memo === undefined) {\n const { command: authCommand, env } = azureAuthCommand();\n const command = `${authCommand.join(\" \")} --version`;\n\n try {\n const result = await exec(command, { env });\n // version must be >=0.8.0.0\n const [, minor] = result.stdout.split(\".\");\n memo = parseInt(minor) >= 8;\n } catch {\n // azureauth not installed\n memo = false;\n }\n }\n\n return memo;\n};\n", "import os from \"node:os\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { downloadFile } from \"../utils/request.js\";\nimport { execProcess } from \"../utils/exec.js\";\n\nconst CredentialProviderVersion = \"1.4.1\";\nconst OutputDir = path.resolve(\n \"..\",\n \".bin\",\n \"CredentialProvider.Microsoft\",\n \"v\" + CredentialProviderVersion,\n);\n\ntype CredentialProviderResponse = {\n Username: string;\n Password: string;\n};\n\nexport async function credentialProviderPat(\n registry: string,\n): Promise<CredentialProviderResponse> {\n const nugetFeedUrl = toNugetUrl(registry);\n const toolPath = await getCredentialProvider();\n return await invokeCredentialProvider(toolPath, nugetFeedUrl);\n}\n\nfunction toNugetUrl(registry: string): string {\n // Yarn 4 normalizes registry URLs by stripping the trailing slash before\n // invoking auth hooks, so accept the URL with or without it.\n const normalized = registry.endsWith(\"/\") ? registry : registry + \"/\";\n if (!normalized.endsWith(\"/npm/registry/\")) {\n throw new Error(\n `Registry URL ${registry} is not a valid Azure Artifacts npm registry URL. Expected it to end with '/npm/registry/'`,\n );\n }\n const nugetPath = normalized.replace(\n \"/npm/registry/\",\n \"/nuget/v3/index.json\",\n );\n // Tolerate scheme-less inputs (e.g. older callers) by prepending https://\n // when no scheme is present. Yarn 4 always supplies a scheme, but the\n // function signature accepts any string.\n return /^[a-z]+:\\/\\//i.test(nugetPath) ? nugetPath : \"https://\" + nugetPath;\n}\n\nasync function invokeCredentialProvider(\n toolPath: string,\n nugetFeedUrl: string,\n): Promise<CredentialProviderResponse> {\n let response = \"\";\n await execProcess(toolPath, [\"-U\", nugetFeedUrl, \"-I\", \"-F\", \"Json\"], {\n stdio: \"pipe\",\n processStdOut: (data: string) => {\n response += data;\n },\n processStdErr: (data: string) => {\n console.error(data);\n },\n });\n try {\n const value = JSON.parse(response);\n return value as CredentialProviderResponse;\n } catch {\n throw new Error(`Failed to parse CredentialProvider output: ${response}`);\n }\n}\n\nfunction tryFileExists(executable: string): string | undefined {\n if (fs.existsSync(executable)) {\n return executable;\n } else if (fs.existsSync(executable + \".exe\")) {\n return executable + \".exe\";\n }\n return undefined;\n}\n\nasync function getCredentialProvider(): Promise<string> {\n let toolPath = tryFileExists(\n path.join(\n os.homedir(),\n \".nuget\",\n \"plugins\",\n \"netcore\",\n \"CredentialProvider.Microsoft\",\n \"CredentialProvider.Microsoft\",\n ),\n );\n if (toolPath) {\n return toolPath;\n }\n\n const downloadedFilePath = path.join(\n OutputDir,\n \"plugins\",\n \"netcore\",\n \"CredentialProvider.Microsoft\",\n \"CredentialProvider.Microsoft\",\n );\n toolPath = tryFileExists(downloadedFilePath);\n if (toolPath) {\n return toolPath;\n }\n\n await downloadCredentialProvider();\n toolPath = tryFileExists(downloadedFilePath);\n if (toolPath) {\n fs.chmodSync(toolPath, 0o755);\n } else {\n throw new Error(\n `CredentialProvider was not found at expected path after download: ${toolPath}`,\n );\n }\n\n return toolPath;\n}\n\nasync function downloadCredentialProvider(): Promise<void> {\n const downloadUrl = `https://github.com/microsoft/artifacts-credprovider/releases/download/v${CredentialProviderVersion}/Microsoft.Net8.${os.platform()}-${os.arch()}.NuGet.CredentialProvider.tar.gz`;\n const downloadPath = path.join(\n OutputDir,\n \"CredentialProvider.Microsoft.tar.gz\",\n );\n\n console.log(`🌐 Downloading ${downloadUrl}`);\n await downloadFile(downloadUrl, downloadPath);\n await execProcess(\"tar\", [\"-xzf\", downloadPath, \"-C\", OutputDir], {\n stdio: \"inherit\",\n });\n}\n", "import { type Configuration, type Plugin, SettingsType } from \"@yarnpkg/core\";\nimport { getConfigString } from \"./utils.ts\";\n\nexport type AuthPluginConfigurationValueMap = {\n adoNpmAuthToolPath?: string;\n adoNpmAuthFeedPrefix: string;\n};\n\nexport function getConfiguration() {\n return {\n adoNpmAuthToolPath: {\n description: `The path to the ADO authentication tool`,\n type: SettingsType.STRING,\n default: null,\n },\n adoNpmAuthFeedPrefix: {\n description: `The prefix to use for ADO NPM feed URLs`,\n type: SettingsType.STRING,\n default: `https://pkgs.dev.azure.com/`,\n },\n } as Plugin[\"configuration\"];\n}\n\nexport function loadConfiguration(\n configuration: Configuration,\n): AuthPluginConfigurationValueMap {\n return {\n adoNpmAuthToolPath: getConfigString(configuration, \"adoNpmAuthToolPath\"),\n adoNpmAuthFeedPrefix: getConfigString(\n configuration,\n \"adoNpmAuthFeedPrefix\",\n true,\n ),\n };\n}\n", "export function ifString(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nexport function asString(value: unknown): string {\n if (typeof value === \"string\") {\n return value;\n }\n throw new Error(`Expected a string but got: ${JSON.stringify(value)}`);\n}\n\nexport type MapLike = {\n get(key: string): unknown;\n};\n\nexport function getConfigString(\n config: MapLike | undefined,\n key: string,\n required: true,\n): string;\nexport function getConfigString(\n config: MapLike | undefined,\n key: string,\n required?: false,\n): string | undefined;\nexport function getConfigString(\n config: MapLike | undefined,\n key: string,\n required = false,\n): string | undefined {\n const value = config?.get(key);\n if (typeof value === \"string\") {\n return value;\n } else if (required) {\n throw new Error(`Expected configuration key \"${key}\" to be a string`);\n }\n return undefined;\n}\n\nexport function getConfigMap(\n config: MapLike | undefined,\n key: string,\n): MapLike | undefined {\n const value = config?.get(key);\n if (value && (value as MapLike).get !== undefined) {\n return value as MapLike;\n }\n return undefined;\n}\n", "import { type Configuration, type Ident } from \"@yarnpkg/core\";\nimport { TokenCache } from \"./tokenCache.ts\";\n\n/** not correctly exported so redefined here */\nexport type GetAuthHeaderOptions = {\n configuration: Configuration;\n ident?: Ident;\n};\n\n/**\n * Get the token for the given registry, using caching to avoid multiple calls, initializing\n * the cache on first use.\n */\nexport const getToken = (() => {\n let tokenCache: TokenCache | undefined = undefined;\n return (options: GetAuthHeaderOptions, registry: string) => {\n tokenCache ??= new TokenCache(options.configuration);\n return tokenCache.getToken(registry, options.ident);\n };\n})();\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;;;ACAA,MAAAA,eAKO;;;ACkBP,MAAM,oBAAoB,CAAC,QAAe;AACxC,QAAI;AACF,UAAI,CAAC,IAAI,WAAW,UAAU,GAAG;AAC/B,cAAM,aAAa;MACrB;AACA,YAAM,YAAY,IAAI,IAAI,GAAG;AAC7B,YAAMC,YAAW,UAAU;AAC3B,YAAM,WAAW,UAAU;AAG3B,UAAIA,UAAS,SAAS,eAAe,GAAG;AACtC,cAAM,eAAe,SAAS,MAAM,GAAG,EAAE,OAAO,OAAO;AACvD,YAAI,aAAa,UAAU,GAAG;AAC5B,iBAAO;YACL,cAAc,aAAa,CAAC;YAC5B,SAAS,aAAa,CAAC;;QAE3B,OAAO;AACL,gBAAM,IAAI,MACR,8EAA8E;QAElF;MACF;AAGA,UAAIA,UAAS,SAAS,kBAAkB,GAAG;AACzC,cAAM,YAAYA,UAAS,MAAM,GAAG,EAAE,CAAC;AACvC,cAAM,eAAe,SAAS,MAAM,GAAG,EAAE,OAAO,OAAO;AACvD,YAAI,aAAa,aAAa,UAAU,GAAG;AACzC,iBAAO;YACL,cAAc;YACd,SAAS,aAAa,CAAC;;QAE3B,OAAO;AACL,gBAAM,IAAI,MACR,mGAAmG;QAEvG;MACF;AAGA,YAAM,IAAI,MACR,mEAAmE;IAEvE,QAAQ;AACN,YAAM,IAAI,MAAM,mCAAmC;IACrD;EACF;AAQO,MAAM,6BAA6B,CACxC,SACA,aAAa,OACX;AACF,QAAI;AACF,YAAM,EAAE,aAAY,IAAK,kBAAkB,OAAO;AAClD,aAAO;IACT,QAAQ;A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,YAAY,EAAE;AAAA,MAC3C;AAEA,aAAO,mBAAmB;AAAA,IAC5B;AAAA,EACF;AAEA,WAAS,oBAAwC;AAC/C,UAAM,QAAQ,gBAAAC,QAAG,SAAS,MAAM;AAChC,UAAM,WAAW,QAAQ,kBAAkB;AAC3C,UAAM,MAAM,QAAQ,UAAU;AAE9B,QAAI;AACF,YAAM,aAAS,sCAAU,KAAK,CAAC,QAAQ,GAAG,EAAE,UAAU,QAAQ,CAAC;AAC/D,UAAI,OAAO,WAAW,KAAK,OAAO,QAAQ;AACxC,cAAM,OAAO,OAAO,OAAO,MAAM,OAAO,EAAE,KAAK,OAAO;AACtD,eAAO,OAAO,KAAK,KAAK,IAAI;AAAA,MAC9B;AAAA,IACF,QAAQ;AAAA,IAER;AAEA,WAAO;AAAA,EACT;;;Ac/KO,MAAM,WAAY,uBAAM;AAC7B,QAAI,aAAqC;AACzC,WAAO,CAAC,SAA+B,aAAqB;AAC1D,qBAAe,IAAI,WAAW,QAAQ,aAAa;AACnD,aAAO,WAAW,SAAS,UAAU,QAAQ,KAAK;AAAA,IACpD;AAAA,EACF,GAAG;;;AfVH,iBAAe,2BACb,eACA,UACA,SAC6B;AAC7B,UAAM,cAAc,SAAS,SAAS,QAAQ;AAC9C,QAAI,gBAAgB,QAAW;AAC7B,YAAM,QACJ,OAAO,gBAAgB,WAAW,cAAc,MAAM;AACxD,aAAO,UAAU,KAAK;AAAA,IACxB;AACA,WAAO;AAAA,EACT;AAKA,MAAM,SAAiB;AAAA;AAAA;AAAA;AAAA,IAIrB,eAAe,iBAAiB;AAAA;AAAA;AAAA;AAAA,IAKhC,OAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAGA,MAAO,iBAAQ;",
6
+ "names": ["import_core", "hostname", "https", "path", "fs", "import_node_os", "import_node_os", "import_node_child_process", "_exec", "_a", "import_node_os", "memo", "memo", "import_node_os", "import_node_fs", "import_node_path", "path", "fs", "os", "import_node_child_process", "import_node_os", "os"]
7
7
  }