Skip to content

findAuthorizers

findAuthorizers(client, options): Promise<OutputType>

Defined in: packages/synapse-core/src/session-key/find-authorizers.ts:121

Find every wallet (identity) that authorized a session key.

Scans AuthorizationsUpdated events on the session key registry from toBlock back to fromBlock, in windows of blockRange blocks, and returns one entry per distinct identity that authorized signer, ordered by its most recent authorization (newest first). Revocations (zero expiry) and authorizations with no permissions are ignored.

Treat more than one result as a red flag. SessionKeyRegistry.login needs no consent from the signer, so any wallet that knows the session key address can authorize it, for instance after seeing the real authorization on-chain. Another wallet can add an authorization but cannot remove yours, so for a freshly created key exactly one result is expected. When there are several, do not pick one: stop, or ask the user which wallet is theirs. Even with one result, show the address to the user to confirm before binding to it or sending data to the account it controls.

The registry does not index signer, so the match happens locally and the whole range is scanned. Keep fromBlock close to the block when the session key was created to limit the number of requests.

The result does not say which permissions are still valid; use authorizationExpiry or getExpirations for that.

Parameter Type Description
client Client<Transport, Chain> The client to use to read the logs.
options OptionsType findAuthorizers.OptionsType

Promise<OutputType>

The wallets that authorized the session key findAuthorizers.OutputType

Errors findAuthorizers.ErrorType

import { findAuthorizers } from '@filoz/synapse-core/session-key'
import { createPublicClient, http } from 'viem'
import { calibration } from '@filoz/synapse-core/chains'

const client = createPublicClient({
  chain: calibration,
  transport: http(),
})

const authorizers = await findAuthorizers(client, {
  signer: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
  fromBlock: 3_000_000n,
})

if (authorizers.length !== 1) {
  throw new Error(`Expected one authorizing wallet, found ${authorizers.length}`)
}
const root = authorizers[0].identity