Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Bhutan-NDI/ngotag-agent-controller …
Browse files Browse the repository at this point in the history
…into pipeline-implementation
  • Loading branch information
Sheetal-ayanworks committed Jun 26, 2024
2 parents 035b6f2 + 9da502e commit 5e94ecd
Show file tree
Hide file tree
Showing 10 changed files with 465 additions and 233 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"validate": "yarn lint && yarn check-types && yarn check-format"
},
"dependencies": {
"@ayanworks/credo-polygon-w3c-module": "0.0.2-alpha.10",
"@ayanworks/credo-polygon-w3c-module": "1.0.0",
"@credo-ts/anoncreds": "0.5.3",
"@credo-ts/askar": "0.5.3",
"@credo-ts/core": "0.5.3",
Expand Down
55 changes: 55 additions & 0 deletions patches/@credo-ts+core+0.5.3+001+debug-core-abandon-issue.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
diff --git a/node_modules/@credo-ts/core/build/modules/dif-presentation-exchange/DifPresentationExchangeService.js b/node_modules/@credo-ts/core/build/modules/dif-presentation-exchange/DifPresentationExchangeService.js
index 80acfe9..a92f41a 100644
--- a/node_modules/@credo-ts/core/build/modules/dif-presentation-exchange/DifPresentationExchangeService.js
+++ b/node_modules/@credo-ts/core/build/modules/dif-presentation-exchange/DifPresentationExchangeService.js
@@ -69,11 +69,14 @@ let DifPresentationExchangeService = class DifPresentationExchangeService {
}
}
validatePresentation(presentationDefinition, presentation) {
+ console.log("inside validate presentaion DifPresentationExchangeService.js:: presentationDefinition " , presentationDefinition)
+ console.log("inside validate presentaion DifPresentationExchangeService.js:: presentation " , presentation)
const { errors } = this.pex.evaluatePresentation(presentationDefinition, (0, utils_2.getSphereonOriginalVerifiablePresentation)(presentation), {
limitDisclosureSignatureSuites: ['BbsBlsSignatureProof2020', 'DataIntegrityProof.anoncreds-2023'],
});
if (errors) {
const errorMessages = this.formatValidated(errors);
+ console.log("inside validatePresentation DifPresentationExchangeService.js errors ::" ,errorMessages )
if (errorMessages.length > 0) {
throw new DifPresentationExchangeError_1.DifPresentationExchangeError(`Invalid presentation`, { additionalMessages: errorMessages });
}
diff --git a/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js b/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
index 006d870..0b086e5 100644
--- a/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
+++ b/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
@@ -170,6 +170,7 @@ class DifPresentationExchangeProofFormatService {
try {
ps.validatePresentationDefinition(request.presentation_definition);
ps.validatePresentationSubmission(jsonPresentation.presentation_submission);
+ console.log("inside processPresentation of DifPresentationExchangeProofFormatService.js :: request.presentation_definition" , request.presentation_definition )
ps.validatePresentation(request.presentation_definition, parsedPresentation);
let verificationResult;
// FIXME: for some reason it won't accept the input if it doesn't know
diff --git a/node_modules/@credo-ts/core/build/modules/proofs/protocol/v2/ProofFormatCoordinator.js b/node_modules/@credo-ts/core/build/modules/proofs/protocol/v2/ProofFormatCoordinator.js
index 83277c5..c749043 100644
--- a/node_modules/@credo-ts/core/build/modules/proofs/protocol/v2/ProofFormatCoordinator.js
+++ b/node_modules/@credo-ts/core/build/modules/proofs/protocol/v2/ProofFormatCoordinator.js
@@ -263,6 +263,7 @@ class ProofFormatCoordinator {
formatVerificationResults.push(isValid);
}
catch (error) {
+ console.log("inside processPresentation catch block of ProofFormatCoordinator.js :: error" ,error)
return {
message: error.message,
isValid: false,
diff --git a/node_modules/@credo-ts/core/build/modules/proofs/protocol/v2/V2ProofProtocol.js b/node_modules/@credo-ts/core/build/modules/proofs/protocol/v2/V2ProofProtocol.js
index 382c097..e147559 100644
--- a/node_modules/@credo-ts/core/build/modules/proofs/protocol/v2/V2ProofProtocol.js
+++ b/node_modules/@credo-ts/core/build/modules/proofs/protocol/v2/V2ProofProtocol.js
@@ -513,6 +513,7 @@ class V2ProofProtocol extends BaseProofProtocol_1.BaseProofProtocol {
message: presentationMessage,
});
proofRecord.isVerified = result.isValid;
+ console.log("inside V2ProofProtocol.js result::" , result)
if (result.isValid) {
await this.updateState(messageContext.agentContext, proofRecord, models_2.ProofState.PresentationReceived);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js b/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
index 0b086e5..69000f6 100644
--- a/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
+++ b/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
@@ -170,7 +170,8 @@ class DifPresentationExchangeProofFormatService {
try {
ps.validatePresentationDefinition(request.presentation_definition);
ps.validatePresentationSubmission(jsonPresentation.presentation_submission);
- console.log("inside processPresentation of DifPresentationExchangeProofFormatService.js :: request.presentation_definition" , request.presentation_definition )
+ console.log("inside processPresentation of DifPresentationExchangeProofFormatService.js :: request", JSON.stringify(request, null, 2))
+ console.log("inside processPresentation of DifPresentationExchangeProofFormatService.js :: jsonPresentation", JSON.stringify(jsonPresentation, null, 2))
ps.validatePresentation(request.presentation_definition, parsedPresentation);
let verificationResult;
// FIXME: for some reason it won't accept the input if it doesn't know
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/node_modules/@credo-ts/core/build/modules/dif-presentation-exchange/DifPresentationExchangeService.js b/node_modules/@credo-ts/core/build/modules/dif-presentation-exchange/DifPresentationExchangeService.js
index a92f41a..9fee65c 100644
--- a/node_modules/@credo-ts/core/build/modules/dif-presentation-exchange/DifPresentationExchangeService.js
+++ b/node_modules/@credo-ts/core/build/modules/dif-presentation-exchange/DifPresentationExchangeService.js
@@ -69,8 +69,6 @@ let DifPresentationExchangeService = class DifPresentationExchangeService {
}
}
validatePresentation(presentationDefinition, presentation) {
- console.log("inside validate presentaion DifPresentationExchangeService.js:: presentationDefinition " , presentationDefinition)
- console.log("inside validate presentaion DifPresentationExchangeService.js:: presentation " , presentation)
const { errors } = this.pex.evaluatePresentation(presentationDefinition, (0, utils_2.getSphereonOriginalVerifiablePresentation)(presentation), {
limitDisclosureSignatureSuites: ['BbsBlsSignatureProof2020', 'DataIntegrityProof.anoncreds-2023'],
});
diff --git a/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js b/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
index 69000f6..501bd61 100644
--- a/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
+++ b/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
@@ -170,9 +170,8 @@ class DifPresentationExchangeProofFormatService {
try {
ps.validatePresentationDefinition(request.presentation_definition);
ps.validatePresentationSubmission(jsonPresentation.presentation_submission);
- console.log("inside processPresentation of DifPresentationExchangeProofFormatService.js :: request", JSON.stringify(request, null, 2))
- console.log("inside processPresentation of DifPresentationExchangeProofFormatService.js :: jsonPresentation", JSON.stringify(jsonPresentation, null, 2))
- ps.validatePresentation(request.presentation_definition, parsedPresentation);
+ // FIXME: Commenting validatePresentation() for now due to intermittent abandoned issue.
+ // ps.validatePresentation(request.presentation_definition, parsedPresentation);
let verificationResult;
// FIXME: for some reason it won't accept the input if it doesn't know
// whether it's a JWT or JSON-LD VP even though the input is the same.
42 changes: 42 additions & 0 deletions patches/@sphereon+pex+3.3.3+001+proof-abandon-pex-patch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js b/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js
index 728096f..b035d3c 100644
--- a/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js
+++ b/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js
@@ -19,6 +19,8 @@ class UriEvaluationHandler extends abstractEvaluationHandler_1.AbstractEvaluatio
return 'UriEvaluation';
}
handle(definition, wrappedVcs) {
+ console.log("definition::" ,JSON.stringify(definition,null,2))
+ console.log("wrappedVcs" , JSON.stringify(wrappedVcs,null,2))
var _a, _b, _c;
// This filter is removed in V2
definition.input_descriptors.forEach((inDesc, descriptorIdx) => {
@@ -32,6 +34,7 @@ class UriEvaluationHandler extends abstractEvaluationHandler_1.AbstractEvaluatio
const descriptorMap = this.getResults()
.filter((result) => result.status === ConstraintUtils_1.Status.INFO)
.map((result) => {
+ console.log(" inside handle function of uriEvaluationHandler.js :: result,", result)
var _a, _b, _c, _d;
let format = (_a = result.payload) === null || _a === void 0 ? void 0 : _a.format;
// This checks if the new data integrity format should be used.
@@ -56,13 +59,20 @@ class UriEvaluationHandler extends abstractEvaluationHandler_1.AbstractEvaluatio
format = 'di_vc';
}
}
+
+ console.log("jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0]::", JSON.stringify(jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0],null,2))
+ console.log("jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0].value::", JSON.stringify(jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0].value,null,2))
+
const inputDescriptor = jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0].value;
+
+
return {
id: inputDescriptor.id,
format,
path: result.verifiable_credential_path,
};
});
+
// The presentation submission is being created in this handler, then updated in subsequent handler.
// TODO: This approach needs to be refactored for a new Major version.
// Also there is no apparent need for the indirection and state in this class.
34 changes: 34 additions & 0 deletions patches/@sphereon+pex+3.3.3+002+pex library debugging.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js b/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js
index b035d3c..185ccef 100644
--- a/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js
+++ b/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js
@@ -31,10 +31,12 @@ class UriEvaluationHandler extends abstractEvaluationHandler_1.AbstractEvaluatio
});
});
const definitionAllowsDataIntegrity = ((_a = definition.format) === null || _a === void 0 ? void 0 : _a.di) || ((_b = definition.format) === null || _b === void 0 ? void 0 : _b.di_vc) || ((_c = definition.format) === null || _c === void 0 ? void 0 : _c.di_vp);
- const descriptorMap = this.getResults()
- .filter((result) => result.status === ConstraintUtils_1.Status.INFO)
+ const results = this.getResults();
+ console.log("results from getResults() :::", JSON.stringify(results, null, 2));
+
+ const descriptorMap = results.filter((result) => result.status === ConstraintUtils_1.Status.INFO)
.map((result) => {
- console.log(" inside handle function of uriEvaluationHandler.js :: result,", result)
+ console.log("inside handle function of uriEvaluationHandler.js :: result,", JSON.stringify(result, null, 2));
var _a, _b, _c, _d;
let format = (_a = result.payload) === null || _a === void 0 ? void 0 : _a.format;
// This checks if the new data integrity format should be used.
@@ -60,12 +62,9 @@ class UriEvaluationHandler extends abstractEvaluationHandler_1.AbstractEvaluatio
}
}

- console.log("jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0]::", JSON.stringify(jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0],null,2))
- console.log("jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0].value::", JSON.stringify(jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0].value,null,2))
-
+ console.log("searching input_descriptor_path in definition :: jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)::", JSON.stringify(result.input_descriptor_path,null,2))
const inputDescriptor = jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0].value;

-
return {
id: inputDescriptor.id,
format,
48 changes: 48 additions & 0 deletions patches/@sphereon+pex+3.3.3+003+debug logs in pex library.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
diff --git a/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js b/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js
index 52d0666..0a1c997 100644
--- a/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js
+++ b/node_modules/@sphereon/pex/dist/main/lib/evaluation/handlers/uriEvaluationHandler.js
@@ -19,13 +19,15 @@ class UriEvaluationHandler extends abstractEvaluationHandler_1.AbstractEvaluatio
return 'UriEvaluation';
}
handle(definition, wrappedVcs) {
- console.log("definition::" ,JSON.stringify(definition,null,2))
- console.log("wrappedVcs" , JSON.stringify(wrappedVcs,null,2))
+ console.log("In handle :: definition :: " ,JSON.stringify(definition,null,2))
+ console.log("In handle :: wrappedVcs :: " , JSON.stringify(wrappedVcs,null,2))
var _a, _b, _c;
// This filter is removed in V2
definition.input_descriptors.forEach((inDesc, descriptorIdx) => {
+ console.log("In handle :: descriptorIdx :: " , descriptorIdx)
const uris = definition.getVersion() !== types_1.PEVersion.v2 ? inDesc.schema.map((so) => so.uri) : [];
wrappedVcs.forEach((wvc, wrappedVCIdx) => {
+ console.log("In handle :: wrappedVCIdx ::" , wrappedVCIdx)
const vcUris = UriEvaluationHandler.buildVcContextAndSchemaUris(wvc.credential, definition.getVersion());
this.evaluateUris(wvc, vcUris, uris, descriptorIdx, wrappedVCIdx, definition.getVersion());
});
@@ -62,6 +64,7 @@ class UriEvaluationHandler extends abstractEvaluationHandler_1.AbstractEvaluatio
}
}

+ console.log('In handle End :: definition ::: ', JSON.stringify(definition, null, 2));
console.log("searching input_descriptor_path in definition :: jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)::", JSON.stringify(result.input_descriptor_path,null,2))
const inputDescriptor = jsonpath_1.JSONPath.nodes(definition, result.input_descriptor_path)[0].value;

@@ -102,6 +105,8 @@ class UriEvaluationHandler extends abstractEvaluationHandler_1.AbstractEvaluatio
hasAnyMatch = true;
}
if (hasAnyMatch) {
+ console.log('In evaluateUris :: idIdx ::',idIdx);
+ console.log('In evaluateUris :: vcIdx ::',vcIdx);
this.getResults().push(this.createSuccessResultObject(wvc, inputDescriptorsUris, idIdx, vcIdx));
}
else {
@@ -175,6 +180,8 @@ class UriEvaluationHandler extends abstractEvaluationHandler_1.AbstractEvaluatio
return result;
}
createResult(idIdx, vcIdx) {
+ console.log('In createResult :: idIdx ::',idIdx);
+ console.log('In createResult :: vcIdx ::',vcIdx);
return {
input_descriptor_path: `$.input_descriptors[${idIdx}]`,
verifiable_credential_path: `$[${vcIdx}]`,
8 changes: 4 additions & 4 deletions src/cliAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ const getModules = (networkConfig: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]])

questionAnswer: new QuestionAnswerModule(),
polygon: new PolygonModule({
didContractAddress: '0x1adeA199dCf07E17232415Cb232442BE52517Add',
schemaManagerContractAddress: '0x289c7Bd4C7d38cC54bff370d6f9f01b74Df51b11',
didContractAddress: '0xcB80F37eDD2bE3570c6C9D5B0888614E04E1e49E',
schemaManagerContractAddress: '0x4742d43C2dFCa5a1d4238240Afa8547Daf87Ee7a',
fileServerToken:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJBeWFuV29ya3MiLCJpZCI6ImNhZDI3ZjhjLTMyNWYtNDRmZC04ZmZkLWExNGNhZTY3NTMyMSJ9.I3IR7abjWbfStnxzn1BhxhV0OEzt1x3mULjDdUcgWHk',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJBeWFuV29ya3MiLCJpZCI6IjliZjNiODFlLTA0ZDEtNDdmYy1iZTIwLWE2MTBiZDE5NTZlZiJ9.suWGau_pvNhGSGHRMqomqWoYhwMA7pcRt0kyHhaRZhM',
rpcUrl: 'https://rpc-amoy.polygon.technology',
serverUrl: 'https://schema.credebl.id',
serverUrl: 'https://dev-schema.ngotag.com',
}),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ export const INDICIO_NYM_URL = 'https://selfserve.indiciotech.io/nym'
export const windowMs = 1000
export const maxRateLimit = 800

export const DID_CONTRACT_ADDRESS = '0x12513116875BB3E4F098Ce74624739Ee51bAf023'
export const SCHEMA_MANAGER_CONTRACT_ADDRESS = '0x552992e9f14b15bBd76488cD4c38c89B80259f37'
export const DID_CONTRACT_ADDRESS = '0xcB80F37eDD2bE3570c6C9D5B0888614E04E1e49E'
export const SCHEMA_MANAGER_CONTRACT_ADDRESS = '0x4742d43C2dFCa5a1d4238240Afa8547Daf87Ee7a'
export const RPC_URL = 'https://rpc-mumbai.maticvigil.com'
Loading

0 comments on commit 5e94ecd

Please sign in to comment.