Documentation
    Preparing search index...

    Function createUnrecognizedTypeDiagnostic

    • Create the host-side diagnostic for unrecognized message types.

      NIP-5D (nostr-protocol/nips#2303 at dskvr/nips@f60550c3) says "Messages with an unrecognized type MUST be silently ignored" and that this prevents capability probing, so a service drops such a message and calls the returned function instead of answering. The host still hears about it once:

      • one warning per domain/type pair per diagnostic instance;
      • at most UNRECOGNIZED_TYPE_WARNING_LIMIT pairs, then one final line and silence, so a napplet cannot flood the log with invented types;
      • the type is printed only when it is a plain domain.action string of at most 64 characters. Anything else is reported as <unprintable>. Payloads, ids and window ids are never logged.

      Create one per service or runtime instance, not per message.

      Parameters

      Returns IgnoreUnrecognizedType

      A function to call for every dropped message.

      import { createUnrecognizedTypeDiagnostic } from '@kehto/runtime';

      const ignoreUnrecognized = createUnrecognizedTypeDiagnostic();
      function handleMessage(windowId: string, message: NappletMessage, send: Send): void {
      if (message.type === 'serial.open') return open(windowId, message, send);
      ignoreUnrecognized('serial', message.type); // no reply
      }