Skip to main content
Package: @hyperauth/sdk

Factory function

createClient

Initializes the vault worker, loads the WASM enclave, and returns a fully initialized HyperAuthClient. Throws ClientStateError if the vault worker fails to start.

HyperAuthClient

All operations route through the vault worker. The enclave is never called directly.

Static factory

Constructs a client with an explicit WasmPlugin adapter. Used for testing or custom plugin topologies.

Configuration

ClientConfig

ContractsConfig

defaultContracts

Pre-configured addresses for Base Sepolia (chain ID 84532):

Core methods

generate

Generates a new identity (DID + MPC key shares) from a WebAuthn credential. Resets the auto-lock timer. Parameters GenerateOptions
Returns: GenerateResult

ping

Health check and echo test against the vault worker. Returns: PingResult

Cryptography methods

sign

Signs raw data bytes using the MPC enclave with the given encrypted key shares. Returns: SignResult

deriveAddress

Derives a chain address from a hex-encoded public key. Returns: DeriveAddressResult

mintUcan

Mints a signed UCAN token using the MPC key. Returns: MintUcanResult

parseWebAuthn

Parses a WebAuthn credential object through the enclave. Returns: ParseWebAuthnResult

Vault methods

load

Loads an encrypted database into the vault worker. Resets the auto-lock timer on success. Returns: LoadOutput — shape mirrors @hyperauth/schemas.

lock

Locks the vault: encrypts and serializes vault state. Clears the auto-lock timer. Returns: LockOutput — shape mirrors @hyperauth/schemas.

unlock

Unlocks the vault from encrypted bytes. Resets the auto-lock timer on success. Returns: UnlockOutput — shape mirrors @hyperauth/schemas.

status

Returns current vault status (locked/initialized state). Returns: StatusOutput — shape mirrors @hyperauth/schemas. Includes locked: boolean.

isLocked

Convenience accessor. Returns status().locked.

query

Queries the DID document, verification methods, accounts, and credentials for the given DID. Returns: QueryOutput
Account

exportVault

Exports the vault as a password-encrypted backup. Returns raw bytes. Throws PluginCallError on failure. VaultExportOptions

importVault

Imports a vault from a password-encrypted backup. VaultImportOptions
Returns: VaultImportOutput — shape mirrors @hyperauth/schemas. Includes success, did, accounts, credentials.

ERC-4337 methods

createRegistration

Constructs a signed ERC-4337 UserOperation for DID registration. Throws PluginCallError on failure. CreateRegistrationInput
Returns: RegistrationResult

signUserOp

Signs an ERC-4337 UserOperation using the MPC enclave. Throws PluginCallError on failure. Returns: SignUserOpResult

execute

Executes a resource-action command through the vault worker. Resource
Returns: ExecOutput<T>

submitPayment

Builds, signs, and submits an ERC-4337 payment UserOperation. Throws PluginCallError on failure. PaymentParams
Returns: PaymentResult

registerPaymentHandler

Registers a Payment Handler API service worker for browser-native payment flows. PaymentHandlerOptions
Returns: PaymentHandlerRegistration

Indexer methods

These are module-level functions, not methods on HyperAuthClient.

computeAliasHash

Computes the on-chain alias hash: keccak256(hexEncode(utf8Bytes(alias))). Matches the Go enclave convention.

lookupAlias

Queries the indexer for a registered alias by its hash. Returns: IndexerAlias

lookupDid

Returns: IndexerDid

lookupAccount

Returns: IndexerAccount

fetchStats

Returns: IndexerStats

fetchHealth

Returns: IndexerHealth
Default indexerUrl for all indexer functions: '/api/indexer'.

Passkey helpers

createPasskey

Creates a WebAuthn passkey using the ES256 (P-256) algorithm. Only ES256 is accepted; the function throws WebAuthnError if the authenticator returns a different algorithm. CreatePasskeyOptions
Returns: CreatePasskeyResult

authenticatePasskey

Triggers a WebAuthn assertion ceremony. Returns the credential ID string. Throws WebAuthnError if unsupported or cancelled.

DeviceCapabilities


Device sync methods

syncInit

Initiates a device-to-device vault sync session. Returns a session ID and public key for the initiating device. Throws PluginCallError on failure. Returns: SyncInitResult — shape mirrors @hyperauth/schemas. Includes success, session_id, public_key, error?.

syncRespond

Responds to a sync request from a remote device. Throws PluginCallError on failure. Returns: SyncRespondResult — shape mirrors @hyperauth/schemas.

syncComplete

Completes the sync handshake and merges vault state. Throws PluginCallError on failure. Returns: SyncCompleteResult — shape mirrors @hyperauth/schemas.

UCAN delegation methods

delegate

Creates a UCAN delegation to another DID. Throws PluginCallError on failure. DelegationOptions

createInvocation

Creates a UCAN invocation. Throws PluginCallError on failure. InvocationOptions

Persistence methods

These methods require the VaultWorkerCore bridge (available when using createClient).

getBootStatus

Returns boot status of the enclave and supporting services. Returns all-false if no core bridge is available.

hasPersistedVault

Returns true if a persisted vault state is available for restore.

snapshotVault

Takes a content-addressed snapshot of current vault state via Helia (IPFS). Returns { error } if no core bridge is available.

persistNow

Triggers an immediate persistence flush. Returns { success: false, error } if no core bridge is available.

hasCorebridge

true when the client was created with createClient and has access to the vault worker core bridge.

Auto-lock methods

setAutoLockCallback

Registers a callback invoked with the encrypted database bytes when the auto-lock timer fires.

setAutoLockTimeout

Updates the auto-lock inactivity timeout in milliseconds. Resets the current timer. 0 disables auto-lock.

Lifecycle methods

reset

Resets the plugin state and clears the activity timer.

close

Closes the plugin and clears the activity timer.

Wallet pipeline functions

Module-level functions for ERC-4337 UserOperation handling.

sendUserOp

Submits a UserOperation to the bundler via eth_sendUserOperation. Returns the userOpHash. Default bundlerUrl: '/api/bundler'.

getUserOpReceipt

Fetches a UserOperation receipt. Returns null if not yet confirmed. UserOpReceipt

waitForReceipt

Polls for a UserOperation receipt until confirmed or timeout. Throws NetworkError on timeout.

getSupportedEntryPoints

Returns supported entry point addresses from the bundler.

estimateUserOpGas

Estimates gas for a UserOperation via eth_estimateUserOperationGas.

sponsorUserOp

Sponsors a UserOperation via pm_sponsorUserOperation. Returns the UserOperation with paymaster fields populated.

getSmartAccountAddress

Predicts the smart account address from public key coordinates via the vault API.
Default vaultUrl: '/api'.

getAccountState

Fetches on-chain account state from the vault API.
Returns: AccountState

computeUserOpHash

Computes the ERC-4337 v0.7 UserOperation hash client-side. Matches on-chain hash derivation.

Hex utilities


Error classes

All errors extend HyperAuthError extends Error.

Shared types

EncryptedShares

UserOp

ERC-4337 v0.7 packed UserOperation. Shape mirrors @hyperauth/schemas.