applesauce-relay 0.0.0-next-20250716144720 → 0.0.0-next-20250718170433

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/README.md CHANGED
@@ -56,9 +56,8 @@ const event = {
56
56
  // ... other required fields
57
57
  };
58
58
 
59
- relay.event(event).subscribe((response) => {
60
- console.log(`Published:`, response.ok);
61
- });
59
+ const response = await relay.publish(event);
60
+ console.log(`Published:`, response.ok);
62
61
  ```
63
62
 
64
63
  ### Relay Pool
@@ -85,7 +84,8 @@ pool
85
84
  });
86
85
 
87
86
  // Publish to multiple relays
88
- pool.event(relays, event).subscribe((response) => {
87
+ const responses = await pool.publish(relays, event);
88
+ responses.forEach((response) => {
89
89
  console.log(`Published to ${response.from}:`, response.ok);
90
90
  });
91
91
  ```
@@ -112,7 +112,8 @@ group
112
112
  });
113
113
 
114
114
  // Publish to all relays in group
115
- group.event(event).subscribe((response) => {
115
+ const responses = await group.publish(event);
116
+ responses.forEach((response) => {
116
117
  console.log(`Published to ${response.from}:`, response.ok);
117
118
  });
118
119
  ```
@@ -144,7 +144,7 @@ describe("req", () => {
144
144
  // Verify the second subscription received the event and EOSE
145
145
  expect(secondSub.getValues()).toEqual([expect.objectContaining(mockEvent), "EOSE"]);
146
146
  });
147
- it("should open connection and wait for authentication if relay info document has limitations.auth_required = true", async () => {
147
+ it("should wait for authentication if relay info document has limitations.auth_required = true", async () => {
148
148
  // Mock the fetchInformationDocument method to return a document with auth_required = true
149
149
  vi.spyOn(Relay, "fetchInformationDocument").mockImplementation(() => of({
150
150
  name: "Auth Required Relay",
@@ -162,20 +162,10 @@ describe("req", () => {
162
162
  const sub = subscribeSpyTo(relay.req([{ kinds: [1] }], "sub1"));
163
163
  // Wait 10ms to ensure the information document is fetched
164
164
  await new Promise((resolve) => setTimeout(resolve, 10));
165
- // Wait for connection
166
- await server.connected;
167
165
  // Verify no REQ message was sent yet (waiting for auth)
168
166
  expect(server).not.toHaveReceivedMessages(["REQ", "sub1", { kinds: [1] }]);
169
- // Send AUTH challenge
170
- server.send(["AUTH", "challenge"]);
171
- // Send auth response
172
- subscribeSpyTo(relay.auth(mockEvent));
173
- // Verify the auth event was sent
174
- await expect(server.nextMessage).resolves.toEqual(["AUTH", mockEvent]);
175
- // Accept auth
176
- server.send(["OK", mockEvent.id, true, ""]);
177
167
  // Simulate successful authentication
178
- expect(relay.authenticated).toBe(true);
168
+ relay.authenticated$.next(true);
179
169
  // Now the REQ should be sent
180
170
  await expect(server).toReceiveMessage(["REQ", "sub1", { kinds: [1] }]);
181
171
  // Send EVENT and EOSE to complete the subscription
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-relay",
3
- "version": "0.0.0-next-20250716144720",
3
+ "version": "0.0.0-next-20250718170433",
4
4
  "description": "nostr relay communication framework built on rxjs",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -61,7 +61,7 @@
61
61
  },
62
62
  "devDependencies": {
63
63
  "@hirez_io/observer-spy": "^2.2.0",
64
- "applesauce-signers": "^2.0.0",
64
+ "applesauce-signers": "0.0.0-next-20250718170433",
65
65
  "@vitest/expect": "^3.1.1",
66
66
  "typescript": "^5.7.3",
67
67
  "vitest": "^3.2.3",