Skip to content

Conversation

@adonesky1
Copy link
Contributor

@adonesky1 adonesky1 commented Jun 10, 2024

This proposal introduces new "lifecycle" methods for managing permissions within an existing CAIP-25 session, allowing for addition, revocation, and retrieval of permissions. These methods provide an alternative to session management via sessionIds, allowing sessionIds to be optional for CAIP-25.

@adonesky1 adonesky1 force-pushed the ad/life-cycle-methods branch from bbb3e3b to a15b6ab Compare June 10, 2024 15:19
@adonesky1 adonesky1 marked this pull request as ready for review June 11, 2024 23:21
@adonesky1 adonesky1 requested review from jiexi and vandan June 12, 2024 01:34
Copy link

@vandan vandan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we need a way to distinguish between the initial and subsequent permission requests as they may have different implications to the way permission requests are presented to end-users.

Specifying that subsequent calls to provider_authorize will be treated as additive (similar to how provider_augment would work) seems like an elegant way to handle this. Otherwise we might have ambiguity about what happens when provider_authorize is called multiple times.

I initially thought we might need wildcards in the provider_revoke call, but with provider_getSession available it should be trivial to create application-side utilities to do things like "revoke all" permissions (aka logout).

@hmalik88
Copy link
Collaborator

I would prefer the various methods to be spun out in their own respective CAIPs, you can mark the CAIPs based off of the PR #.

CAIPs/caip-x.md Outdated

- **Current Method:** "If a respondent (e.g. a wallet) needs to initiate a new session, whether due to user input, security policy, or session expiry reasons, it can simply generate a new session identifier to signal this notification to the calling provider."
- Given this language it is unclear if a wallet can revoke permissions without creating a new session. It is also therefore unclear if a wallet can revoke some subset of permissions without creating a new session.
- **Proposed Method:** Wallet publishes and caller/dapp listens for an event `providerAuthorizationChanged` with the new full sessionScope.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you're referring to user-initiated permission revocation in the extension? If so, what happens if the dapp is not connected to the wallet when the permission is revoked? Can the dapp just not rely on provider_getSession?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you're referring to user-initiated permission revocation in the extension? If so, what happens if the dapp is not connected to the wallet when the permission is revoked?

🤔 I guess you mean if the connection is severed somehow? I suppose in that case the dapp would use provider_getSession but I think this event is useful for most cases where a dapp can immediately reflect a change to the state of its permissions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

severed, or just timed out. i think the fundamental assumption that both app and wallet persist the config (if not the "session" in browser-memory or RPC-connection sense) is the first thing we need to be aligned on, before getting to other stuff? in hassan's example, the wallet would let the user revoke a permission and... persist that message/event until there's an active RPC connection, right?

all this sounds fine to me, but should be explicit in the spec since it obligates the provider (or the wallet+plus+provider) to persist until next connection. conversely, if this event is ONLY fired within an active session and dropped otherwise, specify that and separately define the behavior if user tells wallet to revoke without (or without knowing about the absence of) a live connection

Copy link
Contributor Author

@adonesky1 adonesky1 Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the following additional sentence assuage your concerns?

"If a connection between the wallet and the caller/dapp is severed and the possiblity of missed events arises, the caller/dapp should immediately call wallet_getSession to retrieve the current session scopes."

@adonesky1
Copy link
Contributor Author

I would prefer the various methods to be spun out in their own respective CAIPs, you can mark the CAIPs based off of the PR #.

Happy to do this. Wanted to present these as a package to lay out the full sweep of scenarios they are serving in place of sessionIds.

CAIPs/caip-x.md Outdated

4. **Dapp Initiated Permissions Revocation:**

- **Current Method:** "if a caller [dapp] needs to initiate a new session, it can do so by sending a new request without a sessionIdentifier."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...on the assumption that dapp should only persist one "session" (config) at a time for any given wallet, thus new sessionId overwrites/replaces the revoked session, that by not being persisted is as good as dead.

(no change here, just filling in the assumptions/thought behind status quo in case it's cryptic)

Copy link
Collaborator

@bumblefudge bumblefudge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, looking forward to discussing Wednesday on the community call

@adonesky1 adonesky1 force-pushed the ad/life-cycle-methods branch from 53bec6f to 8c48748 Compare June 30, 2024 15:59
@adonesky1
Copy link
Contributor Author

adonesky1 commented Jun 30, 2024

I'm starting to wonder - forgive me if someone already suggested this - whether wallet_updateSession (previously called provider_augment in this PR) could be used for both adding and revoking permissions, rather than having a separate wallet_revokeSession method to partially or fully revoke. Why not just have one method that could do both additions and revocations simultaneously.

I suppose you could then argue why not just let it all fall back to provider_authorize (which may be renamed to wallet_createSession) and just create a new "session" with modified scopes (added and/or revoked) each time.

I think that could work too. Whether its a new session or just an updated existing session becomes pure semantics when you don't include a sessionId and the new wallet_createSession must be called with the full scopes that should be authorized after the call (not just the delta).

After reflecting on it I think its cleaner to either:

  1. Just fall back to provider_authorize/wallet_createSession for adding/revoking to an existing session
    or
  2. Just use wallet_createSession for an session initiation and wallet_updateSession for any changes (additions or revocations) to an existing session.

WDYT?
@bumblefudge @pedrouid @shanejonas @vandan @hmalik88 @300

@bumblefudge
Copy link
Collaborator

  1. Just fall back to provider_authorize/wallet_createSession for adding/revoking to an existing session
    or
  2. Just use wallet_createSession for an session initiation and wallet_updateSession for any changes (additions or revocations) to an existing session.

But isn't option (1) just... status quo? CAIP-25 as written means the dapp sends update/escalate/partial-remove proposals by sending the entire state it would like to see, with the current sessionId written on the envelope, or if it sends an envelope with no sessionId, that's interpreted by the wallet as wiping the slate and proposing a totally new session.

As I understood it, the whole reason for adding more RPC methods was that either party could send deltas without a sessionId and have the other side accept/reject the delta. This gives a sessionId-free wallet a way to interact with a sessionId-relying dapp, while still allowing the dapp to send a blank sessionId when it wants to renew. Makes it easy for both sides to interact meaningfully.

Copy link
Collaborator

@bumblefudge bumblefudge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking mergeable, once we renumber all the docs? I opened tracking issues to ensure people find THIS thread when looking up THOSE documents:
image

The only thing that seems like it might change as this gets implemented is error codes and Considersations sections, but all that should be easy enough to update with separate PRs down the road.

@hmalik88 have you taken a stroll through here?

@adonesky1 adonesky1 force-pushed the ad/life-cycle-methods branch from 09666ea to 9941270 Compare July 29, 2024 16:35
Copy link
Collaborator

@hmalik88 hmalik88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants