Files
Lisbet Alvarez 3ba93927fe Update copyright headers (#3146)
* empty commit

* Add missing copyright headers

* chore: 🤖 update copywrite config file with correct year

* Add missing copyright headers

* empty commit (gh action merge checks are stuck)
2026-01-28 17:09:06 -08:00

53 lines
1.4 KiB
JavaScript

/**
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
import ApplicationSerializer from './application';
export default class CredentialStoreSerializer extends ApplicationSerializer {
/**
* @override
* @method serialize
* @param {Snapshot} snapshot
*/
serialize(snapshot) {
switch (snapshot.record.type) {
case 'vault':
return this.serializeVault(...arguments);
case 'static':
default:
return this.serializeStatic(...arguments);
}
}
serializeVault() {
const serialized = super.serialize(...arguments);
if (serialized.attributes) {
// Client certificate key cannot be unset when certificate is set.
// If it's falsy, it must be removed.
if (
!serialized.attributes?.client_certificate_key &&
serialized.attributes?.client_certificate
) {
delete serialized.attributes.client_certificate_key;
}
}
return serialized;
}
serializeStatic() {
const serialized = super.serialize(...arguments);
// Delete attributes for static cred store
delete serialized.attributes;
return serialized;
}
normalize(typeClass, hash, ...rest) {
const normalizedHash = structuredClone(hash);
const normalized = super.normalize(typeClass, normalizedHash, ...rest);
// Remove secret fields as we don't track them after being created/updated
normalized.data.attributes.token = '';
return normalized;
}
}