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 +17 -7
- package/lib/src/payload.d.ts +2 -3
- package/lib/src/payload.js +10 -14
- package/package.json +1 -1
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 (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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);
|
package/lib/src/payload.d.ts
CHANGED
|
@@ -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
|
-
|
|
961
|
+
eapMessage: Buffer;
|
|
963
962
|
critical: boolean;
|
|
964
963
|
length: number;
|
|
965
|
-
constructor(nextPayload: payloadType,
|
|
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
|
package/lib/src/payload.js
CHANGED
|
@@ -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,
|
|
1750
|
-
super(payloadType.EAP, nextPayload, critical, length > 0 ? length : 4 +
|
|
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.
|
|
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
|
|
1766
|
-
return new PayloadEAP(genericPayload.nextPayload,
|
|
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
|
-
|
|
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 +
|
|
1788
|
+
this.length = 4 + this.eapMessage.length;
|
|
1793
1789
|
const buffer = Buffer.alloc(this.length);
|
|
1794
1790
|
super.serialize().copy(buffer);
|
|
1795
|
-
|
|
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.
|
|
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}\
|
|
1811
|
+
return `${genericString}\neapMessage: ${this.eapMessage.toString("hex")}`;
|
|
1816
1812
|
}
|
|
1817
1813
|
}
|
|
1818
1814
|
exports.PayloadEAP = PayloadEAP;
|