1309d724e3
* refactor parser to pull serial number from subject * refactor pki parser * uninstall pvtutils * remove hideFormSection as attr * remove hideFormSection as attr * add string-list * test removing issueDate * update tests * final answer - make number types * change to unix time - since valueOf() is typically used internally * add algo mapping * add comment to complete in followon * add attrs to pki parser * add conditional operands so parser continues when values dont exist * add error handling WIP * finish tests, add error handling * revert to helper * move helper to util * add parseSubject test * finish tests * move certs to pki helper file * wrap parsing functions in try...catch
27 lines
774 B
JavaScript
27 lines
774 B
JavaScript
import { parseCertificate } from 'vault/utils/parse-pki-cert';
|
|
import ApplicationSerializer from '../../application';
|
|
|
|
export default class PkiCertificateBaseSerializer extends ApplicationSerializer {
|
|
primaryKey = 'serial_number';
|
|
|
|
attrs = {
|
|
role: { serialize: false },
|
|
};
|
|
|
|
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
|
|
if (payload.data.certificate) {
|
|
// Parse certificate back from the API and add to payload
|
|
const parsedCert = parseCertificate(payload.data.certificate);
|
|
const json = super.normalizeResponse(
|
|
store,
|
|
primaryModelClass,
|
|
{ ...payload, ...parsedCert },
|
|
id,
|
|
requestType
|
|
);
|
|
return json;
|
|
}
|
|
return super.normalizeResponse(...arguments);
|
|
}
|
|
}
|