-
Notifications
You must be signed in to change notification settings - Fork 7
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
Introduce transact plugin hooks #1019
Conversation
@brandonfancher adding you as a reviewer because of the updates to the supervisor / plugin loading code |
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.
Deleted code is tested code 🔥
let user = this.getLoggedInUser(); | ||
if (!!user) { | ||
const account = this.getAccount(user); | ||
if (account === undefined) { | ||
console.warn( | ||
`Invalid user account '${user}' detected. Automatically logging out.`, | ||
); | ||
this.logout(); | ||
// Consider deleting the user from the accounts plugin db | ||
} else { | ||
// Current limitation: an auth service plugin must be called "plugin" ("<service>:plugin") | ||
this.loader.trackPlugins([ | ||
pluginId(account.authService, "plugin"), | ||
]); | ||
} | ||
await this.loader.processPlugins(); | ||
await this.loader.awaitReady(); | ||
} |
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 lines 102
and 103
supposed to run even when the user account is invalid?
Assuming they are not and assuming you're okay with early returns, this all could be:
// Phase 2: Loads plugins needed by the current user
const user = this.getLoggedInUser();
if (!user) return;
const account = this.getAccount(user);
if (account === undefined) {
console.warn(`Invalid user account '${user}' detected. Automatically logging out.`);
this.logout();
// Consider deleting the user from the accounts plugin db
return;
}
// Current limitation: an auth service plugin must be called "plugin" ("<service>:plugin")
this.loader.trackPlugins([
pluginId(account.authService, "plugin"),
]);
await this.loader.processPlugins();
await this.loader.awaitReady();
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.
Thanks, refactored
} | ||
|
||
let action_groups: Vec<ActionGroup> = partition_by_label(actions); | ||
let transformer_plugin = TxTransformLabel::get_transformer_plugin().unwrap(); |
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.
let Some()
or if let Some()
is better than a separate test and unwrap.
Transact plugin hooks
Adds hooks to the transact plugin, allowing third-party apps to "hook" into various functionality to dynamically modify the process of transaction construction and authorization.
For example:
invited-sys
user with custom auth claims/proofs in order to create their first account.Transaction construction lifecycle with hooks
The transaction construction cycle, including hooks, is as follows:
start-tx
add-action-to-transaction
finish-tx
Hook worlds
The transact plugin's wit file contains worlds for using various hooks. Users of these hooks simply include the world corresponding to their hook, and their toolchain will enforce that their plugin exports the necessary functionality to be compatible with the transact plugin's expectations.
Support inline interfaces
Allows the component parser (used by supervisor to understand plugins) to support plugins with interfaces defined inline in a world, rather than requiring them to be defined outside of a world and pulled in.
Better adherence to the wit world spec.