Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apexdevtools/sfdx-auth-helper

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apexdevtools/sfdx-auth-helper

Salesforce authentication utilities

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-90%
Maintainers
1
Weekly downloads
 
Created
Source

sfdx-auth-helper

Authentication support library for sfdx.

Usage

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

  // 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)
  // 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
  // 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
  // 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.

  pnpm build

To run unit tests:

  pnpm test

To test bundling using webpack:

  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.

Keywords

FAQs

Package last updated on 13 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc