Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support agent revocation status; refactring resolve opts #103

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

ilya-korotya
Copy link
Contributor

No description provided.

@ilya-korotya
Copy link
Contributor Author

ilya-korotya commented Jul 19, 2023

Flow tested after the code refactoring:
зображення

@vmidyllic
Copy link
Collaborator

@ilya-korotya skip revocation option is supported on sdk level and allows not to include revocation info into the circuits, so zkp will be generated without checks for non-revocation of credentials.
At this moment JS SDK will not generate proof on revoked credential despite the option skip revocation

if (!cred.credentialSubject.id) {
userDID = issuerDID;
} else {
try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this try catch because DID.parse throws custom error and code flows looks more clearly

issuerDID,
userDID
};
return await this.getRevocationStatus(cred.credentialStatus, opts);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can ommit await here

issuer: issuerDID,
issuerData: issuerData
});
const cs = await statusResolver.resolve(credStatus, credentialStatusResolveOptions);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const cs = await statusResolver.resolve(credStatus, credentialStatusResolveOptions);
return statusResolver.resolve(credStatus, credentialStatusResolveOptions);

import { MediaType, PROTOCOL_MESSAGE_TYPE } from '../../iden3comm/constants';
import * as uuid from 'uuid';

export class AgentResolver implements CredentialStatusResolver {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add JSDoc comment to all public members for documentation generation

}
});
const agentResponse = await response.json();
return Object.assign(new RevocationStatusAgent(), { agentResponse }).toRevocationStatus();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 42 to 53
const revocationStatusRequestMessage: RevocationStatusRequestMessage = {
id: uuid.v4(),
typ: MediaType.PlainMessage,
type: PROTOCOL_MESSAGE_TYPE.REVOCATION_STATUS_REQUEST_MESSAGE_TYPE,
body: {
revocation_nonce: revocationNonce
},
thid: uuid.v4(),
from: from,
to: to
};
return revocationStatusRequestMessage;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const revocationStatusRequestMessage: RevocationStatusRequestMessage = {
id: uuid.v4(),
typ: MediaType.PlainMessage,
type: PROTOCOL_MESSAGE_TYPE.REVOCATION_STATUS_REQUEST_MESSAGE_TYPE,
body: {
revocation_nonce: revocationNonce
},
thid: uuid.v4(),
from: from,
to: to
};
return revocationStatusRequestMessage;
return {
id: uuid.v4(),
typ: MediaType.PlainMessage,
type: PROTOCOL_MESSAGE_TYPE.REVOCATION_STATUS_REQUEST_MESSAGE_TYPE,
body: {
revocation_nonce: revocationNonce
},
thid: uuid.v4(),
from: from,
to: to
}

return revocationStatusRequestMessage;
}

class RevocationStatusAgent {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any sense to keep this as class instead of creating function something like

toRevocationStatus(agentResponse: RevocationStatusResponseMessage): RevocationStatus {
    return {
      mtp: agentResponse.body.mtp,
      issuer: agentResponse.body.issuer
    }
  }

??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Analog of DTO implementation

CredentialStatusType
} from '../../verifiable';

export type CredentialStatusResolveOptions = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep it as interface to be more consistent in the project

if (!credential.credentialSubject.id) {
userDID = issuerDID;
} else {
try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also don't see a reason wrapping this with try/catch

@@ -262,7 +262,7 @@ describe('rhs', () => {
await idWallet.publishStateToRHS(issuerDID, rhsUrl);

const rhsResolver = new RHSResolver(mockStateStorageForDefinedState);
const rhsStatus = await rhsResolver.resolve(credRHSStatus, { issuer: issuerDID });
const rhsStatus = await rhsResolver.resolve(credRHSStatus, { issuerDID: issuerDID });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const rhsStatus = await rhsResolver.resolve(credRHSStatus, { issuerDID: issuerDID });
const rhsStatus = await rhsResolver.resolve(credRHSStatus, { issuerDID });

@ilya-korotya ilya-korotya merged commit 7d7b193 into main Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants