fromResponse method Null safety

AuthInfo fromResponse(
  1. CreateAccountResponse? response,
  2. String pwd
)

If the response is null, return null, otherwise return an AuthInfo object with the response's username, password, and token

Args: response (CreateAccountResponse): The response from the server. pwd (String): The password that the user entered.

Implementation

static AuthInfo fromResponse(CreateAccountResponse? response, String pwd) {
  if (response == null) {
    return AuthInfo.create();
  }
  return AuthInfo(
    address: response.address,
    did: response.whoIs.didDocument.id,
    password: pwd,
    aesDscKey: response.aesDsc,
    aesPskKey: response.aesPsk,
  );
}