general_name.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { __decorate } from "tslib";
  2. import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes, AsnOctetStringConverter, } from "@peculiar/asn1-schema";
  3. import { IpConverter } from "./ip_converter.js";
  4. import { DirectoryString, Name } from "./name.js";
  5. export const AsnIpConverter = {
  6. fromASN: (value) => IpConverter.toString(AsnOctetStringConverter.fromASN(value)),
  7. toASN: (value) => AsnOctetStringConverter.toASN(IpConverter.fromString(value)),
  8. };
  9. export class OtherName {
  10. typeId = "";
  11. value = new ArrayBuffer(0);
  12. constructor(params = {}) {
  13. Object.assign(this, params);
  14. }
  15. }
  16. __decorate([
  17. AsnProp({ type: AsnPropTypes.ObjectIdentifier })
  18. ], OtherName.prototype, "typeId", void 0);
  19. __decorate([
  20. AsnProp({
  21. type: AsnPropTypes.Any, context: 0,
  22. })
  23. ], OtherName.prototype, "value", void 0);
  24. export class EDIPartyName {
  25. nameAssigner;
  26. partyName = new DirectoryString();
  27. constructor(params = {}) {
  28. Object.assign(this, params);
  29. }
  30. }
  31. __decorate([
  32. AsnProp({
  33. type: DirectoryString, optional: true, context: 0, implicit: true,
  34. })
  35. ], EDIPartyName.prototype, "nameAssigner", void 0);
  36. __decorate([
  37. AsnProp({
  38. type: DirectoryString, context: 1, implicit: true,
  39. })
  40. ], EDIPartyName.prototype, "partyName", void 0);
  41. let GeneralName = class GeneralName {
  42. otherName;
  43. rfc822Name;
  44. dNSName;
  45. x400Address;
  46. directoryName;
  47. ediPartyName;
  48. uniformResourceIdentifier;
  49. iPAddress;
  50. registeredID;
  51. constructor(params = {}) {
  52. Object.assign(this, params);
  53. }
  54. };
  55. __decorate([
  56. AsnProp({
  57. type: OtherName, context: 0, implicit: true,
  58. })
  59. ], GeneralName.prototype, "otherName", void 0);
  60. __decorate([
  61. AsnProp({
  62. type: AsnPropTypes.IA5String, context: 1, implicit: true,
  63. })
  64. ], GeneralName.prototype, "rfc822Name", void 0);
  65. __decorate([
  66. AsnProp({
  67. type: AsnPropTypes.IA5String, context: 2, implicit: true,
  68. })
  69. ], GeneralName.prototype, "dNSName", void 0);
  70. __decorate([
  71. AsnProp({
  72. type: AsnPropTypes.Any, context: 3, implicit: true,
  73. })
  74. ], GeneralName.prototype, "x400Address", void 0);
  75. __decorate([
  76. AsnProp({
  77. type: Name, context: 4, implicit: false,
  78. })
  79. ], GeneralName.prototype, "directoryName", void 0);
  80. __decorate([
  81. AsnProp({
  82. type: EDIPartyName, context: 5,
  83. })
  84. ], GeneralName.prototype, "ediPartyName", void 0);
  85. __decorate([
  86. AsnProp({
  87. type: AsnPropTypes.IA5String, context: 6, implicit: true,
  88. })
  89. ], GeneralName.prototype, "uniformResourceIdentifier", void 0);
  90. __decorate([
  91. AsnProp({
  92. type: AsnPropTypes.OctetString,
  93. context: 7,
  94. implicit: true,
  95. converter: AsnIpConverter,
  96. })
  97. ], GeneralName.prototype, "iPAddress", void 0);
  98. __decorate([
  99. AsnProp({
  100. type: AsnPropTypes.ObjectIdentifier, context: 8, implicit: true,
  101. })
  102. ], GeneralName.prototype, "registeredID", void 0);
  103. GeneralName = __decorate([
  104. AsnType({ type: AsnTypeTypes.Choice })
  105. ], GeneralName);
  106. export { GeneralName };