# @apexdevtools/sfdx-auth-helper

> Salesforce authentication utilities

Latest version **3.0.0** (published 2026-07-09) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @apexdevtools/sfdx-auth-helper
pnpm add @apexdevtools/sfdx-auth-helper
yarn add @apexdevtools/sfdx-auth-helper
bun add @apexdevtools/sfdx-auth-helper
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-07-09 |
| First published | 2022-07-10 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | ^22.13.0 \|\| >=24 |
| Dependencies | 2 |
| Unpacked size | 20.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Apex Dev Tools Team |
| Maintainers | apexdevtools |
| Keywords | salesforce, sfdx-core |

## Links

- npm: https://www.npmjs.com/package/@apexdevtools/sfdx-auth-helper
- Repository: https://github.com/apex-dev-tools/sfdx-auth-helper
- Homepage: https://github.com/apex-dev-tools/sfdx-auth-helper#readme
- Issues: https://github.com/apex-dev-tools/sfdx-auth-helper/issues
- npm.io page: https://npm.io/package/@apexdevtools/sfdx-auth-helper

## Dependencies (2)

- [jsforce](https://npm.io/package/jsforce.md) ^1.11.0
- [@salesforce/core](https://npm.io/package/@salesforce/core.md) ^8.32.2

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2026-07-09
- 2.1.1 — 2026-06-14
- 2.1.0 — 2023-10-13
- 2.0.1 — 2023-10-12
- 2.0.0 — 2023-04-12
- 1.0.5 — 2022-07-25
- 1.0.4 — 2022-07-10
- 1.0.3 — 2022-07-10
- 1.0.2 — 2022-07-10
- 1.0.1 — 2022-07-10
- 1.0.0 — 2022-07-10

## README

# sfdx-auth-helper

Authentication support library for sfdx.

## Usage

To start, create an instance of the helper at the path of your sf project.

```js
  // dir containing sfdx-project.json
  const workspacePath = '/path/to/my/project';
  const helper = await AuthHelper.instance(workspacePath);
```

* Get connection to an org (That exists in `sf` config)

```js
  // Connection.create(...) with default user auth info
  const conn = helper.connect();
  // Get an existing saved org by specific username or alias
  helper.connect('user@mycompany.org');
  helper.connect('MyOrg');
```

* Get a jsforce connection to current default org

```js
  // new jsforce.Connection with default user auth info
  const conn = helper.connectJsForce();

  // Also supports alias / username
  helper.connectJsForce('MyOrg');
  // Provide fallback API version if none set in project
  helper.connectJsForce('MyOrg', '57.0');
```

* Transform an existing `Connection` into a `jsforce` one

```js
  // Connection created by newer version of `@salesforce/core`
  const conn = Connection.create({...});

  // Use static to produce a jsforce.Connection
  AuthHelper.toJsForceConnection(conn);
```

* Additional instance methods
  * `getDefaultUsername()` - This returns the default org username for a sfdx workspace. If no default username is set it returns undefined. If the default is an org alias that is translated to a username.
  * `reloadConfig()` - If the loaded config has changed due to some external action (e.g. org creation) the copy cached by the core library will be stale. Use this to reload, making a new helper instance will not be enough.

## Development

### Building

This project uses the `pnpm` package manager.

```txt
  pnpm build
```

To run unit tests:

```txt
  pnpm test
```

To test bundling using webpack:

```txt
  pnpm test:pack
  node test-bundle/bundle.js
```

This should execute without error.

### Git Hooks

If you encounter difficulties with the installed git hooks, they can be bypassed with `--no-verify`/`-n` flag on commit. To disable them completely (after `install`) use `npx husky uninstall` or the direct command `git config --unset core.hooksPath`.

## License

All the source code included uses a 3-clause BSD license, see LICENSE for details.

---
_Source: https://npm.io/package/@apexdevtools/sfdx-auth-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
