balena-auth
Version:
Balena session authentication utilities
85 lines (82 loc) • 2.37 kB
JavaScript
;
/*
Copyright 2016-17 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.APIKey = void 0;
const token_1 = require("./token");
class APIKey {
constructor(key) {
/**
* @member type
* @summary Get the type of token
* @public
*
* @returns {TokenType} the type of token
*
* @example
* console.log(token.type)
*/
this.type = token_1.TokenType.APIKey;
/**
* @member isValid
* @summary Check if a token is valid
* @function
* @public
*
* @returns {boolean} is valid
*
* @example
* console.log(token.isValid());
*/
this.isValid = () => true;
/**
* @member getAge
* @summary Get the token age
* @function
* @public
*
* @returns {number | undefined}
*
* @example
* console.log(token.getAge());
*/
this.getAge = () => 0;
/**
* @member isExpired
* @summary Check whether the token has expired
* @function
* @public
*
* @returns {boolean}
*
* @example
* console.log(token.isExpired());
*/
this.isExpired = () => false;
/**
* @member get2FAStatus
* @summary Gets whether passing a 2FA challenge is pending, passed or not required.
* @function
* @public
*
* @returns {'not_required'|'pending'|'passed'}
*
* @example
* console.log(token.get2FAStatus())
*/
this.get2FAStatus = () => 'not_required';
this.key = key;
}
}
exports.APIKey = APIKey;
//# sourceMappingURL=api-key.js.map