Files
threshold-ui/addons/api/addon/models/credential.js
T

41 lines
896 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
2022-07-19 13:02:04 -07:00
import GeneratedCredentialModel from '../generated/models/credential';
2022-09-20 17:31:16 -07:00
/**
* Supported Credential types.
*/
2022-12-12 16:37:01 -08:00
export const types = ['username_password', 'ssh_private_key', 'json'];
2022-09-20 17:31:16 -07:00
2022-09-02 12:29:39 -07:00
export default class CredentialModel extends GeneratedCredentialModel {
// =attributes
/**
* All Credentials are prefixed with "cred" and are considered
* static due to their relation with Static Credential Stores.
2022-10-06 11:41:12 -04:00
*
* True if credential starts with the "cred" prefix.
2022-09-02 12:29:39 -07:00
* @type {boolean}
*/
get isStatic() {
return this.id.startsWith('cred');
}
2022-09-20 17:31:16 -07:00
2022-12-16 15:06:19 -05:00
/**
* True if type is `json`.
* @type {boolean}
*/
get isJSON() {
return this.type === 'json';
}
2022-09-20 17:31:16 -07:00
/**
* True if credential is an unknown type.
* @type {boolean}
*/
get isUnknown() {
return !types.includes(this.type);
}
2022-09-02 12:29:39 -07:00
}