Skip to content

feat: session key support and Safe multisig tooling#416

Merged
rvagg merged 2 commits intomainfrom
rvagg/session-keys
Apr 1, 2026
Merged

feat: session key support and Safe multisig tooling#416
rvagg merged 2 commits intomainfrom
rvagg/session-keys

Conversation

@rvagg
Copy link
Copy Markdown
Contributor

@rvagg rvagg commented Apr 1, 2026

Add session key authentication for delegated signing from a Safe multisig wallet. When SESSION_KEY_PRIVATE_KEY is set, DealBot uses scoped session key permissions instead of direct wallet signing.

  • Add SESSION_KEY_PRIVATE_KEY env var (mutually exclusive with WALLET_PRIVATE_KEY)
  • Session key mode in both deal service and wallet SDK Synapse creation
  • Read-only account readiness check via synapse-core getUploadCosts in session key mode
  • Scripts: create-session-key-safe.mjs (session key registration calldata), fund-safe.mjs (USDFC deposit + FWSS operator approval calldata)
  • Runbook: docs/runbooks/wallet-and-session-keys.md
  • @filoz/synapse-core added as dev dependency for scripts and readiness check

Add session key authentication for delegated signing from a Safe
multisig wallet. When SESSION_KEY_PRIVATE_KEY is set, DealBot uses
scoped session key permissions instead of direct wallet signing.

- Add SESSION_KEY_PRIVATE_KEY env var (mutually exclusive with WALLET_PRIVATE_KEY)
- Session key mode in both deal service and wallet SDK Synapse creation
- Read-only account readiness check via synapse-core getUploadCosts in session key mode
- Scripts: create-session-key-safe.mjs (session key registration calldata),
  fund-safe.mjs (USDFC deposit + FWSS operator approval calldata)
- Runbook: docs/runbooks/wallet-and-session-keys.md
- @filoz/synapse-core added as dev dependency for scripts and readiness check
Copilot AI review requested due to automatic review settings April 1, 2026 05:09
@FilOzzy FilOzzy added this to FOC Apr 1, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Apr 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for operating DealBot using a Safe multisig as the root wallet while delegating day-to-day signing to a scoped, expiring session key. This includes backend wiring for session key auth, operational runbooks, and helper scripts for Safe transaction calldata.

Changes:

  • Add SESSION_KEY_PRIVATE_KEY configuration and session-key-mode Synapse initialization in backend services.
  • Add readiness/allowance handling for session-key mode plus related test updates.
  • Add operational runbook + Safe calldata generation scripts for session key registration and funding/approvals.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
apps/backend/src/config/app.config.ts Adds SESSION_KEY_PRIVATE_KEY to config + updates validation/loading logic.
apps/backend/src/deal/deal.service.ts Creates Synapse instance using session key when configured (async init).
apps/backend/src/wallet-sdk/wallet-sdk.service.ts Initializes Synapse in session-key mode and changes allowance behavior accordingly.
apps/backend/src/wallet-sdk/wallet-sdk.service.spec.ts Adds config-validation tests and basic session/direct allowance-path tests.
apps/backend/scripts/create-session-key-safe.mjs Generates Safe calldata for registering a session key on-chain.
apps/backend/scripts/fund-safe.mjs Generates Safe batch calldata for USDFC deposit and FWSS operator approvals.
docs/runbooks/wallet-and-session-keys.md New runbook documenting Safe + session key lifecycle and funding flows.
docs/environment-variables.md Documents SESSION_KEY_PRIVATE_KEY and updates wallet key guidance.
docs/production-operations.md Links to the new wallet/session key runbook.
apps/backend/package.json Adds @filoz/synapse-core (currently as a dev dependency).
pnpm-lock.yaml Lockfile update for @filoz/synapse-core.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

apps/backend/src/config/app.config.ts:114

  • IBlockchainConfig.walletPrivateKey is typed as required, but config validation now makes WALLET_PRIVATE_KEY optional (session key mode). This can leak undefined/"" into runtime code paths that still assume a real private key. Suggest making walletPrivateKey optional in the interface and only constructing an account when it’s actually present/selected by validation.
export interface IBlockchainConfig {
  network: Network;
  rpcUrl?: string;
  sessionKeyPrivateKey?: `0x${string}`;
  walletAddress: string;
  walletPrivateKey: `0x${string}`;
  checkDatasetCreationFees: boolean;
  useOnlyApprovedProviders: boolean;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/backend/package.json Outdated
Comment thread apps/backend/src/config/app.config.ts Outdated
Comment thread apps/backend/src/config/app.config.ts
Comment thread apps/backend/src/config/app.config.ts Outdated
Comment thread apps/backend/src/wallet-sdk/wallet-sdk.service.ts
Comment thread apps/backend/src/wallet-sdk/wallet-sdk.service.spec.ts Outdated
Comment thread apps/backend/src/wallet-sdk/wallet-sdk.service.spec.ts
Comment thread apps/backend/src/deal/deal.service.ts Outdated
Comment thread apps/backend/scripts/fund-safe.mjs
Comment thread docs/runbooks/wallet-and-session-keys.md Outdated
@github-project-automation github-project-automation Bot moved this from 📌 Triage to ✔️ Approved by reviewer in FOC Apr 1, 2026
@rvagg rvagg merged commit 8d089a2 into main Apr 1, 2026
7 checks passed
@rvagg rvagg deleted the rvagg/session-keys branch April 1, 2026 05:45
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC Apr 1, 2026
@BigLep BigLep mentioned this pull request Apr 2, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

4 participants