/* tslint:disable */ /* eslint-disable */ /** * JavaScript-friendly OutsideExecution V3 structure */ export interface JsOutsideExecutionV3 { caller: JsFelt; execute_after: number; execute_before: number; calls: JsCall[]; nonce: [JsFelt, JsFelt]; } /** * Result type for signExecuteFromOutside containing both the OutsideExecution and signature */ export interface JsSignedOutsideExecution { outside_execution: JsOutsideExecutionV3; signature: JsFelt[]; } export interface ApprovalPolicy { target: JsFelt; spender: JsFelt; amount: JsFelt; } export interface AuthorizedSession { session: Session; authorization: JsFelt[] | null; isRegistered: boolean; expiresAt: number; allowedPoliciesRoot: JsFelt; metadataHash: JsFelt; sessionKeyGuid: JsFelt; guardianKeyGuid: JsFelt; } export interface CallPolicy { target: JsFelt; method: JsFelt; authorized?: boolean; } export interface Credentials { authorization: JsFelt[]; privateKey: JsFelt; } export interface Eip191Signer { address: string; } export interface ImportedControllerMetadata { username: string; classHash: JsFelt; rpcUrl: string; salt: JsFelt; owner: Owner; address: JsFelt; chainId: JsFelt; } export interface ImportedProvedPolicy { policy: Policy; proof: JsFelt[]; } export interface ImportedSession { requestedPolicies: Policy[]; provedPolicies: ImportedProvedPolicy[]; expiresAt: number; allowedPoliciesRoot: JsFelt; metadataHash: JsFelt; sessionKeyGuid: JsFelt; guardianKeyGuid: JsFelt; metadata: string; } export interface ImportedSessionMetadata { session: ImportedSession; maxFee?: JsFelt; credentials?: Credentials; isRegistered: boolean; appId?: string; policies?: Policy[]; } export interface JsCall { contractAddress: JsFelt; entrypoint: string; calldata: JsFelt[]; } export interface JsEstimateFeeDetails { nonce: JsFelt; } export interface JsFeeEstimate { l1_gas_consumed: number; l1_gas_price: number; l2_gas_consumed: number; l2_gas_price: number; l1_data_gas_consumed: number; l1_data_gas_price: number; overall_fee: number; } export interface Owner { signer?: Signer; account?: JsFelt; } export interface Session { policies: Policy[]; expiresAt: number; metadataHash: JsFelt; sessionKeyGuid: JsFelt; guardianKeyGuid: JsFelt; } export interface Signer { webauthns?: WebauthnSigner[]; webauthn?: WebauthnSigner; starknet?: StarknetSigner; eip191?: Eip191Signer; } export interface StarknetSigner { privateKey: JsFelt; } export interface TypedDataPolicy { scope_hash: JsFelt; authorized?: boolean; } export interface WebauthnSigner { rpId: string; credentialId: string; publicKey: string; } export type Felts = JsFelt[]; export type JsAddSignerInput = SignerInput; export type JsFeeSource = "PAYMASTER" | "CREDITS"; export type JsFelt = Felt; export type JsPriceUnit = "WEI" | "FRI"; export type JsRegister = RegisterInput; export type JsRegisterResponse = ResponseData; export type JsRemoveSignerInput = SignerInput; export type JsRevokableSession = RevokableSession; export type JsSubscribeSessionResult = SubscribeCreateSessionSubscribeCreateSession; export type Policy = CallPolicy | TypedDataPolicy | ApprovalPolicy; export class CartridgeAccount { private constructor(); free(): void; [Symbol.dispose](): void; addOwner(owner?: Signer | null, signer_input?: JsAddSignerInput | null, rp_id?: string | null): Promise; createPasskeySigner(rp_id: string): Promise; createSession(app_id: string, policies: Policy[], expires_at: bigint, authorize_user_execution?: boolean | null): Promise; delegateAccount(): Promise; deploySelf(max_fee?: JsFeeEstimate | null): Promise; disconnect(): Promise; estimateInvokeFee(calls: JsCall[]): Promise; execute(calls: JsCall[], max_fee?: JsFeeEstimate | null, fee_source?: JsFeeSource | null): Promise; executeFromOutsideV2(calls: JsCall[], fee_source?: JsFeeSource | null): Promise; executeFromOutsideV3(calls: JsCall[], fee_source?: JsFeeSource | null): Promise; exportAuthorizedSession(app_id?: string | null): Promise; exportMetadata(): Promise; static fromStorage(cartridge_api_url: string): Promise; getNonce(): Promise; hasAuthorizedPoliciesForCalls(app_id: string, calls: JsCall[]): Promise; hasAuthorizedPoliciesForMessage(app_id: string, typed_data: string): Promise; /** * Checks if there are stored policies for a given app_id. * * # Parameters * - `app_id`: The application identifier to check for stored policies * * # Returns * `true` if policies exist for the given app_id, `false` otherwise */ hasPoliciesForAppId(app_id: string): Promise; hasRequestedSession(app_id: string, policies: Policy[]): Promise; importSession(imported_session: ImportedSessionMetadata): Promise; isRegisteredSessionAuthorized(policies: Policy[], public_key?: JsFelt | null): Promise; /** * Creates a new `CartridgeAccount` instance. * * # Parameters * - `rpc_url`: The URL of the JSON-RPC endpoint. * - `address`: The blockchain address associated with the account. * - `username`: Username associated with the account. * - `owner`: A Owner struct containing the owner signer and associated data. */ static new(class_hash: JsFelt, rpc_url: string, address: JsFelt, username: string, owner: Owner, cartridge_api_url: string): Promise; /** * Creates a new `CartridgeAccount` instance with a randomly generated Starknet signer. * The controller address is computed internally based on the generated signer. * * # Parameters * - `rpc_url`: The URL of the JSON-RPC endpoint. * - `username`: Username associated with the account. */ static newHeadless(class_hash: JsFelt, rpc_url: string, username: string, cartridge_api_url: string): Promise; register(register: JsRegister): Promise; registerSession(app_id: string, policies: Policy[], expires_at: bigint, public_key: JsFelt, max_fee?: JsFeeEstimate | null): Promise; registerSessionCalldata(policies: Policy[], expires_at: bigint, public_key: JsFelt): Promise; removeOwner(signer: JsRemoveSignerInput): Promise; revokeSession(session: JsRevokableSession): Promise; revokeSessions(sessions: JsRevokableSession[]): Promise; /** * Signs an OutsideExecution V3 transaction and returns both the OutsideExecution object and its signature. * * # Parameters * - `calls`: Array of calls to execute from outside * * # Returns * A `JsSignedOutsideExecution` containing the OutsideExecution V3 object and its signature */ signExecuteFromOutside(calls: JsCall[]): Promise; signMessage(typed_data: string): Promise; skipSession(app_id: string, policies: Policy[]): Promise; trySessionExecute(app_id: string, calls: JsCall[], fee_source?: JsFeeSource | null): Promise; upgrade(new_class_hash: JsFelt): Promise; } /** * A type for accessing fixed attributes of `CartridgeAccount`. * * This type exists as concurrent mutable and immutable calls to `CartridgeAccount` are guarded * with `WasmMutex`, which only operates under an `async` context. If these getters were directly * implemented under `CartridgeAccount`: * * - calls to them would unnecessarily have to be `async` as well; * - there would be excessive locking. * * This type is supposed to only ever be borrowed immutably. So no concurrent access control would * be needed. */ export class CartridgeAccountMeta { private constructor(); free(): void; [Symbol.dispose](): void; address(): string; chainId(): string; classHash(): string; owner(): Owner; ownerGuid(): JsFelt; rpcUrl(): string; username(): string; } /** * A type used as the return type for constructing `CartridgeAccount` to provide an extra, * separately borrowable `meta` field for synchronously accessing fixed fields. * * This type exists instead of simply having `CartridgeAccount::new()` return a tuple as tuples * don't implement `IntoWasmAbi` which is needed for crossing JS-WASM boundary. */ export class CartridgeAccountWithMeta { private constructor(); free(): void; [Symbol.dispose](): void; intoAccount(): CartridgeAccount; meta(): CartridgeAccountMeta; } export class ControllerFactory { private constructor(); free(): void; [Symbol.dispose](): void; /** * This should only be used with webauthn signers */ static apiLogin(username: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, owner: Owner, cartridge_api_url: string): Promise; static fromMetadata(metadata: ImportedControllerMetadata, cartridge_api_url: string): Promise; static fromStorage(cartridge_api_url: string): Promise; /** * Login to an existing controller account. * * # Parameters * * * `create_wildcard_session` - Whether to create a wildcard session on login. Defaults to `true` * for backward compatibility. Set to `false` when using the `register_session` flow where * specific policies will be registered instead of using a wildcard session. * * # Returns * * Returns a `LoginResult` containing: * * `account` - The controller account * * `session` - Optional session (Some if `create_wildcard_session` is true, None otherwise) * * # Testing * * The core logic is tested in the SDK layer: * * `account_sdk::tests::session_test::test_wildcard_session_creation` - Tests session creation * * `account_sdk::tests::session_test::test_login_with_wildcard_session_and_execute` - Tests login with session + execution * * `account_sdk::tests::session_test::test_login_without_session_can_still_execute` - Tests login without session + execution * * The WASM layer is a thin wrapper that: * 1. Converts WASM types to SDK types * 2. Calls `Controller::new` and optionally `create_wildcard_session` * 3. Handles WebAuthn signer updates when multiple signers are present * 4. Registers the session with Cartridge API if requested */ static login(username: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, owner: Owner, cartridge_api_url: string, session_expires_at_s: bigint, is_controller_registered?: boolean | null, create_wildcard_session?: boolean | null, app_id?: string | null): Promise; } export enum ErrorCode { StarknetFailedToReceiveTransaction = 1, StarknetContractNotFound = 20, StarknetBlockNotFound = 24, StarknetInvalidTransactionIndex = 27, StarknetClassHashNotFound = 28, StarknetTransactionHashNotFound = 29, StarknetPageSizeTooBig = 31, StarknetNoBlocks = 32, StarknetInvalidContinuationToken = 33, StarknetTooManyKeysInFilter = 34, StarknetContractError = 40, StarknetTransactionExecutionError = 41, StarknetClassAlreadyDeclared = 51, StarknetInvalidTransactionNonce = 52, StarknetInsufficientMaxFee = 53, StarknetInsufficientAccountBalance = 54, StarknetValidationFailure = 55, StarknetCompilationFailed = 56, StarknetContractClassSizeIsTooLarge = 57, StarknetNonAccount = 58, StarknetDuplicateTx = 59, StarknetCompiledClassHashMismatch = 60, StarknetUnsupportedTxVersion = 61, StarknetUnsupportedContractClassVersion = 62, StarknetUnexpectedError = 63, StarknetNoTraceAvailable = 10, StarknetReplacementTransactionUnderpriced = 64, StarknetFeeBelowMinimum = 65, SignError = 101, StorageError = 102, AccountFactoryError = 103, PaymasterExecutionTimeNotReached = 104, PaymasterExecutionTimePassed = 105, PaymasterInvalidCaller = 106, PaymasterRateLimitExceeded = 107, PaymasterNotSupported = 108, PaymasterHttp = 109, PaymasterExcecution = 110, PaymasterSerialization = 111, CartridgeControllerNotDeployed = 112, InsufficientBalance = 113, OriginError = 114, EncodingError = 115, SerdeWasmBindgenError = 116, CairoSerdeError = 117, CairoShortStringToFeltError = 118, DeviceCreateCredential = 119, DeviceGetAssertion = 120, DeviceBadAssertion = 121, DeviceChannel = 122, DeviceOrigin = 123, AccountSigning = 124, AccountProvider = 125, AccountClassHashCalculation = 126, AccountFeeOutOfRange = 128, ProviderRateLimited = 129, ProviderArrayLengthMismatch = 130, ProviderOther = 131, SessionAlreadyRegistered = 132, UrlParseError = 133, Base64DecodeError = 134, CoseError = 135, PolicyChainIdMismatch = 136, InvalidOwner = 137, GasPriceTooHigh = 138, TransactionTimeout = 139, ConversionError = 140, InvalidChainId = 141, SessionRefreshRequired = 142, ManualExecutionRequired = 143, ForbiddenEntrypoint = 144, GasAmountTooHigh = 145, ApproveExecutionRequired = 146, } /** * JavaScript-friendly chain configuration */ export class JsChainConfig { free(): void; [Symbol.dispose](): void; constructor(class_hash: JsFelt, rpc_url: string, owner: Owner, address?: JsFelt | null); readonly address: JsFelt | undefined; readonly class_hash: JsFelt; readonly owner: Owner; readonly rpc_url: string; } export class JsControllerError { private constructor(); free(): void; [Symbol.dispose](): void; code: ErrorCode; get data(): string | undefined; set data(value: string | null | undefined); message: string; } export class LoginResult { private constructor(); free(): void; [Symbol.dispose](): void; intoValues(): Array; } /** * WASM bindings for MultiChainController */ export class MultiChainAccount { private constructor(); free(): void; [Symbol.dispose](): void; /** * Adds a new chain configuration */ addChain(config: JsChainConfig): Promise; /** * Gets an account instance for a specific chain */ controller(chain_id: JsFelt): Promise; /** * Creates a new MultiChainAccount with multiple chain configurations */ static create(username: string, chain_configs: JsChainConfig[], cartridge_api_url: string): Promise; /** * Loads a MultiChainAccount from storage */ static fromStorage(cartridge_api_url: string): Promise; /** * Removes a chain configuration */ removeChain(chain_id: JsFelt): Promise; } /** * Metadata for displaying multi-chain information */ export class MultiChainAccountMeta { private constructor(); free(): void; [Symbol.dispose](): void; readonly chains: JsFelt[]; readonly username: string; } /** * Computes the Starknet contract address for a controller account without needing a full instance. * * # Arguments * * * `class_hash` - The class hash of the account contract (JsFelt). * * `owner` - The owner configuration for the account. * * `salt` - The salt used for address calculation (JsFelt). * * # Returns * * The computed Starknet contract address as a `JsFelt`. */ export function computeAccountAddress(class_hash: JsFelt, owner: Owner, salt: JsFelt): JsFelt; export function signerToGuid(signer: Signer): JsFelt; /** * Subscribes to the creation of a session for a given controller, session_key_guid and cartridge api url. * The goal of this function is to know from any place when the register session flow has been completed, and to * get the authorization. */ export function subscribeCreateSession(session_key_guid: JsFelt, cartridge_api_url: string): Promise;