import * as asn1js from "asn1js"; import * as pvutils from "pvutils"; import { PKIStatusInfo, PKIStatusInfoJson, PKIStatusInfoSchema } from "./PKIStatusInfo"; import { ContentInfo, ContentInfoJson, ContentInfoSchema } from "./ContentInfo"; import { SignedData } from "./SignedData"; import * as Schema from "./Schema"; import { id_ContentType_SignedData } from "./ObjectIdentifiers"; import { Certificate } from "./Certificate"; import { PkiObject, PkiObjectParameters } from "./PkiObject"; import { AsnError } from "./errors"; import { EMPTY_BUFFER, EMPTY_STRING } from "./constants"; import * as common from "./common";
public status!: PKIStatusInfo; public timeStampToken?: ContentInfo;
/** * Initializes a new instance of the {@link TimeStampResp} class * @param parameters Initialization parameters
*/
constructor(parameters: TimeStampRespParameters = {}) { super();
this.status = pvutils.getParametersValue(parameters, STATUS, TimeStampResp.defaultValues(STATUS)); if (TIME_STAMP_TOKEN in parameters) { this.timeStampToken = pvutils.getParametersValue(parameters, TIME_STAMP_TOKEN, TimeStampResp.defaultValues(TIME_STAMP_TOKEN));
}
if (parameters.schema) { this.fromSchema(parameters.schema);
}
}
/** * Returns default values for all class members * @param memberName String name for a class member * @returns Default value
*/ publicstatic override defaultValues(memberName: typeof STATUS): PKIStatusInfo; publicstatic override defaultValues(memberName: typeof TIME_STAMP_TOKEN): ContentInfo; publicstatic override defaultValues(memberName: string): any { switch (memberName) { case STATUS: returnnew PKIStatusInfo(); case TIME_STAMP_TOKEN: returnnew ContentInfo(); default: returnsuper.defaultValues(memberName);
}
}
/** * Compare values with default values for all class members * @param memberName String name for a class member * @param memberValue Value to compare with default value
*/ publicstatic compareWithDefault(memberName: string, memberValue: any): boolean { switch (memberName) { case STATUS: return ((PKIStatusInfo.compareWithDefault(STATUS, memberValue.status)) &&
(("statusStrings" in memberValue) === false) &&
(("failInfo" in memberValue) === false)); case TIME_STAMP_TOKEN: return ((memberValue.contentType === EMPTY_STRING) &&
(memberValue.content instanceof asn1js.Any)); default: returnsuper.defaultValues(memberName);
}
}
public fromSchema(schema: Schema.SchemaType): void { // Clear input data first
pvutils.clearProps(schema, CLEAR_PROPS);
// Check the schema is valid const asn1 = asn1js.compareSchema(schema,
schema,
TimeStampResp.schema()
);
AsnError.assertSchema(asn1, this.className);
// Get internal properties from parsed schema this.status = new PKIStatusInfo({ schema: asn1.result[TIME_STAMP_RESP_STATUS] }); if (TIME_STAMP_RESP_TOKEN in asn1.result) this.timeStampToken = new ContentInfo({ schema: asn1.result[TIME_STAMP_RESP_TOKEN] });
}
public toSchema(): asn1js.Sequence { //#region Create array for output sequence const outputArray = [];
outputArray.push(this.status.toSchema()); if (this.timeStampToken) {
outputArray.push(this.timeStampToken.toSchema());
} //#endregion
//#region Construct and return new ASN.1 schema for this object return (new asn1js.Sequence({
value: outputArray
})); //#endregion
}
private assertContentType(): asserts this is { timeStampToken: ContentInfo; } { if (!this.timeStampToken) { thrownew Error("timeStampToken is absent in TSP response");
} if (this.timeStampToken.contentType !== id_ContentType_SignedData) { // Must be a CMS signed data thrownew Error(`Wrong format of timeStampToken: ${this.timeStampToken.contentType}`);
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet am 2026-06-06)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.