How to use the @arcblock/did.isFromPublicKey function in @arcblock/did

To help you get started, we’ve selected a few @arcblock/did examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArcBlock / forge-js / did / did-auth / lib / jwt.js View on Github external
if (!signature) {
      debug('verify.error.emptySig');
      return false;
    }
    if (!header.alg) {
      debug('verify.error.emptyAlg');
      return false;
    }

    const signerDid = body[signerKey];
    if (!signerDid) {
      debug('verify.error.emptySignerDid');
      return false;
    }

    if (isFromPublicKey(signerDid, signerPk) === false) {
      debug('verify.error.signerDidAndPkNotMatch');
      return false;
    }

    if (enforceTimestamp) {
      const now = Math.ceil(Date.now() / 1000);
      const exp = Number(body.exp) || 0;
      const iat = Number(body.iat) || 0;
      const nbf = Number(body.nbf) || 0;
      debug('verify.enforceTimestamp', { now, exp, iat, nbf });
      if (exp && exp + tolerance < now) {
        debug('verify.error.expired');
        return false;
      }
      if (iat && iat > now && iat - now > tolerance) {
        debug('verify.error.issuedAt');