node-ikev2 0.1.0 → 0.1.2
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 +13 -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
|
|
@@ -1593,6 +1592,9 @@ class PayloadSK extends Payload {
|
|
|
1593
1592
|
throw new Error(`Insufficient data for payload header at offset ${offset}`);
|
|
1594
1593
|
}
|
|
1595
1594
|
const payload = nextPayloadClass.parse(inClearData.subarray(offset, inClearData.length));
|
|
1595
|
+
// Some extended types set NONE in type from the constructor on parse, when there are multiple types with the same
|
|
1596
|
+
// encoding - e.g. PayloadID with IDi and IDr
|
|
1597
|
+
payload.type = nextPayload;
|
|
1596
1598
|
payloads.push(payload);
|
|
1597
1599
|
offset += payload.length;
|
|
1598
1600
|
nextPayload = payload.nextPayload;
|
|
@@ -1746,10 +1748,10 @@ exports.PayloadCP = PayloadCP;
|
|
|
1746
1748
|
* @extends Payload
|
|
1747
1749
|
*/
|
|
1748
1750
|
class PayloadEAP extends Payload {
|
|
1749
|
-
constructor(nextPayload,
|
|
1750
|
-
super(payloadType.EAP, nextPayload, critical, length > 0 ? length : 4 +
|
|
1751
|
+
constructor(nextPayload, eapMessage, critical = false, length = 0) {
|
|
1752
|
+
super(payloadType.EAP, nextPayload, critical, length > 0 ? length : 4 + eapMessage.length);
|
|
1751
1753
|
this.nextPayload = nextPayload;
|
|
1752
|
-
this.
|
|
1754
|
+
this.eapMessage = eapMessage;
|
|
1753
1755
|
this.critical = critical;
|
|
1754
1756
|
this.length = length;
|
|
1755
1757
|
}
|
|
@@ -1762,8 +1764,8 @@ class PayloadEAP extends Payload {
|
|
|
1762
1764
|
*/
|
|
1763
1765
|
static parse(buffer) {
|
|
1764
1766
|
const genericPayload = Payload.parse(buffer);
|
|
1765
|
-
const
|
|
1766
|
-
return new PayloadEAP(genericPayload.nextPayload,
|
|
1767
|
+
const eapMessage = buffer.subarray(4, genericPayload.length);
|
|
1768
|
+
return new PayloadEAP(genericPayload.nextPayload, eapMessage, genericPayload.critical, genericPayload.length);
|
|
1767
1769
|
}
|
|
1768
1770
|
/**
|
|
1769
1771
|
* Serializes a JSON representation of the EAP payload to a buffer
|
|
@@ -1776,8 +1778,7 @@ class PayloadEAP extends Payload {
|
|
|
1776
1778
|
const buffer = Buffer.alloc(json.length);
|
|
1777
1779
|
const genericPayload = Payload.serializeJSON(json);
|
|
1778
1780
|
genericPayload.copy(buffer);
|
|
1779
|
-
|
|
1780
|
-
tlvDataBuffer.copy(buffer, 4);
|
|
1781
|
+
Buffer.from(json.eapMessage, "hex").copy(buffer, 4);
|
|
1781
1782
|
return buffer;
|
|
1782
1783
|
}
|
|
1783
1784
|
/**
|
|
@@ -1786,13 +1787,11 @@ class PayloadEAP extends Payload {
|
|
|
1786
1787
|
* @returns {Buffer}
|
|
1787
1788
|
*/
|
|
1788
1789
|
serialize() {
|
|
1789
|
-
// Encode deep first to calculate length
|
|
1790
|
-
const tlvDataBuffer = this.tlvData.serialize();
|
|
1791
1790
|
// Fix the length
|
|
1792
|
-
this.length = 4 +
|
|
1791
|
+
this.length = 4 + this.eapMessage.length;
|
|
1793
1792
|
const buffer = Buffer.alloc(this.length);
|
|
1794
1793
|
super.serialize().copy(buffer);
|
|
1795
|
-
|
|
1794
|
+
this.eapMessage.copy(buffer, 4);
|
|
1796
1795
|
return buffer;
|
|
1797
1796
|
}
|
|
1798
1797
|
/**
|
|
@@ -1802,7 +1801,7 @@ class PayloadEAP extends Payload {
|
|
|
1802
1801
|
*/
|
|
1803
1802
|
toJSON() {
|
|
1804
1803
|
const json = super.genToJSON();
|
|
1805
|
-
json.
|
|
1804
|
+
json.eapMessage = this.eapMessage.toString("hex");
|
|
1806
1805
|
return json;
|
|
1807
1806
|
}
|
|
1808
1807
|
/**
|
|
@@ -1812,7 +1811,7 @@ class PayloadEAP extends Payload {
|
|
|
1812
1811
|
*/
|
|
1813
1812
|
toString() {
|
|
1814
1813
|
const genericString = super.genToString();
|
|
1815
|
-
return `${genericString}\
|
|
1814
|
+
return `${genericString}\neapMessage: ${this.eapMessage.toString("hex")}`;
|
|
1816
1815
|
}
|
|
1817
1816
|
}
|
|
1818
1817
|
exports.PayloadEAP = PayloadEAP;
|