@openclaw/nostr 2026.5.2 → 2026.5.3-beta.2

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.
Files changed (59) hide show
  1. package/dist/api.js +532 -0
  2. package/dist/channel-DfEqBtUh.js +1466 -0
  3. package/dist/channel-plugin-api.js +2 -0
  4. package/dist/config-schema-DIk4jlBg.js +64 -0
  5. package/dist/default-relays-DLwdWOTu.js +4 -0
  6. package/dist/inbound-direct-dm-runtime-22bZWcIW.js +2 -0
  7. package/dist/index.js +84 -0
  8. package/dist/runtime-api.js +2 -0
  9. package/dist/setup-api.js +2 -0
  10. package/dist/setup-entry.js +11 -0
  11. package/dist/setup-plugin-api.js +165 -0
  12. package/dist/setup-surface-DxAaUTyC.js +336 -0
  13. package/dist/test-api.js +2 -0
  14. package/package.json +15 -6
  15. package/api.ts +0 -10
  16. package/channel-plugin-api.ts +0 -1
  17. package/index.ts +0 -97
  18. package/runtime-api.ts +0 -6
  19. package/setup-api.ts +0 -1
  20. package/setup-entry.ts +0 -9
  21. package/setup-plugin-api.ts +0 -3
  22. package/src/channel-api.ts +0 -15
  23. package/src/channel.inbound.test.ts +0 -176
  24. package/src/channel.outbound.test.ts +0 -128
  25. package/src/channel.setup.ts +0 -231
  26. package/src/channel.test.ts +0 -519
  27. package/src/channel.ts +0 -207
  28. package/src/config-schema.ts +0 -98
  29. package/src/default-relays.ts +0 -1
  30. package/src/gateway.ts +0 -302
  31. package/src/inbound-direct-dm-runtime.ts +0 -1
  32. package/src/metrics.ts +0 -458
  33. package/src/nostr-bus.fuzz.test.ts +0 -360
  34. package/src/nostr-bus.inbound.test.ts +0 -526
  35. package/src/nostr-bus.integration.test.ts +0 -472
  36. package/src/nostr-bus.test.ts +0 -190
  37. package/src/nostr-bus.ts +0 -789
  38. package/src/nostr-key-utils.ts +0 -94
  39. package/src/nostr-profile-core.ts +0 -134
  40. package/src/nostr-profile-http-runtime.ts +0 -6
  41. package/src/nostr-profile-http.test.ts +0 -632
  42. package/src/nostr-profile-http.ts +0 -594
  43. package/src/nostr-profile-import.test.ts +0 -119
  44. package/src/nostr-profile-import.ts +0 -262
  45. package/src/nostr-profile-url-safety.ts +0 -21
  46. package/src/nostr-profile.fuzz.test.ts +0 -430
  47. package/src/nostr-profile.test.ts +0 -412
  48. package/src/nostr-profile.ts +0 -144
  49. package/src/nostr-state-store.test.ts +0 -237
  50. package/src/nostr-state-store.ts +0 -223
  51. package/src/runtime.ts +0 -9
  52. package/src/seen-tracker.ts +0 -289
  53. package/src/session-route.ts +0 -25
  54. package/src/setup-surface.ts +0 -265
  55. package/src/test-fixtures.ts +0 -45
  56. package/src/types.ts +0 -117
  57. package/test/setup.ts +0 -5
  58. package/test-api.ts +0 -1
  59. package/tsconfig.json +0 -16
package/src/types.ts DELETED
@@ -1,117 +0,0 @@
1
- import {
2
- DEFAULT_ACCOUNT_ID,
3
- normalizeAccountId,
4
- normalizeOptionalAccountId,
5
- } from "openclaw/plugin-sdk/account-id";
6
- import {
7
- listCombinedAccountIds,
8
- resolveListedDefaultAccountId,
9
- } from "openclaw/plugin-sdk/account-resolution";
10
- import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
11
- import { normalizeSecretInputString, type SecretInput } from "openclaw/plugin-sdk/secret-input";
12
- import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
13
- import type { NostrProfile } from "./config-schema.js";
14
- import { DEFAULT_RELAYS } from "./default-relays.js";
15
- import { getPublicKeyFromPrivate } from "./nostr-key-utils.js";
16
-
17
- interface NostrAccountConfig {
18
- enabled?: boolean;
19
- name?: string;
20
- defaultAccount?: string;
21
- privateKey?: SecretInput;
22
- relays?: string[];
23
- dmPolicy?: "pairing" | "allowlist" | "open" | "disabled";
24
- allowFrom?: Array<string | number>;
25
- profile?: NostrProfile;
26
- }
27
-
28
- export interface ResolvedNostrAccount {
29
- accountId: string;
30
- name?: string;
31
- enabled: boolean;
32
- configured: boolean;
33
- privateKey: string;
34
- publicKey: string;
35
- relays: string[];
36
- profile?: NostrProfile;
37
- config: NostrAccountConfig;
38
- }
39
-
40
- function resolveConfiguredDefaultNostrAccountId(cfg: OpenClawConfig): string | undefined {
41
- const nostrCfg = (cfg.channels as Record<string, unknown> | undefined)?.nostr as
42
- | NostrAccountConfig
43
- | undefined;
44
- return normalizeOptionalAccountId(nostrCfg?.defaultAccount);
45
- }
46
-
47
- /**
48
- * List all configured Nostr account IDs
49
- */
50
- export function listNostrAccountIds(cfg: OpenClawConfig): string[] {
51
- const nostrCfg = (cfg.channels as Record<string, unknown> | undefined)?.nostr as
52
- | NostrAccountConfig
53
- | undefined;
54
- const privateKey = normalizeSecretInputString(nostrCfg?.privateKey);
55
- return listCombinedAccountIds({
56
- configuredAccountIds: [],
57
- implicitAccountId: privateKey
58
- ? (resolveConfiguredDefaultNostrAccountId(cfg) ?? DEFAULT_ACCOUNT_ID)
59
- : undefined,
60
- });
61
- }
62
-
63
- /**
64
- * Get the default account ID
65
- */
66
- export function resolveDefaultNostrAccountId(cfg: OpenClawConfig): string {
67
- return resolveListedDefaultAccountId({
68
- accountIds: listNostrAccountIds(cfg),
69
- configuredDefaultAccountId: resolveConfiguredDefaultNostrAccountId(cfg),
70
- });
71
- }
72
-
73
- /**
74
- * Resolve a Nostr account from config
75
- */
76
- export function resolveNostrAccount(opts: {
77
- cfg: OpenClawConfig;
78
- accountId?: string | null;
79
- }): ResolvedNostrAccount {
80
- const accountId = normalizeAccountId(opts.accountId ?? resolveDefaultNostrAccountId(opts.cfg));
81
- const nostrCfg = (opts.cfg.channels as Record<string, unknown> | undefined)?.nostr as
82
- | NostrAccountConfig
83
- | undefined;
84
-
85
- const baseEnabled = nostrCfg?.enabled !== false;
86
- const privateKey = normalizeSecretInputString(nostrCfg?.privateKey) ?? "";
87
- const configured = Boolean(privateKey);
88
-
89
- let publicKey = "";
90
- if (privateKey) {
91
- try {
92
- publicKey = getPublicKeyFromPrivate(privateKey);
93
- } catch {
94
- // Invalid key - leave publicKey empty, configured will indicate issues
95
- }
96
- }
97
-
98
- return {
99
- accountId,
100
- name: normalizeOptionalString(nostrCfg?.name),
101
- enabled: baseEnabled,
102
- configured,
103
- privateKey,
104
- publicKey,
105
- relays: nostrCfg?.relays ?? DEFAULT_RELAYS,
106
- profile: nostrCfg?.profile,
107
- config: {
108
- enabled: nostrCfg?.enabled,
109
- name: nostrCfg?.name,
110
- privateKey: nostrCfg?.privateKey,
111
- relays: nostrCfg?.relays,
112
- dmPolicy: nostrCfg?.dmPolicy,
113
- allowFrom: nostrCfg?.allowFrom,
114
- profile: nostrCfg?.profile,
115
- },
116
- };
117
- }
package/test/setup.ts DELETED
@@ -1,5 +0,0 @@
1
- // Test setup file for nostr extension
2
- import { vi } from "vitest";
3
-
4
- // Mock console.error to suppress noise in tests
5
- vi.spyOn(console, "error").mockImplementation(() => {});
package/test-api.ts DELETED
@@ -1 +0,0 @@
1
- export { nostrPlugin } from "./src/channel.js";
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "extends": "../tsconfig.package-boundary.base.json",
3
- "compilerOptions": {
4
- "rootDir": "."
5
- },
6
- "include": ["./*.ts", "./src/**/*.ts"],
7
- "exclude": [
8
- "./**/*.test.ts",
9
- "./dist/**",
10
- "./node_modules/**",
11
- "./src/test-support/**",
12
- "./src/**/*test-helpers.ts",
13
- "./src/**/*test-harness.ts",
14
- "./src/**/*test-support.ts"
15
- ]
16
- }