-
Notifications
You must be signed in to change notification settings - Fork 36
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
publish genesis state #133
Conversation
src/credentials/credential-wallet.ts
Outdated
credentialStatus.id = request.revocationOpts.issuerState | ||
? `${request.revocationOpts.id}/node?state=${request.revocationOpts.issuerState}` | ||
: `${request.revocationOpts.id}`; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect default
keyword which throws Error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For SparseMerkleTreeProof
, Iden3commRevocationStatusV1
, Iden3ReverseSparseMerkleTreeProof
types we have to modify the id
field. All other types remain unchanged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add default
keyword to switch
statement which will throw an Error in case for some reasons request.revocationOpts.type
none of available cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to modify id for Iden3commRevocationStatusV1. This is not right! Agent URL must remain the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How I understand this regexp cuts end '/'. We should cut the last '/' for the agent endpoint also to be sure that SDK will not create a URL like https/agent//
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kolezhniuk @vmidylli about the default
case. I disagree that we should return an error if we have an unknown type.
- What if the user implements a custom revocation type?
- We have strict typing to protect against dummy users.
- SDK should be flexible. All validation should be on the user side. Because we cannot know all the use cases of this SDK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilya-korotya ok, in case we don't need to throw an Error, I would expect default
statement in any case where you need to use switch to make logic flow explicitly
default:
return credentialStatus;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/**
* Builds credential status
* @param {CredentialRequest} request
* @returns `CredentialStatus`
*/
private buildCredentialStatus(request: CredentialRequest): CredentialStatus {
const credentialStatus: CredentialStatus = {
id: request.revocationOpts.id,
type: request.revocationOpts.type,
revocationNonce: request.revocationOpts.nonce
};
switch (request.revocationOpts.type) {
case CredentialStatusType.SparseMerkleTreeProof:
case CredentialStatusType.Iden3commRevocationStatusV1:
return {
...credentialStatus,
id: `${request.revocationOpts.id.replace(/\/$/, '')}/${request.revocationOpts.nonce}`
};
case CredentialStatusType.Iden3ReverseSparseMerkleTreeProof:
return {
...credentialStatus,
id: request.revocationOpts.issuerState
? `${request.revocationOpts.id}/node?state=${request.revocationOpts.issuerState}`
: `${request.revocationOpts.id}`
};
default:
return credentialStatus;
}
}
claimsTreeRoot: issuerData.state.claimsTreeRoot | ||
} | ||
}; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need else here
tests/identity/id.test.ts
Outdated
@@ -21,6 +21,8 @@ import { CredentialStatusResolverRegistry } from '../../src/credentials'; | |||
import { RHSResolver } from '../../src/credentials'; | |||
|
|||
describe('identity', () => { | |||
const rhsURL = process.env.RHS_URL as string; | |||
let credWallet: CredentialWallet; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use ICredentialWallet
tests/identity/id.test.ts
Outdated
const issuerCred = await wallet.issueCredential(issuerDID, claimReq); | ||
issuerCred.credentialStatus.id = rhsURL; | ||
|
||
credWallet.getRevocationStatusFromCredential(issuerCred); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess await
missed here
src/credentials/credential-wallet.ts
Outdated
credentialStatus.id = request.revocationOpts.issuerState | ||
? `${request.revocationOpts.id}/node?state=${request.revocationOpts.issuerState}` | ||
: `${request.revocationOpts.id}`; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add default
keyword to switch
statement which will throw an Error in case for some reasons request.revocationOpts.type
none of available cases
src/credentials/credential-wallet.ts
Outdated
credentialStatus.id = request.revocationOpts.issuerState | ||
? `${request.revocationOpts.id}/node?state=${request.revocationOpts.issuerState}` | ||
: `${request.revocationOpts.id}`; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to modify id for Iden3commRevocationStatusV1. This is not right! Agent URL must remain the same.
src/identity/identity-wallet.ts
Outdated
const revocationTree = await this._storage.mt.getMerkleTreeByIdentifierAndType( | ||
did.string(), | ||
MerkleTreeType.Revocations | ||
); | ||
|
||
const rootOfRootsTree = await this._storage.mt.getMerkleTreeByIdentifierAndType( | ||
did.string(), | ||
MerkleTreeType.Roots | ||
); | ||
|
||
const trees: TreesModel = { | ||
state: currentState, | ||
claimsTree: claimsTree, | ||
revocationTree: revocationTree, | ||
rootsTree: rootOfRootsTree | ||
}; | ||
await pushHashesToRHS(currentState, trees, opts.revocationOpts.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we just call publishStateToRHS here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I did it
src/credentials/rhs.ts
Outdated
@@ -35,7 +35,7 @@ export interface TreesModel { | |||
* @param {number[]} [revokedNonces] - revoked nonces since last published info | |||
* @returns void | |||
*/ | |||
export async function pushHashesToRHS( | |||
export async function publishStateToRHS( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure that we want to check public interface here? I think it is better to live it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vmidyllic we discussed it. And we decided to add export to this function and call it inside on identity-wallet.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was exported already, so this is a problem of renaming already exported function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I returned old name
src/credentials/credential-wallet.ts
Outdated
}; | ||
|
||
switch (request.revocationOpts.type) { | ||
case (CredentialStatusType.SparseMerkleTreeProof, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to write
case CredentialStatusType.SparseMerkleTreeProof:
case CredentialStatusType.Iden3commRevocationStatusV1:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is already fixed
src/credentials/credential-wallet.ts
Outdated
credentialStatus.id = request.revocationOpts.issuerState | ||
? `${request.revocationOpts.id}/node?state=${request.revocationOpts.issuerState}` | ||
: `${request.revocationOpts.id}`; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/**
* Builds credential status
* @param {CredentialRequest} request
* @returns `CredentialStatus`
*/
private buildCredentialStatus(request: CredentialRequest): CredentialStatus {
const credentialStatus: CredentialStatus = {
id: request.revocationOpts.id,
type: request.revocationOpts.type,
revocationNonce: request.revocationOpts.nonce
};
switch (request.revocationOpts.type) {
case CredentialStatusType.SparseMerkleTreeProof:
case CredentialStatusType.Iden3commRevocationStatusV1:
return {
...credentialStatus,
id: `${request.revocationOpts.id.replace(/\/$/, '')}/${request.revocationOpts.nonce}`
};
case CredentialStatusType.Iden3ReverseSparseMerkleTreeProof:
return {
...credentialStatus,
id: request.revocationOpts.issuerState
? `${request.revocationOpts.id}/node?state=${request.revocationOpts.issuerState}`
: `${request.revocationOpts.id}`
};
default:
return credentialStatus;
}
}
No description provided.