import { type DkgData, PortalError } from '@portal-hq/utils' import type { MpcErrorCodes } from './src/mpc/errors' import Portal, { BackupMethods, PortalCurve } from './src/index' // Re-export shared types for backward compatibility export type { Address, AddressResult, BackupConfigs, BackupData, BackupResponse, BackupResult, Balance, BuiltEip155Transaction, BuiltSolanaTransaction, BuiltTransaction, CustomBackupConfig, Dapp, DappImage, DappOnNetwork, DecryptArgs, DecryptData, DecryptResult, EIP1559Transaction, EjectPrivateKeysResult, EjectResult, EncryptArgs, EncryptedData, EncryptedResult, EncryptedWithPasswordData, EncryptedWithPasswordResult, EvaluatedTransaction, EvaluateTransactionParam, FeatureFlags, FundParams, FundResponse, FundResponseData, FundResponseMetadata, GDriveConfig, GenerateData, GenerateResponse, GenerateResult, LegacyTransaction, MpcStatus, Network, NFT, NFTContract, OrgBackupShares, PasskeyConfig, PasskeyStatusResponse, PasswordConfig, QuoteArgs, QuoteResponse, RotateData, RotateResult, RawSignOptions, SendAssetParams, SendAssetResponse, SharesOnDeviceResponse, SignArgs, SignResult, SimulatedTransaction, SimulatedTransactionChange, SimulatedTransactionError, SimulateTransactionParam, SwitchEthereumChainParameter, Transaction, Type, TypedData, GetAssetsResponse, IframeConfigurationOptions, NFTAsset, EvaluateTransactionOperationType, PortalError, } from './src/shared/types' import type { BackupConfigs, FeatureFlags, GDriveConfig, MpcStatus, OrgBackupShares, PasskeyConfig, DecryptArgs, EncryptArgs, SignArgs, BackupResult, DecryptResult, EncryptedResult, EncryptedWithPasswordResult, GenerateResult, SignResult, EjectResult, EIP1559Transaction, LegacyTransaction, } from './src/shared/types' export type EventHandler = (event: Event) => void | Promise export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug' export interface ILogger { error(...args: unknown[]): void warn(...args: unknown[]): void info(...args: unknown[]): void debug(...args: unknown[]): void } export type EthereumTransaction = EIP1559Transaction | LegacyTransaction export type MessageData = | BackupArgs | DecryptArgs | EncryptArgs | GenerateArgs | RecoverArgs | SignArgs export type ProgressCallback = (status: MpcStatus) => void | Promise export type ValidRpcErrorCodes = 4001 | 4100 | 4200 | 4900 | 4901 export interface FirebaseStorageConfigOptions { getToken: (options?: { forceRefresh?: boolean }) => Promise tbsHost?: string } // Interfaces export interface BackupArgs extends MpcOperationArgs { backupMethod: BackupMethods backupConfigs: BackupConfigs = { } } export interface BackupShareResult { cipherText: string encryptionKey: string } export interface PasskeyOptions { /** * Toggle legacy popup behaviour. Defaults to true to preserve existing integrations. */ usePopup?: boolean /** * Fully qualified domain or hostname that hosts passkey endpoints. * Example: `passkeys.wigwam.app` */ customDomain?: string /** * Human-friendly name rendered in the browser passkey prompt. */ relyingPartyName?: string /** * Override the relying party ID. Useful when the TBS domain differs from the browser origin. * Example: Use `localhost` when testing locally against a staging TBS. */ relyingPartyId?: string } export interface BackupOptions extends PasskeyOptions { /** * Backup method to use when running combined flows. * Defaults to `BackupMethods.passkey` for direct passkey flows. */ backupMethod?: BackupMethods } export interface ClientResponse { id: string address: string backupStatus?: string | null custodian: ClientResponseCustodian environment: ClientResponseEnvironment ejectedAt: string | null isAccountAbstracted: boolean metadata: ClientResponseMetadata wallets: ClientResponseWallet[] } interface ClientResponseCustodian { id: string name: string } interface ClientResponseEnvironment { id: string name: string backupWithPortalEnabled: boolean } interface ClientResponseMetadata { namespaces: Record } interface NamespaceMetadataItem { curve: PortalCurve address: string } interface ClientResponseSharePair { id: string createdAt: string status: SharePairStatus } interface ClientResponseBackupSharePair extends ClientResponseSharePair { backupMethod: BackupMethods } export interface ClientResponseWallet { id: string createdAt: string backupSharePairs: ClientResponseBackupSharePair[] curve: PortalCurve ejectableUntil?: string publicKey: string signingSharePairs: ClientResponseSharePair[] } export interface EjectArgs extends RecoverArgs { organizationBackupShare: string } export interface EjectPrivateKeysArgs extends RecoverArgs { organizationBackupShares: OrgBackupShares } export interface EjectWorkerArgs extends MpcOperationArgs { clientShare: string organizationBackupShare: string } export interface RpcConfig { [key: string]: string } export interface GDriveStorageOptions { portal: Portal } export type GenerateArgs = MpcOperationArgs export interface PasskeyStorageOptions { portal: IPortal relyingParty?: string relyingPartyOrigins?: string[] webAuthnHost?: string authOrigin?: string } export interface MpcErrorData { code: MpcErrorCodes message: (str?: string) => string } export interface MpcOperationArgs { host: string mpcVersion: string featureFlags?: FeatureFlags } export interface MpcOptions { portal: Portal } export interface PortalApiOptions { apiKey: string baseUrl: string chainId: string host: string portal: Portal } export interface PortalOptions { // Required options rpcConfig: RpcConfig /** * Optional RPC map for iframe-proxied reads only (receipt / Solana polling). Parent signing still * uses `rpcConfig`. Omit in production when iframe and gateway CORS already align. */ iframeRpcConfig?: RpcConfig // Optional options apiKey?: string authToken?: string authUrl?: string autoApprove?: boolean gdrive?: GDriveConfig passkey?: PasskeyConfig host?: string mpcHost?: string keychain?: KeychainAdapter mpcVersion?: string featureFlags?: FeatureFlags chainId?: string logLevel?: LogLevel logger?: ILogger } export interface ProviderOptions { // Required options portal: Portal // Optional chainId?: number } export interface RegisteredEventHandler { handler: EventHandler once?: boolean } export interface RequestArguments { chainId?: string method: RequestMethod params?: unknown[] | SigningRequestParams sponsorGas?: boolean signatureApprovalMemo?: string traceId?: string } export interface RecoverArgs extends MpcOperationArgs { backupConfigs: BackupConfigs backupMethod: BackupMethods cipherText: string featureFlags?: FeatureFlags } export interface RpcErrorDefinition { description: string name: string } export interface RpcErrorOptions { code: ValidProviderRpcErrorCodes data?: unknown } export interface SignData { R: string S: string } export interface SignerOptions { portal: Portal } export interface WorkerMessage { type: string data: | BackupArgs | DecryptArgs | EncryptArgs | GenerateArgs | RecoverArgs | SignArgs } export interface WorkerResult { type: string data: | boolean | string | BackupResult | DecryptResult | EncryptedResult | EncryptedWithPasswordResult | GenerateResult | MpcStatus | PortalError | ReadyResult | RecoverResult | SignResult | EjectResult }