Skip to content

v3.0.0

Compare
Choose a tag to compare
@penpenpng penpenpng released this 10 Jul 16:54
· 113 commits to main since this release

IMPORTANT

Some important features, which rely on cryptographic libraries, have been moved to rx-nostr-crypto.
In the most of use cases, you need to do npm install rx-nostr rx-nostr-crypto.

import { createRxNostr } from 'rx-nostr';
import { verifier, seckeySigner } from 'rx-nostr-crypto';

const rxNostr = createRxNostr({
  // The most of use cases, you need this.
  verifier,
  // If you don't use NIP-07, this is also needed.
  signer: seckeySigner('nsec1...')
});

New Features

Verification with Service Worker

Conventional verifier is executed synchronously, so bursty requests caused UI hangs, especially on the web front-end. rx-nostr v3 provides a verifier that is executed asynchronously on Service Worker, allowing the load from verification to escape outside the UI thread.

In [email protected], the feature was replaced with Web Worker based method. See #138

// service-worker.js

import { startVerificationServiceHost } from 'rx-nostr-crypto';

startVerificationServiceHost();
// index.js

import { createRxNostr } from 'rx-nostr';
import { createVerificationServiceClient } from 'rx-nostr-crypto';

const verificationClient = createVerificationServiceClient();

const rxNostr = createRxNostr({
  verifier: verificationClient.verify
});

Option to control complete timing of send()

Now rxNostr.send() takes completeOn option. If you set "sent", it will complete when the event is sent to all alive relays. It means that rx-nostr doesn't wait for OK response.

Support using keyword

All disposables now support [Symbol.dispose](). This means you can using to manage these resources.

import { createRxNostr } from 'rx-nostr';
import { seckeySigner } from 'rx-nostr-crypto';
import * as Nostr from 'nostr-typedef';
import { firstValueFrom } from 'rxjs';

const sendEvent = async (event: Nostr.Event) => {
  using rxNostr = createRxNostr({
    signer: seckeySigner('nsec1...')
  });

  await firstValueFrom(rxNostr.send(event, { completeOn: 'sent' }));
};

BREAKING CHANGES

  • All features marked as deprecated have been deleted.
  • NIP-26-related features have been deleted.
  • rxNostr.send() no longer treats timeout as a subscription error as default.
    • If you set option errorOnTimeout: true, it works the same way as the older version. But as default, errorOnTimeout is false.
  • verifier is now async function.
  • Features that rely on cryptographic libraries have been moved to rx-nostr-crypto

Full Changelog: v2.7.3...v3.0.0