@kodelyth/nostr 2026.5.42 → 2026.6.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.
Files changed (47) hide show
  1. package/klaw.plugin.json +185 -2
  2. package/package.json +17 -4
  3. package/api.ts +0 -10
  4. package/channel-plugin-api.ts +0 -1
  5. package/index.ts +0 -95
  6. package/runtime-api.ts +0 -6
  7. package/setup-api.ts +0 -1
  8. package/setup-entry.ts +0 -9
  9. package/setup-plugin-api.ts +0 -3
  10. package/src/channel-api.ts +0 -11
  11. package/src/channel.inbound.test.ts +0 -187
  12. package/src/channel.outbound.test.ts +0 -163
  13. package/src/channel.setup.ts +0 -234
  14. package/src/channel.test.ts +0 -526
  15. package/src/channel.ts +0 -215
  16. package/src/config-schema.ts +0 -98
  17. package/src/default-relays.ts +0 -1
  18. package/src/gateway.ts +0 -321
  19. package/src/inbound-direct-dm-runtime.ts +0 -1
  20. package/src/metrics.ts +0 -458
  21. package/src/nostr-bus.fuzz.test.ts +0 -382
  22. package/src/nostr-bus.inbound.test.ts +0 -526
  23. package/src/nostr-bus.integration.test.ts +0 -477
  24. package/src/nostr-bus.test.ts +0 -231
  25. package/src/nostr-bus.ts +0 -789
  26. package/src/nostr-key-utils.ts +0 -94
  27. package/src/nostr-profile-core.ts +0 -134
  28. package/src/nostr-profile-http-runtime.ts +0 -6
  29. package/src/nostr-profile-http.test.ts +0 -632
  30. package/src/nostr-profile-http.ts +0 -583
  31. package/src/nostr-profile-import.test.ts +0 -119
  32. package/src/nostr-profile-import.ts +0 -262
  33. package/src/nostr-profile-url-safety.ts +0 -21
  34. package/src/nostr-profile.fuzz.test.ts +0 -430
  35. package/src/nostr-profile.test.ts +0 -415
  36. package/src/nostr-profile.ts +0 -144
  37. package/src/nostr-state-store.test.ts +0 -237
  38. package/src/nostr-state-store.ts +0 -206
  39. package/src/runtime.ts +0 -9
  40. package/src/seen-tracker.ts +0 -289
  41. package/src/session-route.ts +0 -25
  42. package/src/setup-surface.ts +0 -264
  43. package/src/test-fixtures.ts +0 -45
  44. package/src/types.ts +0 -117
  45. package/test/setup.ts +0 -5
  46. package/test-api.ts +0 -1
  47. 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 "klaw/plugin-sdk/account-id";
6
- import {
7
- listCombinedAccountIds,
8
- resolveListedDefaultAccountId,
9
- } from "klaw/plugin-sdk/account-resolution";
10
- import type { KlawConfig } from "klaw/plugin-sdk/config-contracts";
11
- import { normalizeSecretInputString, type SecretInput } from "klaw/plugin-sdk/secret-input";
12
- import { normalizeOptionalString } from "klaw/plugin-sdk/string-coerce-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: KlawConfig): 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: KlawConfig): 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: KlawConfig): 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: KlawConfig;
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
- }