2023-03-01 09:39:41 -06:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2024-05-31 11:29:24 -07:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-01 09:39:41 -06:00
|
|
|
*/
|
|
|
|
|
|
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
|
|
|
|
|
/**
|
2022-09-21 15:10:28 -05:00
|
|
|
* 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
|
|
|
*
|
2022-09-21 15:10:28 -05:00
|
|
|
* True if credential starts with the "cred" prefix.
|
2022-09-02 12:29:39 -07:00
|
|
|
* @type {boolean}
|
|
|
|
|
*/
|
2022-09-21 15:10:28 -05:00
|
|
|
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
|
|
|
}
|