Skip to content

Commit

Permalink
chore: improve third party check
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbi08 committed Sep 30, 2024
1 parent 057429a commit 5cd0216
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,13 @@
"source.organizeImports": "always"
},
"files.eol": "\n",
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"jest.jestCommandLine": "../../node_modules/.bin/jest",
"jest.nodeEnv": {
"USE_LOKIJS": "true"
},
"jest.virtualFolders": [
{ "name": "Consumption", "rootPath": "packages/consumption" },
{ "name": "Runtime", "rootPath": "packages/runtime" }
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces
ConsumptionCoreErrors.requests.invalidRequestItem("The provided RelationshipAttribute already exists in the context of the Relationship with the peer.")
);
}
if (!requestItem.thirdPartyAddress) {
return ValidationResult.error(
ConsumptionCoreErrors.requests.invalidRequestItem(
"The source attribute provided is a relationship attribute. You must provide a third party address that is the original peer when sharing with a third party."
)
);
}
}

const queryForNonPendingRelationships = {
Expand All @@ -131,14 +138,6 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces
return ValidationResult.error(ConsumptionCoreErrors.requests.cannotShareRelationshipAttributeOfPendingRelationship());
}

if (recipient && !foundAttribute.shareInfo.peer.equals(recipient) && !requestItem.thirdPartyAddress) {
return ValidationResult.error(
ConsumptionCoreErrors.requests.invalidRequestItem(
"The source attribute provided is a relationship attribute. You must provide a third party address that is the original peer when sharing with a third party."
)
);
}

if (requestItem.thirdPartyAddress && !requestItem.thirdPartyAddress.equals(foundAttribute.shareInfo.peer)) {
return ValidationResult.error(new CoreError("The third party address must be the peer of the relationship attribute."));
}
Expand Down

0 comments on commit 5cd0216

Please sign in to comment.