morpheus-cli 0.6.4 → 0.6.6
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/README.md +7 -1
- package/dist/channels/discord.js +3 -2
- package/dist/channels/telegram.js +5 -4
- package/dist/cli/commands/start.js +30 -0
- package/dist/config/manager.js +117 -1
- package/dist/config/precedence.js +107 -0
- package/dist/http/api.js +29 -0
- package/dist/runtime/chronos/parser.js +66 -3
- package/dist/runtime/chronos/parser.test.js +65 -0
- package/dist/runtime/providers/factory.js +7 -5
- package/dist/runtime/trinity-crypto.js +51 -0
- package/dist/ui/assets/index-B9BClunx.js +111 -0
- package/dist/ui/assets/index-B9ngtbja.css +1 -0
- package/dist/ui/index.html +2 -2
- package/dist/ui/sw.js +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/index-BDWWF6gM.css +0 -1
- package/dist/ui/assets/index-DTUgtIcM.js +0 -111
|
@@ -50,3 +50,54 @@ export function decrypt(ciphertext) {
|
|
|
50
50
|
export function canEncrypt() {
|
|
51
51
|
return !!process.env.MORPHEUS_SECRET;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Checks if a string appears to be an encrypted value.
|
|
55
|
+
* Format: base64(iv):base64(authTag):base64(ciphertext)
|
|
56
|
+
*/
|
|
57
|
+
export function looksLikeEncrypted(value) {
|
|
58
|
+
const parts = value.split(':');
|
|
59
|
+
if (parts.length !== 3)
|
|
60
|
+
return false;
|
|
61
|
+
// Each part should be valid base64
|
|
62
|
+
return parts.every(part => {
|
|
63
|
+
try {
|
|
64
|
+
const decoded = Buffer.from(part, 'base64');
|
|
65
|
+
return decoded.toString('base64') === part;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Safely decrypts a value, returning null if decryption fails.
|
|
74
|
+
* Use this for fail-open scenarios where MORPHEUS_SECRET may not be set.
|
|
75
|
+
*/
|
|
76
|
+
export function safeDecrypt(ciphertext) {
|
|
77
|
+
if (!ciphertext)
|
|
78
|
+
return null;
|
|
79
|
+
try {
|
|
80
|
+
return decrypt(ciphertext);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Gets the usable API key from a potentially encrypted value.
|
|
88
|
+
* If the value looks encrypted, attempts to decrypt it.
|
|
89
|
+
* If decryption fails or MORPHEUS_SECRET is not set, returns the original value.
|
|
90
|
+
* Use this when you need the actual plaintext key for API calls.
|
|
91
|
+
*/
|
|
92
|
+
export function getUsableApiKey(encryptedOrPlain) {
|
|
93
|
+
if (!encryptedOrPlain)
|
|
94
|
+
return undefined;
|
|
95
|
+
// If it looks encrypted, try to decrypt
|
|
96
|
+
if (looksLikeEncrypted(encryptedOrPlain)) {
|
|
97
|
+
const decrypted = safeDecrypt(encryptedOrPlain);
|
|
98
|
+
// If decryption succeeded, return it; otherwise return original
|
|
99
|
+
return decrypted ?? encryptedOrPlain;
|
|
100
|
+
}
|
|
101
|
+
// Not encrypted, return as-is
|
|
102
|
+
return encryptedOrPlain;
|
|
103
|
+
}
|