New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

balena-auth

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

balena-auth - npm Package Compare versions

Comparing version 4.1.3-build-fix-async-tests-027af56893911b7b6a95c6743eb90cae86cc3f86-1 to 4.2.0-build-get2FAStatus-197ab120349279ddda0b77a9e9b104fc40e1c0a7-1

10

build/api-key.d.ts

@@ -66,13 +66,13 @@ /**

/**
* @member needs2FA
* @summary Check if the given token requires 2FA
* @member get2FAStatus
* @summary Gets whether passing a 2FA challenge is pending, passed or not required.
* @function
* @public
*
* @returns {boolean}
* @returns {'not_required'|'pending'|'passed'}
*
* @example
* console.log(token.needs2FA());
* console.log(token.get2FAStatus())
*/
needs2FA: () => boolean;
get2FAStatus: () => 'not_required' | 'pending' | 'passed';
}

@@ -73,13 +73,13 @@ "use strict";

/**
* @member needs2FA
* @summary Check if the given token requires 2FA
* @member get2FAStatus
* @summary Gets whether passing a 2FA challenge is pending, passed or not required.
* @function
* @public
*
* @returns {boolean}
* @returns {'not_required'|'pending'|'passed'}
*
* @example
* console.log(token.needs2FA());
* console.log(token.get2FAStatus())
*/
this.needs2FA = () => false;
this.get2FAStatus = () => 'not_required';
this.key = key;

@@ -86,0 +86,0 @@ }

@@ -112,4 +112,16 @@ import { TokenType } from './token';

/**
* @member get2FAStatus
* @summary Gets whether passing a 2FA challenge is pending, passed or not required.
* @function
* @public
*
* @returns {Promise<'not_required'|'pending'|'passed'>}
*
* @example
* auth.get2FAStatus().then((get2FAStatus) => { ... });
*/
get2FAStatus: () => Promise<'not_required' | 'pending' | 'passed'>;
/**
* @member needs2FA
* @summary Checks whether 2FA is needed
* @summary Checks whether passing 2FA is pending/needed
* @function

@@ -116,0 +128,0 @@ * @public

@@ -153,4 +153,19 @@ "use strict";

/**
* @member get2FAStatus
* @summary Gets whether passing a 2FA challenge is pending, passed or not required.
* @function
* @public
*
* @returns {Promise<'not_required'|'pending'|'passed'>}
*
* @example
* auth.get2FAStatus().then((get2FAStatus) => { ... });
*/
this.get2FAStatus = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
const token = yield this.getToken();
return token.get2FAStatus();
});
/**
* @member needs2FA
* @summary Checks whether 2FA is needed
* @summary Checks whether passing 2FA is pending/needed
* @function

@@ -165,4 +180,4 @@ * @public

this.needs2FA = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
const token = yield this.getToken();
return token.needs2FA();
const status = yield this.get2FAStatus();
return status === 'pending';
});

@@ -169,0 +184,0 @@ // Utility methods

@@ -70,13 +70,13 @@ import { Token, TokenType } from './token';

/**
* @member needs2FA
* @summary Check if the given token requires 2FA
* @member get2FAStatus
* @summary Gets whether passing a 2FA challenge is pending, passed or not required.
* @function
* @public
*
* @returns {boolean}
* @returns {'not_required'|'pending'|'passed'}
*
* @example
* console.log(token.needs2FA());
* console.log(token.get2FAStatus())
*/
needs2FA: () => boolean;
get2FAStatus: () => "pending" | "not_required" | "passed";
}

@@ -92,13 +92,22 @@ "use strict";

/**
* @member needs2FA
* @summary Check if the given token requires 2FA
* @member get2FAStatus
* @summary Gets whether passing a 2FA challenge is pending, passed or not required.
* @function
* @public
*
* @returns {boolean}
* @returns {'not_required'|'pending'|'passed'}
*
* @example
* console.log(token.needs2FA());
* console.log(token.get2FAStatus())
*/
this.needs2FA = () => !!JWT.parse(this.key).twoFactorRequired;
this.get2FAStatus = () => {
const { twoFactorRequired } = JWT.parse(this.key);
if (twoFactorRequired == null) {
return 'not_required';
}
if (twoFactorRequired) {
return 'pending';
}
return 'passed';
};
this.key = key;

@@ -105,0 +114,0 @@ }

@@ -10,3 +10,3 @@ /**

isValid: () => boolean;
needs2FA: () => boolean;
get2FAStatus: () => 'not_required' | 'pending' | 'passed';
}

@@ -13,0 +13,0 @@ export declare enum TokenType {

@@ -92,13 +92,14 @@ /*

/**
* @member needs2FA
* @summary Check if the given token requires 2FA
* @member get2FAStatus
* @summary Gets whether passing a 2FA challenge is pending, passed or not required.
* @function
* @public
*
* @returns {boolean}
* @returns {'not_required'|'pending'|'passed'}
*
* @example
* console.log(token.needs2FA());
* console.log(token.get2FAStatus())
*/
public needs2FA = (): boolean => false;
public get2FAStatus = (): 'not_required' | 'pending' | 'passed' =>
'not_required';
}

@@ -179,4 +179,22 @@ /*

/**
* @member get2FAStatus
* @summary Gets whether passing a 2FA challenge is pending, passed or not required.
* @function
* @public
*
* @returns {Promise<'not_required'|'pending'|'passed'>}
*
* @example
* auth.get2FAStatus().then((get2FAStatus) => { ... });
*/
public get2FAStatus = async (): Promise<
'not_required' | 'pending' | 'passed'
> => {
const token = await this.getToken();
return token.get2FAStatus();
};
/**
* @member needs2FA
* @summary Checks whether 2FA is needed
* @summary Checks whether passing 2FA is pending/needed
* @function

@@ -191,4 +209,4 @@ * @public

public needs2FA = async (): Promise<boolean> => {
const token = await this.getToken();
return token.needs2FA();
const status = await this.get2FAStatus();
return status === 'pending';
};

@@ -195,0 +213,0 @@

@@ -118,13 +118,24 @@ /*

/**
* @member needs2FA
* @summary Check if the given token requires 2FA
* @member get2FAStatus
* @summary Gets whether passing a 2FA challenge is pending, passed or not required.
* @function
* @public
*
* @returns {boolean}
* @returns {'not_required'|'pending'|'passed'}
*
* @example
* console.log(token.needs2FA());
* console.log(token.get2FAStatus())
*/
public needs2FA = (): boolean => !!JWT.parse(this.key).twoFactorRequired;
public get2FAStatus = () => {
const { twoFactorRequired } = JWT.parse(this.key);
if (twoFactorRequired == null) {
return 'not_required';
}
if (twoFactorRequired) {
return 'pending';
}
return 'passed';
};
}

@@ -27,3 +27,3 @@ /*

isValid: () => boolean;
needs2FA: () => boolean;
get2FAStatus: () => 'not_required' | 'pending' | 'passed';
}

@@ -30,0 +30,0 @@

{
"name": "balena-auth",
"version": "4.1.3-build-fix-async-tests-027af56893911b7b6a95c6743eb90cae86cc3f86-1",
"version": "4.2.0-build-get2FAStatus-197ab120349279ddda0b77a9e9b104fc40e1c0a7-1",
"description": "Balena session authentication utilities",

@@ -86,4 +86,4 @@ "main": "build/auth.js",

"versionist": {
"publishedAt": "2023-05-25T08:22:17.474Z"
"publishedAt": "2023-05-25T08:23:39.458Z"
}
}

@@ -54,15 +54,16 @@ balena-auth

* [auth](#module_auth)
* [~setKey(key)](#module_auth..setKey) ⇒ <code>Promise.&lt;void&gt;</code>
* [~hasKey()](#module_auth..hasKey) ⇒ <code>Promise.&lt;Boolean&gt;</code>
* [~setKey(key)](#module_auth..setKey) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;void&gt;</code>
* [~hasKey()](#module_auth..hasKey) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;Boolean&gt;</code>
* [~removeKey()](#module_auth..removeKey) ⇒ <code>Promise</code>
* [~getType()](#module_auth..getType) ⇒ <code>Promise.&lt;TokenType&gt;</code>
* [~getKey()](#module_auth..getKey) ⇒ <code>Promise.&lt;string&gt;</code>
* [~getAge()](#module_auth..getAge) ⇒ <code>Promise.&lt;(number\|undefined)&gt;</code>
* [~isExpired()](#module_auth..isExpired) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [~isValid()](#module_auth..isValid) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [~needs2FA()](#module_auth..needs2FA) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [~getType()](#module_auth..getType) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;TokenType&gt;</code>
* [~getKey()](#module_auth..getKey) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;string&gt;</code>
* [~getAge()](#module_auth..getAge) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;(number\|undefined)&gt;</code>
* [~isExpired()](#module_auth..isExpired) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;boolean&gt;</code>
* [~isValid()](#module_auth..isValid) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;boolean&gt;</code>
* [~get2FAStatus()](#module_auth..get2FAStatus) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;(&#x27;not\_required&#x27;\|&#x27;pending&#x27;\|&#x27;passed&#x27;)&gt;</code>
* [~needs2FA()](#module_auth..needs2FA) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;boolean&gt;</code>
<a name="module_auth..setKey"></a>
### auth~setKey(key) ⇒ <code>Promise.&lt;void&gt;</code>
### auth~setKey(key) ⇒ <code>[ &#x27;Promise&#x27; ].&lt;void&gt;</code>
**Kind**: inner method of [<code>auth</code>](#module_auth)

@@ -82,6 +83,6 @@ **Summary**: Set the key

### auth~hasKey() ⇒ <code>Promise.&lt;Boolean&gt;</code>
### auth~hasKey() ⇒ <code>[ &#x27;Promise&#x27; ].&lt;Boolean&gt;</code>
**Kind**: inner method of [<code>auth</code>](#module_auth)
**Summary**: Has a key
**Returns**: <code>Promise.&lt;Boolean&gt;</code> - has key
**Returns**: <code>[ &#x27;Promise&#x27; ].&lt;Boolean&gt;</code> - has key
**Access**: public

@@ -106,3 +107,3 @@ **Example**

### auth~getType() ⇒ <code>Promise.&lt;TokenType&gt;</code>
### auth~getType() ⇒ <code>[ &#x27;Promise&#x27; ].&lt;TokenType&gt;</code>
**Kind**: inner method of [<code>auth</code>](#module_auth)

@@ -117,3 +118,3 @@ **Summary**: Gets the key type

### auth~getKey() ⇒ <code>Promise.&lt;string&gt;</code>
### auth~getKey() ⇒ <code>[ &#x27;Promise&#x27; ].&lt;string&gt;</code>
**Kind**: inner method of [<code>auth</code>](#module_auth)

@@ -128,3 +129,3 @@ **Summary**: Gets the key

### auth~getAge() ⇒ <code>Promise.&lt;(number\|undefined)&gt;</code>
### auth~getAge() ⇒ <code>[ &#x27;Promise&#x27; ].&lt;(number\|undefined)&gt;</code>
**Kind**: inner method of [<code>auth</code>](#module_auth)

@@ -139,3 +140,3 @@ **Summary**: Gets the token age

### auth~isExpired() ⇒ <code>Promise.&lt;boolean&gt;</code>
### auth~isExpired() ⇒ <code>[ &#x27;Promise&#x27; ].&lt;boolean&gt;</code>
**Kind**: inner method of [<code>auth</code>](#module_auth)

@@ -150,3 +151,3 @@ **Summary**: Checks if token is expired

### auth~isValid() ⇒ <code>Promise.&lt;boolean&gt;</code>
### auth~isValid() ⇒ <code>[ &#x27;Promise&#x27; ].&lt;boolean&gt;</code>
**Kind**: inner method of [<code>auth</code>](#module_auth)

@@ -159,7 +160,17 @@ **Summary**: Checks if token format is valid

```
<a name="module_auth..get2FAStatus"></a>
### auth~get2FAStatus() ⇒ <code>[ &#x27;Promise&#x27; ].&lt;(&#x27;not\_required&#x27;\|&#x27;pending&#x27;\|&#x27;passed&#x27;)&gt;</code>
**Kind**: inner method of [<code>auth</code>](#module_auth)
**Summary**: Gets whether passing a 2FA challenge is pending, passed or not required.
**Access**: public
**Example**
```js
auth.get2FAStatus().then((get2FAStatus) => { ... });
```
<a name="module_auth..needs2FA"></a>
### auth~needs2FA() ⇒ <code>Promise.&lt;boolean&gt;</code>
### auth~needs2FA() ⇒ <code>[ &#x27;Promise&#x27; ].&lt;boolean&gt;</code>
**Kind**: inner method of [<code>auth</code>](#module_auth)
**Summary**: Checks whether 2FA is needed
**Summary**: Checks whether passing 2FA is pending/needed
**Access**: public

@@ -166,0 +177,0 @@ **Example**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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