Skip to content

Use guard for sessions#845

Merged
patrislav merged 22 commits intomasterfrom
guard-v3-for-sessions
Aug 27, 2025
Merged

Use guard for sessions#845
patrislav merged 22 commits intomasterfrom
guard-v3-for-sessions

Conversation

@patrislav
Copy link
Member

  • move guard logic into @0xsequence/guard (where it should've been)
  • change wallet configuration to wrap each module in a "guard-gated" nested signer
  • provide a signEnvelope method on SessionManager that adds a guard signature if needed

@patrislav patrislav requested review from a team as code owners August 21, 2025 17:00
guard: new Guard(shared),
guard: shared.sequence.guardUrl
? new Guard.Sequence.GuardSigner(shared.sequence.guardUrl, shared.sequence.guardAddress)
: new Guard.Local.GuardSigner(Secp256k1.randomPrivateKey()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we support a fixed local key? Maybe as another env var. Otherwise the guard will be different every time you restart the app making local dev harder.

@patrislav patrislav marked this pull request as draft August 22, 2025 11:03
}
const signedEnvelope = Envelope.toSigned(envelope, [sapientSignature])

// TODO: check whether guard signature is even needed for this wallet based on the topology
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove comment. I think this if statement is sufficient.

this.walletAddress = implicitSession?.walletAddress || explicitSessions[0]?.walletAddress || null
this.loginMethod = result[0]?.loginMethod || null
this.userEmail = result[0]?.userEmail || null
this.guard = implicitSession?.guard || explicitSessions[0]?.guard
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably fine but could do || explicitSessions.find(s => !!s.guard)?.guard

@patrislav patrislav marked this pull request as ready for review August 26, 2025 20:16
Copy link
Contributor

@ScreamingHawk ScreamingHawk left a comment

Choose a reason for hiding this comment

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

LGTM!

@patrislav patrislav merged commit efb3354 into master Aug 27, 2025
3 checks passed
@patrislav patrislav deleted the guard-v3-for-sessions branch August 27, 2025 09:01
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.

3 participants