tbs_certificate.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { __decorate } from "tslib";
  2. import { AsnProp, AsnPropTypes, AsnIntegerArrayBufferConverter } from "@peculiar/asn1-schema";
  3. import { AlgorithmIdentifier } from "./algorithm_identifier";
  4. import { Name } from "./name";
  5. import { SubjectPublicKeyInfo } from "./subject_public_key_info";
  6. import { Validity } from "./validity";
  7. import { Extensions } from "./extension";
  8. import { Version } from "./types";
  9. export class TBSCertificate {
  10. constructor(params = {}) {
  11. this.version = Version.v1;
  12. this.serialNumber = new ArrayBuffer(0);
  13. this.signature = new AlgorithmIdentifier();
  14. this.issuer = new Name();
  15. this.validity = new Validity();
  16. this.subject = new Name();
  17. this.subjectPublicKeyInfo = new SubjectPublicKeyInfo();
  18. Object.assign(this, params);
  19. }
  20. }
  21. __decorate([
  22. AsnProp({
  23. type: AsnPropTypes.Integer,
  24. context: 0,
  25. defaultValue: Version.v1,
  26. })
  27. ], TBSCertificate.prototype, "version", void 0);
  28. __decorate([
  29. AsnProp({
  30. type: AsnPropTypes.Integer,
  31. converter: AsnIntegerArrayBufferConverter,
  32. })
  33. ], TBSCertificate.prototype, "serialNumber", void 0);
  34. __decorate([
  35. AsnProp({ type: AlgorithmIdentifier })
  36. ], TBSCertificate.prototype, "signature", void 0);
  37. __decorate([
  38. AsnProp({ type: Name })
  39. ], TBSCertificate.prototype, "issuer", void 0);
  40. __decorate([
  41. AsnProp({ type: Validity })
  42. ], TBSCertificate.prototype, "validity", void 0);
  43. __decorate([
  44. AsnProp({ type: Name })
  45. ], TBSCertificate.prototype, "subject", void 0);
  46. __decorate([
  47. AsnProp({ type: SubjectPublicKeyInfo })
  48. ], TBSCertificate.prototype, "subjectPublicKeyInfo", void 0);
  49. __decorate([
  50. AsnProp({
  51. type: AsnPropTypes.BitString,
  52. context: 1,
  53. implicit: true,
  54. optional: true,
  55. })
  56. ], TBSCertificate.prototype, "issuerUniqueID", void 0);
  57. __decorate([
  58. AsnProp({ type: AsnPropTypes.BitString, context: 2, implicit: true, optional: true })
  59. ], TBSCertificate.prototype, "subjectUniqueID", void 0);
  60. __decorate([
  61. AsnProp({ type: Extensions, context: 3, optional: true })
  62. ], TBSCertificate.prototype, "extensions", void 0);