@websign/sdk - v0.1.0
    Preparing search index...

    Function sign

    • Signs a digest your page prepares for the certificate the person chooses. One confirmation window per call: the certificate is chosen there and prepare runs afterwards, because PAdES/CAdES put the certificate inside the signed attributes. prepare runs again if the person switches certificate; only the digest of the last one is signed.

      The types follow your options: sign({ hash: "SHA-384", algorithm: "ECDSA", … }) gives prepare a context whose hash is "SHA-384" and algorithm is "ECDSA", and resolves with a result typed the same way.

      Type Parameters

      Parameters

      Returns Promise<SignResult<H, A>>

      const { signature, certificate, algorithm } = await sign({
      hash: "SHA-256",
      prepare: (certificate, { hash, algorithm }) =>
      crypto.subtle.digest(hash, signedAttributesFor(certificate, algorithm)),
      });

      InvalidRequest (bad options or digest length), Aborted (signal fired or prepare threw; the original is cause), ExtensionMissing, AppMissing, UserCancelled, PinLocked, Timeout… Each error's hint says what to do.