canary-kit 0.10.0 → 1.0.0

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/nostr.d.ts CHANGED
@@ -1,17 +1,22 @@
1
1
  /**
2
- * Canary Nostr event kinds (NIP-CANARY).
2
+ * NIP-XX Nostr transport builders for Simple Shared Secret (SSG) groups.
3
3
  *
4
- * - group + memberUpdate: parameterised replaceable (30000–39999)
5
- * - seedDistribution, reseed, wordUsed: ephemeral (20000–29999)
6
- * - beacon: ephemeral (20000–29999)
4
+ * Three event kinds are used:
5
+ *
6
+ * - **kind 30078** (parameterised replaceable) — group state and stored signals.
7
+ * The d-tag uses the `ssg/` namespace prefix.
8
+ * - **kind 20078** (ephemeral) — real-time signals between group members.
9
+ * - **kind 14** (rumour / unsigned inner event) — NIP-17 gift-wrapped DMs carrying
10
+ * seed distribution, reseed, and other private payloads.
11
+ *
12
+ * Builders return unsigned events (`UnsignedEvent`). The consumer is responsible for
13
+ * signing (NIP-01), encrypting content (NIP-44), and wrapping (NIP-59) as needed.
7
14
  */
15
+ /** NIP-XX event kinds used by SSG groups. */
8
16
  export declare const KINDS: {
9
- readonly group: 38800;
10
- readonly seedDistribution: 28800;
11
- readonly memberUpdate: 38801;
12
- readonly reseed: 28801;
13
- readonly wordUsed: 28802;
14
- readonly beacon: 20800;
17
+ readonly groupState: 30078;
18
+ readonly signal: 20078;
19
+ readonly giftWrap: 1059;
15
20
  };
16
21
  /** Unsigned Nostr event (consumer signs with their own library). */
17
22
  export interface UnsignedEvent {
@@ -20,83 +25,39 @@ export interface UnsignedEvent {
20
25
  tags: string[][];
21
26
  created_at: number;
22
27
  }
23
- export interface GroupEventParams {
28
+ export interface GroupStateEventParams {
24
29
  groupId: string;
25
- name: string;
26
30
  members: string[];
27
- rotationInterval: number;
28
- wordCount: 1 | 2 | 3;
29
- wordlist: string;
30
31
  encryptedContent: string;
32
+ rotationInterval?: number;
33
+ tolerance?: number;
31
34
  expiration?: number;
32
35
  }
33
- /**
34
- * Build an unsigned kind 38800 group definition event.
35
- *
36
- * @param params - Group event parameters including groupId, name, members, and encrypted content.
37
- * @returns An {@link UnsignedEvent} ready to be signed and published.
38
- * @throws {Error} If groupId/name are invalid, member pubkeys are malformed, rotationInterval is non-positive, or wordCount is not 1/2/3.
39
- */
40
- export declare function buildGroupEvent(params: GroupEventParams): UnsignedEvent;
41
- export interface SeedDistributionParams {
42
- recipientPubkey: string;
43
- groupEventId: string;
44
- encryptedContent: string;
45
- }
46
- /**
47
- * Build an unsigned kind 28800 seed distribution event.
48
- *
49
- * @param params - Seed distribution parameters including recipient pubkey, group event ID, and encrypted seed.
50
- * @returns An {@link UnsignedEvent} ready to be signed and published.
51
- * @throws {Error} If recipientPubkey or groupEventId are not valid 64-character hex strings.
52
- */
53
- export declare function buildSeedDistributionEvent(params: SeedDistributionParams): UnsignedEvent;
54
- export interface MemberUpdateParams {
36
+ export interface StoredSignalEventParams {
55
37
  groupId: string;
56
- action: 'add' | 'remove';
57
- memberPubkey: string;
58
- reseed: boolean;
38
+ signalType: string;
59
39
  encryptedContent: string;
60
40
  }
61
- /**
62
- * Build an unsigned kind 38801 member update event (add or remove).
63
- *
64
- * @param params - Member update parameters including groupId, action ('add' | 'remove'), member pubkey, and reseed flag.
65
- * @returns An {@link UnsignedEvent} ready to be signed and published.
66
- * @throws {Error} If action is not 'add' or 'remove', or pubkey/groupId are invalid.
67
- */
68
- export declare function buildMemberUpdateEvent(params: MemberUpdateParams): UnsignedEvent;
69
- export interface ReseedParams {
70
- groupEventId: string;
71
- reason: 'member_removed' | 'compromise' | 'scheduled' | 'duress';
41
+ export interface SignalEventParams {
42
+ groupId: string;
43
+ signalType: string;
72
44
  encryptedContent: string;
73
45
  }
74
- /**
75
- * Build an unsigned kind 28801 reseed notification event.
76
- *
77
- * @param params - Reseed parameters including group event ID, reason, and encrypted new seed.
78
- * @returns An {@link UnsignedEvent} ready to be signed and published.
79
- * @throws {Error} If groupEventId is not a valid 64-character hex string or reason is invalid.
80
- */
81
- export declare function buildReseedEvent(params: ReseedParams): UnsignedEvent;
82
- export interface WordUsedParams {
83
- groupEventId: string;
46
+ export interface RumourEventParams {
47
+ recipientPubkey: string;
48
+ subject: string;
84
49
  encryptedContent: string;
50
+ groupEventId?: string;
85
51
  }
86
- /**
87
- * Build an unsigned kind 28802 word-used (burn-after-use) event.
88
- *
89
- * @param params - Word-used parameters including group event ID and encrypted content.
90
- * @returns An {@link UnsignedEvent} ready to be signed and published.
91
- * @throws {Error} If groupEventId is not a valid 64-character hex string.
92
- */
93
- export declare function buildWordUsedEvent(params: WordUsedParams): UnsignedEvent;
94
- export interface BeaconEventParams {
95
- groupId: string;
96
- encryptedContent: string;
97
- expiration?: number;
52
+ /** Plaintext payload for group configuration (kind 30078 encrypted content). */
53
+ export interface GroupConfigPayload {
54
+ description: string;
55
+ policies: {
56
+ invite_by: 'admin' | 'any_member';
57
+ reseed_by: 'admin' | 'any_admin';
58
+ };
98
59
  }
99
- /** Plaintext payload for kind 28800 (seed distribution). */
60
+ /** Plaintext payload for seed distribution (kind 14 rumour). */
100
61
  export interface SeedDistributionPayload {
101
62
  seed: string;
102
63
  /** Allows re-seeding mid-window without waiting for the next natural time rotation. */
@@ -104,31 +65,86 @@ export interface SeedDistributionPayload {
104
65
  /** The group's d-tag value (group identifier). */
105
66
  group_d: string;
106
67
  }
107
- /** Plaintext payload for kind 38800 encrypted content (group configuration). */
108
- export interface GroupEventPayload {
109
- description: string;
110
- policies: {
111
- invite_by: 'creator' | 'any_member';
112
- reseed_by: 'creator' | 'any_admin';
113
- };
114
- }
115
- /** Plaintext payload for kind 28801 (reseed notification). */
68
+ /** Plaintext payload for reseed notification (kind 14 rumour). */
116
69
  export interface ReseedPayload {
117
70
  seed: string;
118
71
  reason: 'member_removed' | 'compromise' | 'scheduled' | 'duress';
119
72
  }
120
- /** Plaintext payload for kind 28802 (word used / burn-after-use). */
73
+ /** Plaintext payload for member update (kind 14 rumour). */
74
+ export interface MemberUpdatePayload {
75
+ action: 'add' | 'remove';
76
+ member: string;
77
+ reseed: boolean;
78
+ }
79
+ /** Plaintext payload for counter advance (kind 20078 signal). */
80
+ export interface CounterAdvancePayload {
81
+ new_counter: number;
82
+ }
83
+ /** Plaintext payload for word-used / burn-after-use (kind 20078 signal). */
121
84
  export interface WordUsedPayload {
122
85
  new_counter: number;
123
86
  used_by: string;
124
87
  duress: boolean;
125
88
  }
89
+ export declare function validatePubkey(pubkey: string, label: string): void;
90
+ export declare function validateTagString(value: string, label: string): void;
91
+ export declare function validateExpiration(expiration: number): void;
92
+ export declare function validateEventId(eventId: string, label: string): void;
93
+ /**
94
+ * SHA-256 hash a group ID for use in d-tags where privacy matters.
95
+ *
96
+ * Duplicates hashGroupTag from sync-crypto.ts — kept independent to avoid
97
+ * coupling builders to sync layer.
98
+ */
99
+ export declare function hashGroupId(groupId: string): string;
100
+ /**
101
+ * Build an unsigned kind 30078 group state event.
102
+ *
103
+ * The d-tag uses plaintext `ssg/<groupId>` since content is NIP-44 encrypted.
104
+ * Includes NIP-32 labels for SSG namespace and p-tags for each member.
105
+ *
106
+ * @param params - Group state parameters.
107
+ * @returns An {@link UnsignedEvent} ready to be signed and published.
108
+ * @throws {Error} If groupId is invalid, member pubkeys are malformed, or optional
109
+ * numeric fields are out of range.
110
+ */
111
+ export declare function buildGroupStateEvent(params: GroupStateEventParams): UnsignedEvent;
112
+ /**
113
+ * Build an unsigned kind 30078 stored signal event.
114
+ *
115
+ * The d-tag uses a SHA-256 hash of the group ID (for privacy) scoped by signal type:
116
+ * `ssg/<SHA256(groupId)>:<signalType>`.
117
+ *
118
+ * Includes a 7-day NIP-40 expiration tag.
119
+ *
120
+ * @param params - Stored signal parameters.
121
+ * @returns An {@link UnsignedEvent} ready to be signed and published.
122
+ * @throws {Error} If groupId or signalType are empty.
123
+ */
124
+ export declare function buildStoredSignalEvent(params: StoredSignalEventParams): UnsignedEvent;
126
125
  /**
127
- * Build an unsigned kind 20800 beacon event.
126
+ * Build an unsigned kind 20078 ephemeral signal event.
127
+ *
128
+ * The d-tag uses a SHA-256 hash of the group ID (for privacy):
129
+ * `ssg/<SHA256(groupId)>`. A t-tag carries the signal type.
130
+ *
131
+ * No expiration tag — ephemeral events are not stored by relays.
128
132
  *
129
- * @param params - Beacon event parameters including groupId, encrypted content, and optional expiration.
133
+ * @param params - Signal parameters.
130
134
  * @returns An {@link UnsignedEvent} ready to be signed and published.
131
- * @throws {Error} If groupId is invalid or expiration is not a non-negative integer.
135
+ * @throws {Error} If groupId or signalType are empty.
136
+ */
137
+ export declare function buildSignalEvent(params: SignalEventParams): UnsignedEvent;
138
+ /**
139
+ * Build an unsigned kind 14 rumour event for NIP-17 gift wrapping.
140
+ *
141
+ * The consumer must set the `pubkey` field before computing the event ID.
142
+ * The rumour is then sealed (NIP-44 encrypt + kind 13) and gift-wrapped
143
+ * (kind 1059) by the caller.
144
+ *
145
+ * @param params - Rumour parameters including recipient and subject.
146
+ * @returns An {@link UnsignedEvent} ready for NIP-59 wrapping.
147
+ * @throws {Error} If recipientPubkey is invalid, subject is empty, or groupEventId is invalid.
132
148
  */
133
- export declare function buildBeaconEvent(params: BeaconEventParams): UnsignedEvent;
149
+ export declare function buildRumourEvent(params: RumourEventParams): UnsignedEvent;
134
150
  //# sourceMappingURL=nostr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nostr.d.ts","sourceRoot":"","sources":["../src/nostr.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,KAAK;;;;;;;CAOR,CAAA;AAEV,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB;AA8BD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAA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iEAAiE;AACjE,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;CAChB;AASD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAIlE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAOpE;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAI3D;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAIpE;AAcD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,qBAAqB,GAAG,aAAa,CAgCjF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,uBAAuB,GAAG,aAAa,CAkBrF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,CAgBzE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,CAwBzE"}
package/dist/nostr.js CHANGED
@@ -1,34 +1,36 @@
1
1
  /**
2
- * Canary Nostr event kinds (NIP-CANARY).
2
+ * NIP-XX Nostr transport builders for Simple Shared Secret (SSG) groups.
3
3
  *
4
- * - group + memberUpdate: parameterised replaceable (30000–39999)
5
- * - seedDistribution, reseed, wordUsed: ephemeral (20000–29999)
6
- * - beacon: ephemeral (20000–29999)
4
+ * Three event kinds are used:
5
+ *
6
+ * - **kind 30078** (parameterised replaceable) — group state and stored signals.
7
+ * The d-tag uses the `ssg/` namespace prefix.
8
+ * - **kind 20078** (ephemeral) — real-time signals between group members.
9
+ * - **kind 14** (rumour / unsigned inner event) — NIP-17 gift-wrapped DMs carrying
10
+ * seed distribution, reseed, and other private payloads.
11
+ *
12
+ * Builders return unsigned events (`UnsignedEvent`). The consumer is responsible for
13
+ * signing (NIP-01), encrypting content (NIP-44), and wrapping (NIP-59) as needed.
7
14
  */
15
+ import { sha256, bytesToHex } from './crypto.js';
16
+ // ── Constants ────────────────────────────────────────────────────────────────
17
+ /** NIP-XX event kinds used by SSG groups. */
8
18
  export const KINDS = {
9
- group: 38_800,
10
- seedDistribution: 28_800,
11
- memberUpdate: 38_801,
12
- reseed: 28_801,
13
- wordUsed: 28_802,
14
- beacon: 20_800,
19
+ groupState: 30_078,
20
+ signal: 20_078,
21
+ giftWrap: 1_059,
15
22
  };
16
- function now() {
17
- return Math.floor(Date.now() / 1000);
18
- }
23
+ // ── Validation helpers ───────────────────────────────────────────────────────
19
24
  const HEX_64_RE = /^[0-9a-f]{64}$/;
20
25
  const MAX_TAG_LENGTH = 256;
21
- function validatePubkey(pubkey, label) {
26
+ /** Maximum encrypted content length (64 KB — aligns with typical Nostr relay limits). */
27
+ const MAX_CONTENT_LENGTH = 65_536;
28
+ export function validatePubkey(pubkey, label) {
22
29
  if (!HEX_64_RE.test(pubkey)) {
23
30
  throw new Error(`Invalid ${label}: expected 64 lowercase hex characters, got ${pubkey.length} chars`);
24
31
  }
25
32
  }
26
- function validateEventId(eventId, label) {
27
- if (!HEX_64_RE.test(eventId)) {
28
- throw new Error(`Invalid ${label}: expected 64 lowercase hex characters, got ${eventId.length} chars`);
29
- }
30
- }
31
- function validateTagString(value, label) {
33
+ export function validateTagString(value, label) {
32
34
  if (typeof value !== 'string' || value.length === 0) {
33
35
  throw new Error(`Invalid ${label}: must be a non-empty string`);
34
36
  }
@@ -36,140 +38,161 @@ function validateTagString(value, label) {
36
38
  throw new Error(`Invalid ${label}: exceeds maximum length of ${MAX_TAG_LENGTH} characters`);
37
39
  }
38
40
  }
41
+ export function validateExpiration(expiration) {
42
+ if (!Number.isInteger(expiration) || expiration < 0) {
43
+ throw new Error('expiration must be a non-negative integer');
44
+ }
45
+ }
46
+ export function validateEventId(eventId, label) {
47
+ if (!HEX_64_RE.test(eventId)) {
48
+ throw new Error(`Invalid ${label}: expected 64 lowercase hex characters, got ${eventId.length} chars`);
49
+ }
50
+ }
51
+ function validateContent(content) {
52
+ if (content.length > MAX_CONTENT_LENGTH) {
53
+ throw new Error(`encryptedContent exceeds maximum length of ${MAX_CONTENT_LENGTH} characters`);
54
+ }
55
+ }
56
+ // ── Helpers ──────────────────────────────────────────────────────────────────
57
+ function now() {
58
+ return Math.floor(Date.now() / 1000);
59
+ }
39
60
  /**
40
- * Build an unsigned kind 38800 group definition event.
61
+ * SHA-256 hash a group ID for use in d-tags where privacy matters.
41
62
  *
42
- * @param params - Group event parameters including groupId, name, members, and encrypted content.
63
+ * Duplicates hashGroupTag from sync-crypto.ts kept independent to avoid
64
+ * coupling builders to sync layer.
65
+ */
66
+ export function hashGroupId(groupId) {
67
+ return bytesToHex(sha256(new TextEncoder().encode(groupId)));
68
+ }
69
+ // ── Builder functions ────────────────────────────────────────────────────────
70
+ /**
71
+ * Build an unsigned kind 30078 group state event.
72
+ *
73
+ * The d-tag uses plaintext `ssg/<groupId>` since content is NIP-44 encrypted.
74
+ * Includes NIP-32 labels for SSG namespace and p-tags for each member.
75
+ *
76
+ * @param params - Group state parameters.
43
77
  * @returns An {@link UnsignedEvent} ready to be signed and published.
44
- * @throws {Error} If groupId/name are invalid, member pubkeys are malformed, rotationInterval is non-positive, or wordCount is not 1/2/3.
78
+ * @throws {Error} If groupId is invalid, member pubkeys are malformed, or optional
79
+ * numeric fields are out of range.
45
80
  */
46
- export function buildGroupEvent(params) {
81
+ export function buildGroupStateEvent(params) {
47
82
  validateTagString(params.groupId, 'groupId');
48
- validateTagString(params.name, 'name');
83
+ validateContent(params.encryptedContent);
49
84
  for (const m of params.members)
50
85
  validatePubkey(m, 'member pubkey');
51
- if (!Number.isInteger(params.rotationInterval) || params.rotationInterval <= 0) {
52
- throw new Error(`Invalid rotationInterval: must be a positive integer, got ${params.rotationInterval}`);
53
- }
54
- if (params.wordCount !== 1 && params.wordCount !== 2 && params.wordCount !== 3) {
55
- throw new Error(`Invalid wordCount: must be 1, 2, or 3, got ${params.wordCount}`);
56
- }
57
86
  const tags = [
58
- ['d', params.groupId],
59
- ['name', params.name],
87
+ ['d', `ssg/${params.groupId}`],
60
88
  ...params.members.map((m) => ['p', m]),
61
- ['rotation', String(params.rotationInterval)],
62
- ['words', String(params.wordCount)],
63
- ['wordlist', params.wordlist],
89
+ ['L', 'ssg'],
90
+ ['l', 'group', 'ssg'],
64
91
  ];
65
- if (params.expiration !== undefined) {
66
- if (!Number.isInteger(params.expiration) || params.expiration < 0) {
67
- throw new Error('expiration must be a non-negative integer');
92
+ if (params.rotationInterval !== undefined) {
93
+ if (!Number.isInteger(params.rotationInterval) || params.rotationInterval <= 0) {
94
+ throw new Error(`Invalid rotationInterval: must be a positive integer, got ${params.rotationInterval}`);
95
+ }
96
+ tags.push(['rotation', String(params.rotationInterval)]);
97
+ }
98
+ if (params.tolerance !== undefined) {
99
+ if (!Number.isInteger(params.tolerance) || params.tolerance < 0) {
100
+ throw new Error(`Invalid tolerance: must be a non-negative integer, got ${params.tolerance}`);
68
101
  }
102
+ tags.push(['tolerance', String(params.tolerance)]);
103
+ }
104
+ if (params.expiration !== undefined) {
105
+ validateExpiration(params.expiration);
69
106
  tags.push(['expiration', String(params.expiration)]);
70
107
  }
71
- return { kind: KINDS.group, content: params.encryptedContent, tags, created_at: now() };
108
+ return { kind: KINDS.groupState, content: params.encryptedContent, tags, created_at: now() };
72
109
  }
73
110
  /**
74
- * Build an unsigned kind 28800 seed distribution event.
111
+ * Build an unsigned kind 30078 stored signal event.
75
112
  *
76
- * @param params - Seed distribution parameters including recipient pubkey, group event ID, and encrypted seed.
77
- * @returns An {@link UnsignedEvent} ready to be signed and published.
78
- * @throws {Error} If recipientPubkey or groupEventId are not valid 64-character hex strings.
79
- */
80
- export function buildSeedDistributionEvent(params) {
81
- validatePubkey(params.recipientPubkey, 'recipientPubkey');
82
- validateEventId(params.groupEventId, 'groupEventId');
83
- return {
84
- kind: KINDS.seedDistribution,
85
- content: params.encryptedContent,
86
- tags: [
87
- ['p', params.recipientPubkey],
88
- ['e', params.groupEventId],
89
- ],
90
- created_at: now(),
91
- };
92
- }
93
- /**
94
- * Build an unsigned kind 38801 member update event (add or remove).
113
+ * The d-tag uses a SHA-256 hash of the group ID (for privacy) scoped by signal type:
114
+ * `ssg/<SHA256(groupId)>:<signalType>`.
95
115
  *
96
- * @param params - Member update parameters including groupId, action ('add' | 'remove'), member pubkey, and reseed flag.
116
+ * Includes a 7-day NIP-40 expiration tag.
117
+ *
118
+ * @param params - Stored signal parameters.
97
119
  * @returns An {@link UnsignedEvent} ready to be signed and published.
98
- * @throws {Error} If action is not 'add' or 'remove', or pubkey/groupId are invalid.
120
+ * @throws {Error} If groupId or signalType are empty.
99
121
  */
100
- export function buildMemberUpdateEvent(params) {
101
- if (params.action !== 'add' && params.action !== 'remove') {
102
- throw new Error(`Invalid action: must be 'add' or 'remove', got '${params.action}'`);
103
- }
104
- validatePubkey(params.memberPubkey, 'memberPubkey');
122
+ export function buildStoredSignalEvent(params) {
105
123
  validateTagString(params.groupId, 'groupId');
124
+ validateTagString(params.signalType, 'signalType');
125
+ validateContent(params.encryptedContent);
126
+ const hash = hashGroupId(params.groupId);
127
+ const createdAt = now();
128
+ const sevenDays = 7 * 24 * 60 * 60;
106
129
  return {
107
- kind: KINDS.memberUpdate,
130
+ kind: KINDS.groupState,
108
131
  content: params.encryptedContent,
109
132
  tags: [
110
- ['d', params.groupId],
111
- ['action', params.action],
112
- ['p', params.memberPubkey],
113
- ['reseed', String(params.reseed)],
133
+ ['d', `ssg/${hash}:${params.signalType}`],
134
+ ['expiration', String(createdAt + sevenDays)],
114
135
  ],
115
- created_at: now(),
136
+ created_at: createdAt,
116
137
  };
117
138
  }
118
- const VALID_RESEED_REASONS = new Set(['member_removed', 'compromise', 'scheduled', 'duress']);
119
139
  /**
120
- * Build an unsigned kind 28801 reseed notification event.
140
+ * Build an unsigned kind 20078 ephemeral signal event.
141
+ *
142
+ * The d-tag uses a SHA-256 hash of the group ID (for privacy):
143
+ * `ssg/<SHA256(groupId)>`. A t-tag carries the signal type.
121
144
  *
122
- * @param params - Reseed parameters including group event ID, reason, and encrypted new seed.
145
+ * No expiration tag ephemeral events are not stored by relays.
146
+ *
147
+ * @param params - Signal parameters.
123
148
  * @returns An {@link UnsignedEvent} ready to be signed and published.
124
- * @throws {Error} If groupEventId is not a valid 64-character hex string or reason is invalid.
149
+ * @throws {Error} If groupId or signalType are empty.
125
150
  */
126
- export function buildReseedEvent(params) {
127
- validateEventId(params.groupEventId, 'groupEventId');
128
- if (!VALID_RESEED_REASONS.has(params.reason)) {
129
- throw new Error(`Invalid reason: must be one of ${[...VALID_RESEED_REASONS].join(', ')}, got '${params.reason}'`);
130
- }
151
+ export function buildSignalEvent(params) {
152
+ validateTagString(params.groupId, 'groupId');
153
+ validateTagString(params.signalType, 'signalType');
154
+ validateContent(params.encryptedContent);
155
+ const hash = hashGroupId(params.groupId);
131
156
  return {
132
- kind: KINDS.reseed,
157
+ kind: KINDS.signal,
133
158
  content: params.encryptedContent,
134
159
  tags: [
135
- ['e', params.groupEventId],
136
- ['reason', params.reason],
160
+ ['d', `ssg/${hash}`],
161
+ ['t', params.signalType],
137
162
  ],
138
163
  created_at: now(),
139
164
  };
140
165
  }
141
166
  /**
142
- * Build an unsigned kind 28802 word-used (burn-after-use) event.
167
+ * Build an unsigned kind 14 rumour event for NIP-17 gift wrapping.
143
168
  *
144
- * @param params - Word-used parameters including group event ID and encrypted content.
145
- * @returns An {@link UnsignedEvent} ready to be signed and published.
146
- * @throws {Error} If groupEventId is not a valid 64-character hex string.
169
+ * The consumer must set the `pubkey` field before computing the event ID.
170
+ * The rumour is then sealed (NIP-44 encrypt + kind 13) and gift-wrapped
171
+ * (kind 1059) by the caller.
172
+ *
173
+ * @param params - Rumour parameters including recipient and subject.
174
+ * @returns An {@link UnsignedEvent} ready for NIP-59 wrapping.
175
+ * @throws {Error} If recipientPubkey is invalid, subject is empty, or groupEventId is invalid.
147
176
  */
148
- export function buildWordUsedEvent(params) {
149
- validateEventId(params.groupEventId, 'groupEventId');
177
+ export function buildRumourEvent(params) {
178
+ validatePubkey(params.recipientPubkey, 'recipientPubkey');
179
+ validateTagString(params.subject, 'subject');
180
+ validateContent(params.encryptedContent);
181
+ if (params.groupEventId !== undefined) {
182
+ validateEventId(params.groupEventId, 'groupEventId');
183
+ }
184
+ const tags = [
185
+ ['p', params.recipientPubkey],
186
+ ['subject', params.subject],
187
+ ];
188
+ if (params.groupEventId !== undefined) {
189
+ tags.push(['e', params.groupEventId]);
190
+ }
150
191
  return {
151
- kind: KINDS.wordUsed,
192
+ kind: 14,
152
193
  content: params.encryptedContent,
153
- tags: [['e', params.groupEventId]],
194
+ tags,
154
195
  created_at: now(),
155
196
  };
156
197
  }
157
- /**
158
- * Build an unsigned kind 20800 beacon event.
159
- *
160
- * @param params - Beacon event parameters including groupId, encrypted content, and optional expiration.
161
- * @returns An {@link UnsignedEvent} ready to be signed and published.
162
- * @throws {Error} If groupId is invalid or expiration is not a non-negative integer.
163
- */
164
- export function buildBeaconEvent(params) {
165
- validateTagString(params.groupId, 'groupId');
166
- const tags = [['h', params.groupId]];
167
- if (params.expiration !== undefined) {
168
- if (!Number.isInteger(params.expiration) || params.expiration < 0) {
169
- throw new Error('expiration must be a non-negative integer');
170
- }
171
- tags.push(['expiration', String(params.expiration)]);
172
- }
173
- return { kind: KINDS.beacon, content: params.encryptedContent, tags, created_at: now() };
174
- }
175
198
  //# sourceMappingURL=nostr.js.map
package/dist/nostr.js.map CHANGED
@@ -1 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