Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
balena-auth
Advanced tools
Balena session authentication utilities
The intention of this module is to provide low level access to how a balena authentication tokens are parsed and persisted.
THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY.
Unless you know what you're doing, use the balena SDK instead.
Install balena-auth
by running:
$ npm install --save balena-auth
The module returns a class that you use to get an instance of the auth module.
It accepts the following params:
Param | Type | Description |
---|---|---|
options | Object | options |
[options.dataDirectory] | string | false | the directory to use for storage in Node.js or false to create an isolated in memory instance. Values other than false are ignored in the browser. |
[options.tokenKey] | string | the key used to store the last token in the storage. token by default. |
Example
import BalenaAuth from 'balena-auth';
const auth = new BalenaAuth({
dataDirectory: '/opt/cache/balena',
tokenKey: 'token'
});
[ 'Promise' ].<void>
[ 'Promise' ].<Boolean>
Promise
[ 'Promise' ].<TokenType>
[ 'Promise' ].<string>
[ 'Promise' ].<(number|undefined)>
[ 'Promise' ].<boolean>
[ 'Promise' ].<boolean>
[ 'Promise' ].<('not_required'|'pending'|'passed')>
[ 'Promise' ].<boolean>
[ 'Promise' ].<void>
Kind: inner method of auth
Summary: Set the key
Access: public
Param | Type |
---|---|
key | String |
Example
auth.setKey('...').then(() => { ... });
[ 'Promise' ].<Boolean>
Kind: inner method of auth
Summary: Has a key
Returns: [ 'Promise' ].<Boolean>
- has key
Access: public
Example
auth.hasKey().then((hasKey) => { ... });
Promise
This promise is not rejected if there was no key at the time of removal.
Kind: inner method of auth
Summary: Remove the key
Access: public
Example
auth.removeKey();
[ 'Promise' ].<TokenType>
Kind: inner method of auth
Summary: Gets the key type
Access: public
Example
auth.getType().then((type) => { ... });
[ 'Promise' ].<string>
Kind: inner method of auth
Summary: Gets the key
Access: public
Example
auth.getKey().then((key) => { ... });
[ 'Promise' ].<(number|undefined)>
Kind: inner method of auth
Summary: Gets the token age
Access: public
Example
auth.getAge().then((age) => { ... });
[ 'Promise' ].<boolean>
Kind: inner method of auth
Summary: Checks if token is expired
Access: public
Example
auth.isExpired().then((expired) => { ... });
[ 'Promise' ].<boolean>
Kind: inner method of auth
Summary: Checks if token format is valid
Access: public
Example
auth.isValid().then((valid) => { ... });
[ 'Promise' ].<('not_required'|'pending'|'passed')>
Kind: inner method of auth
Summary: Gets whether passing a 2FA challenge is pending, passed or not required.
Access: public
Example
auth.get2FAStatus().then((get2FAStatus) => { ... });
[ 'Promise' ].<boolean>
Kind: inner method of auth
Summary: Checks whether passing 2FA is pending/needed
Access: public
Example
auth.needs2FA().then((needs2FA) => { ... });
If you're having any problem, please raise an issue on GitHub and the balena team will be happy to help.
Run the test suite by doing:
$ npm test
Before submitting a PR, please make sure that you include tests, and that tslint runs without any warning:
$ npm run lint
The project is licensed under the Apache 2.0 license.
5.1.0 - 2023-07-28
FAQs
Balena session authentication utilities
The npm package balena-auth receives a total of 4,892 weekly downloads. As such, balena-auth popularity was classified as popular.
We found that balena-auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.