Subversion Simple Auth Provider

1.3.5 · active · verified Wed Apr 22

The `svn-simple-auth-provider` package offers a Node.js-based solution for programmatically accessing credentials stored in Subversion's 'simple' authentication files. These files, typically located in `~/.subversion/auth/simple`, contain plaintext username and password pairs for various SVN realms. The library, currently at version 1.3.5, provides a `SvnSimpleAuthProvider` class to read and retrieve these stored credentials. Its release cadence is irregular, primarily focusing on dependency updates and minor bug fixes. A key differentiator is its direct parsing of the SVN simple auth file format, allowing integration into applications that need to interact with SVN repositories using stored credentials without invoking external SVN client commands. It requires Node.js version 16.20.2 or higher.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to instantiate `SvnSimpleAuthProvider` and retrieve credentials for a specific SVN realm and URL. It highlights configuring the `realmDirectory` and handling potential missing credentials.

import { SvnSimpleAuthProvider } from 'svn-simple-auth-provider';
import path from 'path';
import os from 'os';

async function getSvnCredentials() {
  // Define a dummy realm directory for demonstration. In a real scenario,
  // this would be the actual SVN auth directory, e.g., ~/.subversion/auth/simple.
  // For a quick test, you might point it to a directory with a dummy auth file.
  const realmDirectory = path.join(os.homedir(), '.subversion', 'auth', 'simple');

  const provider = new SvnSimpleAuthProvider({
    realmDirectory: realmDirectory
  });

  // Example: Attempt to retrieve credentials for a specific realm and URL.
  // Replace with actual realm and URL from your SVN configuration.
  const exampleRealm = 'svn.example.com:443'; // The realm as it appears in the auth file
  const exampleUrl = 'https://svn.example.com/repo/trunk'; // The URL used to identify the realm

  try {
    console.log(`Attempting to retrieve credentials for realm '${exampleRealm}' from ${realmDirectory}...`);
    const credentials = await provider.getCredentials(exampleRealm, exampleUrl);

    if (credentials) {
      console.log('Credentials found:');
      console.log(`  Username: ${credentials.username}`);
      console.log(`  Password: ${credentials.password ? '[HIDDEN]' : 'N/A'}`);
      // Note: passwords are typically stored in plain text in simple auth files.
    } else {
      console.log(`No credentials found for realm '${exampleRealm}'.`);
    }
  } catch (error) {
    console.error('Failed to retrieve SVN credentials:', error);
    if (error instanceof Error && error.message.includes('ENOENT')) {
        console.error('Make sure the realmDirectory path is correct and the auth files exist.');
    }
  }
}

getSvnCredentials();

view raw JSON →