Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
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 | the directory to use for storage in Node.js. 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.
FAQs
Balena session authentication utilities
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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
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.