@ih8e/express-cli 0.1.0 → 0.1.1
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 +6 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3001,15 +3001,15 @@ async function decryptMessages(events, apigwKeys, client = new ApiClient()) {
|
|
|
3001
3001
|
|
|
3002
3002
|
// src/api/messages-read.ts
|
|
3003
3003
|
async function readMessages(params) {
|
|
3004
|
-
const { chatId, limit = 20, timeoutMs = 2e4, direction = "backward" } = params;
|
|
3004
|
+
const { chatId, limit = 20, timeoutMs = 2e4, direction = "backward", host } = params;
|
|
3005
3005
|
const apigwKeys = loadApigwKeys();
|
|
3006
3006
|
if (!apigwKeys) throw new Error("No apigw keys. Run 'express auth login' first.");
|
|
3007
|
-
const config = loadConfig();
|
|
3008
|
-
const
|
|
3007
|
+
const config = loadConfig(host ? { host } : {});
|
|
3008
|
+
const ctsHost = new URL(getBaseUrl(config)).hostname;
|
|
3009
3009
|
const webOrigin = getWebOrigin(config);
|
|
3010
3010
|
const ctsToken = getAuthToken();
|
|
3011
3011
|
const ctsKey = apigwKeys.ctsKey ?? apigwKeys.encryptionKey;
|
|
3012
|
-
const history = await fetchEventsHistory(
|
|
3012
|
+
const history = await fetchEventsHistory(ctsHost, webOrigin, ctsToken, ctsKey.keyId, chatId, limit, timeoutMs, direction);
|
|
3013
3013
|
return decryptMessages(history, apigwKeys);
|
|
3014
3014
|
}
|
|
3015
3015
|
async function fetchEventsHistory(host, webOrigin, ctsToken, encKeyId, chatId, limit, timeoutMs, direction = "backward") {
|
|
@@ -3093,7 +3093,8 @@ function createMessagesCommand() {
|
|
|
3093
3093
|
try {
|
|
3094
3094
|
const messages = await readMessages({
|
|
3095
3095
|
chatId,
|
|
3096
|
-
limit: parseInt(opts.limit, 10) || 20
|
|
3096
|
+
limit: parseInt(opts.limit, 10) || 20,
|
|
3097
|
+
host: opts.host
|
|
3097
3098
|
});
|
|
3098
3099
|
if (opts.output === "json") {
|
|
3099
3100
|
console.log(formatOutput(messages, opts.output));
|