@elizaos/core 1.6.3-alpha.5 → 1.6.3-alpha.7
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/browser/index.browser.js +80 -80
- package/dist/browser/index.browser.js.map +6 -5
- package/dist/node/index.node.js +52 -14
- package/dist/node/index.node.js.map +6 -5
- package/dist/settings.d.ts.map +1 -1
- package/dist/utils/buffer.d.ts.map +1 -1
- package/dist/utils/crypto-compat.d.ts +184 -0
- package/dist/utils/crypto-compat.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/node/index.node.js
CHANGED
|
@@ -42290,15 +42290,10 @@ function byteLength(buffer) {
|
|
|
42290
42290
|
return buffer.length;
|
|
42291
42291
|
}
|
|
42292
42292
|
function randomBytes(size) {
|
|
42293
|
-
if (hasNativeBuffer()) {
|
|
42294
|
-
try {
|
|
42295
|
-
const crypto = __require("crypto");
|
|
42296
|
-
return crypto.randomBytes(size);
|
|
42297
|
-
} catch {}
|
|
42298
|
-
}
|
|
42299
42293
|
const bytes = new Uint8Array(size);
|
|
42300
|
-
|
|
42301
|
-
|
|
42294
|
+
const cryptoGlobal = typeof globalThis !== "undefined" ? globalThis.crypto || globalThis.webcrypto : undefined;
|
|
42295
|
+
if (cryptoGlobal && typeof cryptoGlobal.getRandomValues === "function") {
|
|
42296
|
+
cryptoGlobal.getRandomValues(bytes);
|
|
42302
42297
|
} else {
|
|
42303
42298
|
for (let i = 0;i < size; i++) {
|
|
42304
42299
|
bytes[i] = Math.floor(Math.random() * 256);
|
|
@@ -46562,8 +46557,51 @@ async function setDefaultSecretsFromEnv(character) {
|
|
|
46562
46557
|
}
|
|
46563
46558
|
|
|
46564
46559
|
// src/settings.ts
|
|
46565
|
-
var import_crypto_browserify = __toESM(require_crypto_browserify(), 1);
|
|
46566
46560
|
init_environment();
|
|
46561
|
+
|
|
46562
|
+
// src/utils/crypto-compat.ts
|
|
46563
|
+
function hasNodeCrypto() {
|
|
46564
|
+
try {
|
|
46565
|
+
return typeof process !== "undefined" && (process.versions?.node !== undefined || process.versions?.bun !== undefined);
|
|
46566
|
+
} catch {
|
|
46567
|
+
return false;
|
|
46568
|
+
}
|
|
46569
|
+
}
|
|
46570
|
+
function getCryptoModule() {
|
|
46571
|
+
if (hasNodeCrypto()) {
|
|
46572
|
+
return __require("crypto");
|
|
46573
|
+
}
|
|
46574
|
+
return require_crypto_browserify();
|
|
46575
|
+
}
|
|
46576
|
+
function createHash(algorithm) {
|
|
46577
|
+
const crypto = getCryptoModule();
|
|
46578
|
+
const hash = crypto.createHash(algorithm);
|
|
46579
|
+
return {
|
|
46580
|
+
update(data2) {
|
|
46581
|
+
hash.update(data2);
|
|
46582
|
+
return this;
|
|
46583
|
+
},
|
|
46584
|
+
digest() {
|
|
46585
|
+
return new Uint8Array(hash.digest());
|
|
46586
|
+
}
|
|
46587
|
+
};
|
|
46588
|
+
}
|
|
46589
|
+
function createCipheriv(algorithm, key, iv) {
|
|
46590
|
+
if (algorithm !== "aes-256-cbc") {
|
|
46591
|
+
throw new Error(`Unsupported algorithm: ${algorithm}. Only 'aes-256-cbc' is currently supported.`);
|
|
46592
|
+
}
|
|
46593
|
+
const crypto = getCryptoModule();
|
|
46594
|
+
return crypto.createCipheriv(algorithm, key, iv);
|
|
46595
|
+
}
|
|
46596
|
+
function createDecipheriv(algorithm, key, iv) {
|
|
46597
|
+
if (algorithm !== "aes-256-cbc") {
|
|
46598
|
+
throw new Error(`Unsupported algorithm: ${algorithm}. Only 'aes-256-cbc' is currently supported.`);
|
|
46599
|
+
}
|
|
46600
|
+
const crypto = getCryptoModule();
|
|
46601
|
+
return crypto.createDecipheriv(algorithm, key, iv);
|
|
46602
|
+
}
|
|
46603
|
+
|
|
46604
|
+
// src/settings.ts
|
|
46567
46605
|
function createSettingFromConfig(configSetting) {
|
|
46568
46606
|
return {
|
|
46569
46607
|
name: configSetting.name,
|
|
@@ -46628,9 +46666,9 @@ function encryptStringValue(value, salt) {
|
|
|
46628
46666
|
}
|
|
46629
46667
|
} catch (e) {}
|
|
46630
46668
|
}
|
|
46631
|
-
const key =
|
|
46669
|
+
const key = createHash("sha256").update(salt).digest().slice(0, 32);
|
|
46632
46670
|
const iv = BufferUtils.randomBytes(16);
|
|
46633
|
-
const cipher =
|
|
46671
|
+
const cipher = createCipheriv("aes-256-cbc", key, iv);
|
|
46634
46672
|
let encrypted = cipher.update(value, "utf8", "hex");
|
|
46635
46673
|
encrypted += cipher.final("hex");
|
|
46636
46674
|
return `${BufferUtils.toHex(iv)}:${encrypted}`;
|
|
@@ -46659,8 +46697,8 @@ function decryptStringValue(value, salt) {
|
|
|
46659
46697
|
}
|
|
46660
46698
|
return value;
|
|
46661
46699
|
}
|
|
46662
|
-
const key =
|
|
46663
|
-
const decipher =
|
|
46700
|
+
const key = createHash("sha256").update(salt).digest().slice(0, 32);
|
|
46701
|
+
const decipher = createDecipheriv("aes-256-cbc", key, iv);
|
|
46664
46702
|
let decrypted = decipher.update(encrypted, "hex", "utf8");
|
|
46665
46703
|
decrypted += decipher.final("utf8");
|
|
46666
46704
|
return decrypted;
|
|
@@ -47711,5 +47749,5 @@ export {
|
|
|
47711
47749
|
AgentRuntime
|
|
47712
47750
|
};
|
|
47713
47751
|
|
|
47714
|
-
//# debugId=
|
|
47752
|
+
//# debugId=C29D4E4AA762AF9664756E2164756E21
|
|
47715
47753
|
//# sourceMappingURL=index.node.js.map
|