buildAuthObject static method

Cacao buildAuthObject({
  1. required CacaoRequestPayload requestPayload,
  2. required CacaoSignature signature,
  3. required String iss,
})

Implementation

static Cacao buildAuthObject({
  required CacaoRequestPayload requestPayload,
  required CacaoSignature signature,
  required String iss,
}) {
  if (!iss.contains('did:pkh:')) {
    iss = 'did:pkh:$iss';
  }
  final address = AddressUtils.getDidAddress(iss);
  iss = iss.replaceAll(address, address.toEIP55());
  return Cacao(
    h: const CacaoHeader(t: CacaoHeader.CAIP122),
    p: CacaoPayload.fromRequestPayload(
      issuer: iss,
      payload: requestPayload,
    ),
    s: signature,
  );
}