openwallet-foundation-labs / sd-jwt-js

A JavaScript implementation of the Selective Disclosure JWT (SD-JWT) spec.
https://sdjwt.js.org/
Apache License 2.0
36 stars 12 forks source link

Disclosure digest should be accessible without providing Hasher #150

Closed c2bo closed 6 months ago

c2bo commented 6 months ago

For a holder, you receive the Disclosures with digests and right now can't easily access the digests of disclosures (private member). The only way to access a digest, is via calling digest which requires a HaserAndAlg as input

  public async digest(hash: HasherAndAlg): Promise<string> {
    const { hasher, alg } = hash;
    if (!this._digest) {
      const hash = await hasher(this.encode(), alg);
      this._digest = Uint8ArrayToBase64Url(hash);
    }
    return this._digest;
  }

I do think it would be beneficial to make either the variable directly accessible (public) or change the signature of the function to have hash as an optional argument as it is only used when computing a new digest.

lukasjhan commented 6 months ago

Hi @c2bo. That's a really good suggestion. I too am having difficulty implementing a feature in PEX. I think we should make them public.