@cartridge/controller-wasm 0.3.13 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartridge/controller-wasm",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "description": "Wasm bindings for Cartridge Controller and Session Account",
5
5
  "type": "module",
6
6
  "main": "./pkg-controller/account_wasm.js",
@@ -93,6 +93,8 @@ export enum ErrorCode {
93
93
  SessionRefreshRequired = 142,
94
94
  ManualExecutionRequired = 143,
95
95
  ForbiddenEntrypoint = 144,
96
+ GasAmountTooHigh = 145,
97
+ ApproveExecutionRequired = 146,
96
98
  }
97
99
  export interface JsCall {
98
100
  contractAddress: JsFelt;
@@ -253,7 +255,7 @@ export class CartridgeAccount {
253
255
  registerSessionCalldata(policies: Policy[], expires_at: bigint, public_key: JsFelt): Promise<any>;
254
256
  upgrade(new_class_hash: JsFelt): Promise<JsCall>;
255
257
  register(register: JsRegister): Promise<JsRegisterResponse>;
256
- createSession(policies: Policy[], expires_at: bigint): Promise<AuthorizedSession | undefined>;
258
+ createSession(policies: Policy[], expires_at: bigint, authorize_user_execution?: boolean | null): Promise<AuthorizedSession | undefined>;
257
259
  skipSession(policies: Policy[]): Promise<void>;
258
260
  addOwner(owner?: Signer | null, signer_input?: JsAddSignerInput | null, rp_id?: string | null): Promise<void>;
259
261
  removeOwner(signer: JsRemoveSignerInput): Promise<void>;
@@ -329,7 +331,35 @@ export class ControllerFactory {
329
331
  free(): void;
330
332
  [Symbol.dispose](): void;
331
333
  static fromStorage(app_id: string, cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
332
- static login(app_id: string, 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): Promise<LoginResult>;
334
+ /**
335
+ * Login to an existing controller account.
336
+ *
337
+ * # Parameters
338
+ *
339
+ * * `create_wildcard_session` - Whether to create a wildcard session on login. Defaults to `true`
340
+ * for backward compatibility. Set to `false` when using the `register_session` flow where
341
+ * specific policies will be registered instead of using a wildcard session.
342
+ *
343
+ * # Returns
344
+ *
345
+ * Returns a `LoginResult` containing:
346
+ * * `account` - The controller account
347
+ * * `session` - Optional session (Some if `create_wildcard_session` is true, None otherwise)
348
+ *
349
+ * # Testing
350
+ *
351
+ * The core logic is tested in the SDK layer:
352
+ * * `account_sdk::tests::session_test::test_wildcard_session_creation` - Tests session creation
353
+ * * `account_sdk::tests::session_test::test_login_with_wildcard_session_and_execute` - Tests login with session + execution
354
+ * * `account_sdk::tests::session_test::test_login_without_session_can_still_execute` - Tests login without session + execution
355
+ *
356
+ * The WASM layer is a thin wrapper that:
357
+ * 1. Converts WASM types to SDK types
358
+ * 2. Calls `Controller::new` and optionally `create_wildcard_session`
359
+ * 3. Handles WebAuthn signer updates when multiple signers are present
360
+ * 4. Registers the session with Cartridge API if requested
361
+ */
362
+ static login(app_id: string, 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): Promise<LoginResult>;
333
363
  /**
334
364
  * This should only be used with webauthn signers
335
365
  */