forked from tetherto/wdk
-
Notifications
You must be signed in to change notification settings - Fork 1
[SEM-5] Add Policy Enforcement to WDK Core #1
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
2cb093d
style: format existing codes
nimdeveloper a002bfa
feat: add full list of mutating wallet and protocol methods
nimdeveloper 97e83f1
feat: add PolicyViolationError class for handling policy rejection er…
nimdeveloper 2bbc7f7
feat: add runPolicies function for sequential policy evaluation
nimdeveloper 6e990bf
feat: implement policy registration and enforcement in WDK class
nimdeveloper f24d987
feat: add registerPolicies function for policy management in WdkManag…
nimdeveloper a31968e
feat: update typescript types
nimdeveloper 8a915e0
style: remove comments
nimdeveloper 58207ce
refactor: remove MUTATING_METHODS constant and dynamically gather met…
nimdeveloper 234e400
refactor: remove MUTATING_METHODS constant types
nimdeveloper 7680380
fix: update PolicyViolationError import and usage in tests
nimdeveloper a56b2f9
refactor: improve Policy typedef documentation for clarity
nimdeveloper 6c9c870
refactor: migrate runPolicies function to WDK class and update Policy…
nimdeveloper d53dd7a
refactor: update _withPolicyGate method signature to use generic type…
nimdeveloper 1f65796
refactor: standardize string quotes and improve Policy typedef docume…
nimdeveloper d2ae357
refactor: update PolicyTarget to use blockchain identifier and adjust…
nimdeveloper a282f94
refactor: update PolicyViolationError to use PolicyTarget type for ta…
nimdeveloper 69d0778
refactor: add registerPolicies document entries and revert format cha…
nimdeveloper de6bc00
refactor: remove unused runPolicies function from policies type defin…
nimdeveloper 57b9aad
refactor: clean up whitespace and update class names for consistency …
nimdeveloper 25ea83e
refactor: simplify policy evaluation by using mock functions in regis…
nimdeveloper 83869f4
refactor: update wallet methods and policies for transaction handling…
nimdeveloper e37662a
refactor: enhance policy evaluation and testing in WdkManager
nimdeveloper d328212
refactor: rename runPolicies to _runPolicies and introduce PolicyEval…
nimdeveloper 3c3651c
refactor: update return type of registerPolicies method to WdkManager
nimdeveloper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /** @typedef {import('../wdk-manager.js').PolicyTarget} PolicyTarget */ | ||
|
|
||
| /** | ||
| * Error thrown when a registered policy rejects an operation. | ||
| */ | ||
| export class PolicyViolationError extends Error { | ||
| /** | ||
| * @param {string} policyName | ||
| * @param {string} method | ||
| * @param {PolicyTarget} target | ||
| */ | ||
| constructor (policyName, method, target = {}) { | ||
| const targetDesc = target.wallet | ||
| ? `wallet: ${target.wallet}` | ||
| : target.protocol | ||
| ? `protocol: ${JSON.stringify(target.protocol)}` | ||
| : 'global' | ||
|
|
||
| super( | ||
| `Policy "${policyName}" rejected method "${method}" for ${targetDesc}` | ||
| ) | ||
|
|
||
| this.name = 'PolicyViolationError' | ||
| /** @type {string} */ | ||
| this.policy = policyName | ||
| /** @type {string} */ | ||
| this.method = method | ||
| /** @type {Object} */ | ||
| this.target = target | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { PolicyViolationError } from './PolicyViolationError.js' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.