@moltdm/client 1.1.0 → 1.3.0
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/dist/index.js +13 -2
- package/dist/index.mjs +13 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51,7 +51,8 @@ var MoltDMClient = class {
|
|
|
51
51
|
identity = null;
|
|
52
52
|
senderKeys = /* @__PURE__ */ new Map();
|
|
53
53
|
constructor(options = {}) {
|
|
54
|
-
|
|
54
|
+
const defaultStoragePath = process.env.OPENCLAW_STATE_DIR ? path.join(process.env.OPENCLAW_STATE_DIR, ".moltdm") : path.join(os.homedir(), ".moltdm");
|
|
55
|
+
this.storagePath = options.storagePath || defaultStoragePath;
|
|
55
56
|
this.relayUrl = options.relayUrl || "https://relay.moltdm.com";
|
|
56
57
|
if (options.identity) {
|
|
57
58
|
this.identity = options.identity;
|
|
@@ -436,9 +437,19 @@ var MoltDMClient = class {
|
|
|
436
437
|
}
|
|
437
438
|
async approvePairing(token) {
|
|
438
439
|
this.ensureInitialized();
|
|
440
|
+
const senderKeysObj = {};
|
|
441
|
+
for (const [convId, keyData] of this.senderKeys) {
|
|
442
|
+
senderKeysObj[convId] = toBase64(keyData.key);
|
|
443
|
+
}
|
|
444
|
+
const encryptionKeys = {
|
|
445
|
+
identityKey: this.identity.publicKey,
|
|
446
|
+
privateKey: this.identity.privateKey,
|
|
447
|
+
// Shared so device can sign/decrypt
|
|
448
|
+
senderKeys: senderKeysObj
|
|
449
|
+
};
|
|
439
450
|
const response = await this.fetch("/api/pair/approve", {
|
|
440
451
|
method: "POST",
|
|
441
|
-
body: JSON.stringify({ token })
|
|
452
|
+
body: JSON.stringify({ token, encryptionKeys })
|
|
442
453
|
});
|
|
443
454
|
const data = await response.json();
|
|
444
455
|
return data.device;
|
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,8 @@ var MoltDMClient = class {
|
|
|
16
16
|
identity = null;
|
|
17
17
|
senderKeys = /* @__PURE__ */ new Map();
|
|
18
18
|
constructor(options = {}) {
|
|
19
|
-
|
|
19
|
+
const defaultStoragePath = process.env.OPENCLAW_STATE_DIR ? path.join(process.env.OPENCLAW_STATE_DIR, ".moltdm") : path.join(os.homedir(), ".moltdm");
|
|
20
|
+
this.storagePath = options.storagePath || defaultStoragePath;
|
|
20
21
|
this.relayUrl = options.relayUrl || "https://relay.moltdm.com";
|
|
21
22
|
if (options.identity) {
|
|
22
23
|
this.identity = options.identity;
|
|
@@ -401,9 +402,19 @@ var MoltDMClient = class {
|
|
|
401
402
|
}
|
|
402
403
|
async approvePairing(token) {
|
|
403
404
|
this.ensureInitialized();
|
|
405
|
+
const senderKeysObj = {};
|
|
406
|
+
for (const [convId, keyData] of this.senderKeys) {
|
|
407
|
+
senderKeysObj[convId] = toBase64(keyData.key);
|
|
408
|
+
}
|
|
409
|
+
const encryptionKeys = {
|
|
410
|
+
identityKey: this.identity.publicKey,
|
|
411
|
+
privateKey: this.identity.privateKey,
|
|
412
|
+
// Shared so device can sign/decrypt
|
|
413
|
+
senderKeys: senderKeysObj
|
|
414
|
+
};
|
|
404
415
|
const response = await this.fetch("/api/pair/approve", {
|
|
405
416
|
method: "POST",
|
|
406
|
-
body: JSON.stringify({ token })
|
|
417
|
+
body: JSON.stringify({ token, encryptionKeys })
|
|
407
418
|
});
|
|
408
419
|
const data = await response.json();
|
|
409
420
|
return data.device;
|