UMIS SDK
    Preparing search index...

    Function verifyRelayCommand

    • Verifies the X-Umis-Command of a request against the exact body text. In this order: the input, the signature (a trusted key, typ umis-relay-cmd+jwt), the hash of the body (bh, a difference is SIGNATURE_INVALID), the relay (aud must be listed), the lifetime (exp - iat at most 30 s), the clock (iat at most skewSeconds ahead, now before exp + skew) and the replay store (a jti is accepted once). A structure, algorithm or typ the relay does not know is MALFORMED; a key that is not trusted is SIGNATURE_INVALID. It never throws.

      At most eight trusted keys are tried per command, the key named by kid first, then the others in the order given; a command signed by a key beyond the eighth that no kid names is SIGNATURE_INVALID.

      The replay id is relay:<jti>, remembered until exp + skew; it is claimed last, so a command refused for another reason is not used up. A replay store without its own clock learns the time from this call.

      Parameters

      • jws: string
      • body: string
      • i: {
            audiences: readonly string[];
            crypto?: CryptoProvider;
            keys: readonly EcPublicJwk[];
            now: number;
            replay: ReplayStore;
            skewSeconds?: number;
        }

      Returns Promise<
          | { ok: true; payload: RelayCommandPayload }
          | {
              ok: false;
              reason:
                  | "MALFORMED"
                  | "SIGNATURE_INVALID"
                  | "AUDIENCE_MISMATCH"
                  | "PRESENTATION_EXPIRED"
                  | "PRESENTATION_TOO_LONG_LIVED"
                  | "REPLAY"
                  | "CLOCK_SKEW";
          },
      >