eufy-security-client 4.1.1-1 → 4.1.1-dev.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eufy-security-client",
3
- "version": "4.1.1-1",
3
+ "version": "4.1.1-dev.39",
4
4
  "description": "Client to communicate with Eufy-Security devices",
5
5
  "author": {
6
6
  "name": "bropat",
@@ -1,31 +0,0 @@
1
- export type ForgeRSAOptions = {
2
- encryptionScheme?: "pkcs1" | "pkcs1_oaep";
3
- };
4
- export interface RSAPublicComponents {
5
- n: Uint8Array;
6
- e: Uint8Array;
7
- }
8
- export declare class ForgeRSA {
9
- private privateKey?;
10
- private publicKey?;
11
- private options;
12
- constructor(bits?: number);
13
- /**
14
- * Import a PEM-formatted key (auto-detects PKCS#1 vs PKCS#8).
15
- */
16
- importKey(pem: string): void;
17
- /**
18
- * Export a key in a NodeRSA-like format.
19
- */
20
- exportKey(format: string): string;
21
- /**
22
- * Set options (only encryptionScheme supported).
23
- */
24
- setOptions(options: ForgeRSAOptions): void;
25
- encrypt(data: string | Buffer): string;
26
- decrypt(encrypted: string | Buffer): Buffer;
27
- /**
28
- * Get raw components of the public key
29
- */
30
- exportPublicComponents(): RSAPublicComponents;
31
- }
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ForgeRSA = void 0;
7
- const node_forge_1 = __importDefault(require("node-forge"));
8
- class ForgeRSA {
9
- privateKey;
10
- publicKey;
11
- options = { encryptionScheme: "pkcs1" };
12
- constructor(bits) {
13
- if (bits) {
14
- const keypair = node_forge_1.default.pki.rsa.generateKeyPair({ bits, e: 0x10001 });
15
- this.privateKey = keypair.privateKey;
16
- this.publicKey = keypair.publicKey;
17
- }
18
- }
19
- /**
20
- * Import a PEM-formatted key (auto-detects PKCS#1 vs PKCS#8).
21
- */
22
- importKey(pem) {
23
- pem = pem.trim();
24
- if (pem.includes("-----BEGIN RSA PRIVATE KEY-----") || pem.includes("-----BEGIN PRIVATE KEY-----")) {
25
- this.privateKey = node_forge_1.default.pki.privateKeyFromPem(pem);
26
- this.publicKey = node_forge_1.default.pki.setRsaPublicKey(this.privateKey.n, this.privateKey.e);
27
- }
28
- else if (pem.includes("-----BEGIN RSA PUBLIC KEY-----") || pem.includes("-----BEGIN PUBLIC KEY-----")) {
29
- this.publicKey = node_forge_1.default.pki.publicKeyFromPem(pem);
30
- }
31
- else {
32
- throw new Error("Unsupported PEM format");
33
- }
34
- }
35
- /**
36
- * Export a key in a NodeRSA-like format.
37
- */
38
- exportKey(format) {
39
- switch (format) {
40
- case "pkcs1-private-pem":
41
- if (!this.privateKey)
42
- throw new Error("No private key loaded");
43
- return node_forge_1.default.pki.privateKeyToPem(this.privateKey);
44
- case "pkcs1-public-pem":
45
- if (!this.publicKey)
46
- throw new Error("No public key loaded");
47
- return node_forge_1.default.pki.publicKeyToPem(this.publicKey);
48
- case "pkcs8-private-pem":
49
- if (!this.privateKey)
50
- throw new Error("No private key loaded");
51
- return node_forge_1.default.pki.privateKeyToPem(this.privateKey); // forge doesn't distinguish PKCS#8 output
52
- case "pkcs8-public-pem":
53
- if (!this.publicKey)
54
- throw new Error("No public key loaded");
55
- return node_forge_1.default.pki.publicKeyToPem(this.publicKey);
56
- default:
57
- throw new Error(`Unsupported export format: ${format}`);
58
- }
59
- }
60
- /**
61
- * Set options (only encryptionScheme supported).
62
- */
63
- setOptions(options) {
64
- this.options = { ...this.options, ...options };
65
- }
66
- encrypt(data) {
67
- if (!this.publicKey)
68
- throw new Error("No public key loaded");
69
- const input = Buffer.isBuffer(data) ? data.toString("binary") : data;
70
- const scheme = this.options.encryptionScheme === "pkcs1_oaep" ? "RSA-OAEP" : "RSAES-PKCS1-V1_5";
71
- const encrypted = this.publicKey.encrypt(input, scheme);
72
- return node_forge_1.default.util.encode64(encrypted);
73
- }
74
- decrypt(encrypted) {
75
- if (!this.privateKey)
76
- throw new Error("No private key loaded");
77
- let encryptedBytes;
78
- if (Buffer.isBuffer(encrypted)) {
79
- encryptedBytes = encrypted.toString("binary");
80
- }
81
- else if (/^[A-Za-z0-9+/=]+$/.test(encrypted.trim())) {
82
- encryptedBytes = node_forge_1.default.util.decode64(encrypted);
83
- }
84
- else {
85
- encryptedBytes = encrypted;
86
- }
87
- const scheme = this.options.encryptionScheme === "pkcs1_oaep" ? "RSA-OAEP" : "RSAES-PKCS1-V1_5";
88
- const decrypted = this.privateKey.decrypt(encryptedBytes, scheme);
89
- // Convert forge binary string → Node Buffer
90
- return Buffer.from(decrypted, "binary");
91
- }
92
- /**
93
- * Get raw components of the public key
94
- */
95
- exportPublicComponents() {
96
- if (!this.publicKey)
97
- throw new Error("No public key loaded");
98
- const nBytes = this.publicKey.n.toByteArray(); // forge BigInteger → byte array
99
- const eBytes = this.publicKey.e.toByteArray();
100
- return {
101
- n: Uint8Array.from(nBytes),
102
- e: Uint8Array.from(eBytes),
103
- };
104
- }
105
- }
106
- exports.ForgeRSA = ForgeRSA;
107
- //# sourceMappingURL=forge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"forge.js","sourceRoot":"","sources":["../../src/p2p/forge.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAW/B,MAAa,QAAQ;IACT,UAAU,CAA4B;IACtC,SAAS,CAA2B;IACpC,OAAO,GAAoB,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC;IAEjE,YAAY,IAAa;QACrB,IAAI,IAAI,EAAE,CAAC;YACP,MAAM,OAAO,GAAG,oBAAK,CAAC,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;YACpE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;YACrC,IAAI,CAAC,SAAS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