-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
CAIP Multichain API with permission refactor changes #4961
CAIP Multichain API with permission refactor changes #4961
Conversation
Co-authored-by: Alex Donesky <adonesky@gmail.com>
…ccounts.ts Co-authored-by: Alex Donesky <adonesky@gmail.com>
Co-authored-by: Alex Donesky <adonesky@gmail.com>
Co-authored-by: Alex Donesky <adonesky@gmail.com>
Co-authored-by: Alex Donesky <adonesky@gmail.com>
Co-authored-by: Alex Donesky <adonesky@gmail.com>
Co-authored-by: Alex Donesky <adonesky@gmail.com>
… caip25-permission-refactor
…rings are supported
…th-permission-refactor
const scopeObject = getSessionScopes(caveat.value)[ | ||
scope as InternalScopeString | ||
]; |
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.
Hmmm when I first read this I thought it was a bit strange to rehydrate this and then have a method authorization check since our permissions are really not method oriented now... But hmmm maybe its still correct since we still need to validate that the requested method is supported
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.
Yeah, we still need to keep the interface consistent. I.e. trying to call a scope/method via wallet_invokeMethod
that wasn't returned to you via wallet_createSession
/ wallet_sessionChanged
should throw an unauthorized error rather than a method not found error
* e.g. We flatten each reference into its own scopeObject before storing them in a `endowment:caip25` permission. | ||
* we resolve the `references` property into a scopeObject per reference and | ||
* assign an empty array to the `accounts` property if not already defined | ||
* to more easily read chain specific permissions. |
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.
Feels like we should call out how/why this type is used since we have 3 of them now 🤣 .
- return type for
getSession
- type used for validation pre-serialization?
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.
e672262 maybe?
packages/multichain/src/adapters/caip-permission-adapter-session-scopes.ts
Show resolved
Hide resolved
packages/multichain/src/adapters/caip-permission-adapter-session-scopes.ts
Show resolved
Hide resolved
…on-scopes.ts Co-authored-by: Alex Donesky <adonesky@gmail.com>
…on-scopes.ts Co-authored-by: Alex Donesky <adonesky@gmail.com>
…n wallet_invokeMethod
…ion-refactor' into caip-multichain-api-with-permission-refactor
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
Explanation
This diff is a bit messy since it also brings in the core PR that refactors the CAIP-25 permission which the caip-multichain-api branch doesn't have yet.The main thing this PR does is adds
getSessionScopes()
which massages the new CAIP-25 permission into aNormalizedScopesObject
References
Changelog
@metamask/package-a
@metamask/package-b
Checklist