mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
* Add util for determining whether secret data is advanced * Add test coverage for bug * use non-dumb logic for detecting advanced object * Add changelog * Add header * Move util to core * Add escaped newline to test coverage * headers again *eyeroll*
21 lines
504 B
JavaScript
21 lines
504 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
/**
|
|
* Method to check whether the secret value is a nested object (returns true)
|
|
* All other values return false
|
|
* @param value string or stringified JSON
|
|
* @returns boolean
|
|
*/
|
|
export function isAdvancedSecret(value) {
|
|
try {
|
|
const json = JSON.parse(value);
|
|
if (Array.isArray(json)) return false;
|
|
return Object.values(json).some((value) => typeof value !== 'string');
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|