node-ikev2 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/src/index.js CHANGED
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
20
  };
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.ikev2 = void 0;
30
40
  __exportStar(require("./attribute"), exports);
@@ -1,5 +1,4 @@
1
1
  import { Proposal } from "./proposal";
2
- import { Attribute } from "./attribute";
3
2
  import { TrafficSelector } from "./selector";
4
3
  /**
5
4
  * IKEv2 Payload Types: \
@@ -959,10 +958,10 @@ export declare class PayloadCP extends Payload {
959
958
  */
960
959
  export declare class PayloadEAP extends Payload {
961
960
  nextPayload: payloadType;
962
- tlvData: Attribute;
961
+ eapMessage: Buffer;
963
962
  critical: boolean;
964
963
  length: number;
965
- constructor(nextPayload: payloadType, tlvData: Attribute, critical?: boolean, length?: number);
964
+ constructor(nextPayload: payloadType, eapMessage: Buffer, critical?: boolean, length?: number);
966
965
  /**
967
966
  * Parses an EAP Payload from a buffer
968
967
  * @param buffer
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.payloadTypeMapping = exports.PayloadEAP = exports.PayloadCP = exports.cfgType = exports.PayloadSK = exports.PayloadTSr = exports.PayloadTSi = exports.PayloadTS = exports.PayloadVENDOR = exports.PayloadDELETE = exports.PayloadNOTIFY = exports.notifyMessageType = exports.securityProtocolId = exports.PayloadNONCE = exports.PayloadAUTH = exports.PayloadCERTREQ = exports.PayloadCERT = exports.CertificateType = exports.PayloadIDr = exports.PayloadIDi = exports.PayloadID = exports.IDType = exports.PayloadKE = exports.PayloadSA = exports.Payload = exports.payloadType = void 0;
4
4
  const proposal_1 = require("./proposal");
5
- const attribute_1 = require("./attribute");
6
5
  const selector_1 = require("./selector");
7
6
  /*
8
7
  IKEv2 Generic Payload Header
@@ -1746,10 +1745,10 @@ exports.PayloadCP = PayloadCP;
1746
1745
  * @extends Payload
1747
1746
  */
1748
1747
  class PayloadEAP extends Payload {
1749
- constructor(nextPayload, tlvData, critical = false, length = 0) {
1750
- super(payloadType.EAP, nextPayload, critical, length > 0 ? length : 4 + tlvData.length);
1748
+ constructor(nextPayload, eapMessage, critical = false, length = 0) {
1749
+ super(payloadType.EAP, nextPayload, critical, length > 0 ? length : 4 + eapMessage.length);
1751
1750
  this.nextPayload = nextPayload;
1752
- this.tlvData = tlvData;
1751
+ this.eapMessage = eapMessage;
1753
1752
  this.critical = critical;
1754
1753
  this.length = length;
1755
1754
  }
@@ -1762,8 +1761,8 @@ class PayloadEAP extends Payload {
1762
1761
  */
1763
1762
  static parse(buffer) {
1764
1763
  const genericPayload = Payload.parse(buffer);
1765
- const tlvData = attribute_1.Attribute.parse(buffer.subarray(4, genericPayload.length));
1766
- return new PayloadEAP(genericPayload.nextPayload, tlvData, genericPayload.critical, genericPayload.length);
1764
+ const eapMessage = buffer.subarray(4, genericPayload.length);
1765
+ return new PayloadEAP(genericPayload.nextPayload, eapMessage, genericPayload.critical, genericPayload.length);
1767
1766
  }
1768
1767
  /**
1769
1768
  * Serializes a JSON representation of the EAP payload to a buffer
@@ -1776,8 +1775,7 @@ class PayloadEAP extends Payload {
1776
1775
  const buffer = Buffer.alloc(json.length);
1777
1776
  const genericPayload = Payload.serializeJSON(json);
1778
1777
  genericPayload.copy(buffer);
1779
- const tlvDataBuffer = attribute_1.Attribute.serializeJSON(json.tlvData);
1780
- tlvDataBuffer.copy(buffer, 4);
1778
+ Buffer.from(json.eapMessage, "hex").copy(buffer, 4);
1781
1779
  return buffer;
1782
1780
  }
1783
1781
  /**
@@ -1786,13 +1784,11 @@ class PayloadEAP extends Payload {
1786
1784
  * @returns {Buffer}
1787
1785
  */
1788
1786
  serialize() {
1789
- // Encode deep first to calculate length
1790
- const tlvDataBuffer = this.tlvData.serialize();
1791
1787
  // Fix the length
1792
- this.length = 4 + tlvDataBuffer.length;
1788
+ this.length = 4 + this.eapMessage.length;
1793
1789
  const buffer = Buffer.alloc(this.length);
1794
1790
  super.serialize().copy(buffer);
1795
- tlvDataBuffer.copy(buffer, 4);
1791
+ this.eapMessage.copy(buffer, 4);
1796
1792
  return buffer;
1797
1793
  }
1798
1794
  /**
@@ -1802,7 +1798,7 @@ class PayloadEAP extends Payload {
1802
1798
  */
1803
1799
  toJSON() {
1804
1800
  const json = super.genToJSON();
1805
- json.tlvData = this.tlvData.toJSON();
1801
+ json.eapMessage = this.eapMessage.toString("hex");
1806
1802
  return json;
1807
1803
  }
1808
1804
  /**
@@ -1812,7 +1808,7 @@ class PayloadEAP extends Payload {
1812
1808
  */
1813
1809
  toString() {
1814
1810
  const genericString = super.genToString();
1815
- return `${genericString}\ntlvData: ${this.tlvData.toString()}`;
1811
+ return `${genericString}\neapMessage: ${this.eapMessage.toString("hex")}`;
1816
1812
  }
1817
1813
  }
1818
1814
  exports.PayloadEAP = PayloadEAP;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-ikev2",
3
3
  "title": "Node-IKEV2",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "description": "IKEv2 parser and serializer for Node.js",
6
6
  "main": "./lib/src/index.js",
7
7
  "types": "./lib/src/index.d.ts",