mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 18:51:04 +00:00
Tests: fix nostr package boundary drift
This commit is contained in:
@@ -64,7 +64,7 @@ describe("nostr outbound cfg threading", () => {
|
||||
)) as { stop: () => void };
|
||||
|
||||
const cfg = createCfg();
|
||||
await nostrOutboundAdapter.sendText({
|
||||
await nostrOutboundAdapter.sendText!({
|
||||
cfg: cfg as OpenClawConfig,
|
||||
to: "NPUB123",
|
||||
text: "|a|b|",
|
||||
@@ -121,7 +121,7 @@ describe("nostr outbound cfg threading", () => {
|
||||
},
|
||||
};
|
||||
|
||||
await nostrOutboundAdapter.sendText({
|
||||
await nostrOutboundAdapter.sendText!({
|
||||
cfg: cfg as OpenClawConfig,
|
||||
to: "NPUB123",
|
||||
text: "hello",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing";
|
||||
import { attachChannelToResult } from "openclaw/plugin-sdk/channel-send-result";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import {
|
||||
createPreCryptoDirectDmAuthorizer,
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
@@ -9,16 +10,12 @@ import {
|
||||
} from "./channel-api.js";
|
||||
import type { MetricEvent, MetricsSnapshot } from "./metrics.js";
|
||||
import { normalizePubkey, startNostrBus, type NostrBusHandle } from "./nostr-bus.js";
|
||||
import type { OpenClawConfig } from "./runtime-api.js";
|
||||
import { getNostrRuntime } from "./runtime.js";
|
||||
import { resolveDefaultNostrAccountId, type ResolvedNostrAccount } from "./types.js";
|
||||
|
||||
type NostrGatewayStart = NonNullable<
|
||||
NonNullable<ChannelPlugin<ResolvedNostrAccount>["gateway"]>["startAccount"]
|
||||
>;
|
||||
type NostrPairingText = NonNullable<
|
||||
NonNullable<NonNullable<ChannelPlugin<ResolvedNostrAccount>["pairing"]>["text"]>
|
||||
>;
|
||||
type NostrOutbound = NonNullable<ChannelPlugin<ResolvedNostrAccount>["outbound"]>;
|
||||
|
||||
const activeBuses = new Map<string, NostrBusHandle>();
|
||||
@@ -241,20 +238,27 @@ export const startNostrGatewayAccount: NostrGatewayStart = async (ctx) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const nostrPairingTextAdapter: Pick<
|
||||
NostrPairingText,
|
||||
"idLabel" | "message" | "normalizeAllowEntry" | "notify"
|
||||
> = {
|
||||
export const nostrPairingTextAdapter = {
|
||||
idLabel: "nostrPubkey",
|
||||
message: "Your pairing request has been approved!",
|
||||
normalizeAllowEntry: (entry) => {
|
||||
normalizeAllowEntry: (entry: string) => {
|
||||
try {
|
||||
return normalizePubkey(entry.trim().replace(/^nostr:/i, ""));
|
||||
} catch {
|
||||
return entry.trim();
|
||||
}
|
||||
},
|
||||
notify: async ({ cfg, id, message, accountId }) => {
|
||||
notify: async ({
|
||||
cfg,
|
||||
id,
|
||||
message,
|
||||
accountId,
|
||||
}: {
|
||||
cfg: OpenClawConfig;
|
||||
id: string;
|
||||
message: string;
|
||||
accountId?: string;
|
||||
}) => {
|
||||
const bus = activeBuses.get(accountId ?? resolveDefaultNostrAccountId(cfg));
|
||||
if (bus) {
|
||||
await bus.sendDm(id, message);
|
||||
|
||||
Reference in New Issue
Block a user