nostr
package: more tests
#434
@ -9,4 +9,4 @@ EXPOSE 8000
|
||||
COPY . .
|
||||
USER $APP_USER
|
||||
RUN yarn
|
||||
CMD yarn app /bin/bash -c "rm -rf /usr/src/app/db/* && ./nostr-rs-relay --db /usr/src/app/db"
|
||||
CMD yarn app /bin/bash -c "rm -rf /usr/src/app/db/* && ./nostr-rs-relay --db /usr/src/app/db --config ./config.toml"
|
||||
|
3
packages/nostr/relay/config.toml
Normal file
3
packages/nostr/relay/config.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[authorization]
|
||||
nip42_auth = true
|
||||
nip42_dms = true
|
@ -109,8 +109,9 @@ export type IncomingMessage =
|
||||
| IncomingNotice
|
||||
| IncomingOk
|
||||
| IncomingEose
|
||||
| IncomingAuth
|
||||
|
||||
export type IncomingKind = "event" | "notice" | "ok" | "eose"
|
||||
export type IncomingKind = "event" | "notice" | "ok" | "eose" | "auth"
|
||||
|
||||
/**
|
||||
* Incoming "EVENT" message.
|
||||
@ -147,6 +148,13 @@ export interface IncomingEose {
|
||||
subscriptionId: SubscriptionId
|
||||
}
|
||||
|
||||
/**
|
||||
* Incoming "AUTH" message.
|
||||
*/
|
||||
export interface IncomingAuth {
|
||||
kind: "auth"
|
||||
}
|
||||
|
||||
/**
|
||||
* A message sent from the client to a relay.
|
||||
*/
|
||||
@ -308,6 +316,14 @@ async function parseIncomingMessage(data: string): Promise<IncomingMessage> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO This is incomplete
|
||||
// Handle incoming "AUTH" messages.
|
||||
if (json[0] === "AUTH") {
|
||||
return {
|
||||
kind: "auth",
|
||||
}
|
||||
}
|
||||
|
||||
throw new ProtocolError(`unknown incoming message: ${data}`)
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,10 @@ export class Nostr extends EventEmitter {
|
||||
)
|
||||
} else if (msg.kind === "eose") {
|
||||
this.emit("eose", msg.subscriptionId, this)
|
||||
} else if (msg.kind === "auth") {
|
||||
// TODO This is incomplete
|
||||
} else {
|
||||
throw new ProtocolError(`invalid message ${msg}`)
|
||||
throw new ProtocolError(`invalid message ${JSON.stringify(msg)}`)
|
||||
}
|
||||
} catch (err) {
|
||||
this.emit("error", err, this)
|
||||
|
@ -37,6 +37,9 @@ describe("dm", async function () {
|
||||
assert.equal(await event.getMessage(subscriberSecret), message)
|
||||
}
|
||||
|
||||
publisher.close()
|
||||
subscriber.close()
|
||||
|
||||
done()
|
||||
} catch (e) {
|
||||
done(e)
|
||||
@ -63,7 +66,7 @@ describe("dm", async function () {
|
||||
})
|
||||
|
||||
// Test that an unintended recipient still receives the direct message event, but cannot decrypt it.
|
||||
it.only("to unintended recipient", (done) => {
|
||||
it("to unintended recipient", (done) => {
|
||||
setup(done).then(
|
||||
({
|
||||
publisher,
|
||||
@ -98,6 +101,9 @@ describe("dm", async function () {
|
||||
)
|
||||
}
|
||||
|
||||
publisher.close()
|
||||
subscriber.close()
|
||||
|
||||
done()
|
||||
} catch (e) {
|
||||
done(e)
|
||||
|
Loading…
Reference in New Issue
Block a user