@cartridge/controller-wasm 0.1.5 → 0.1.7

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.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Wasm bindings for Cartridge Controller and Session Account",
5
5
  "type": "module",
6
6
  "main": "./pkg-controller/account_wasm.js",
@@ -143,6 +143,8 @@ export type Felts = JsFelt[];
143
143
 
144
144
  export type JsFeeSource = "PAYMASTER" | "CREDITS";
145
145
 
146
+ export type JsRevokableSession = RevokableSession;
147
+
146
148
  export interface AuthorizedSession {
147
149
  session: Session;
148
150
  authorization: JsFelt[] | null;
@@ -181,13 +183,13 @@ export class CartridgeAccount {
181
183
  * - `username`: Username associated with the account.
182
184
  * - `owner`: A Owner struct containing the owner signer and associated data.
183
185
  */
184
- static new(app_id: string, class_hash: JsFelt, rpc_url: string, chain_id: JsFelt, address: JsFelt, username: string, owner: Owner): CartridgeAccountWithMeta;
185
- static fromStorage(app_id: string): CartridgeAccountWithMeta | undefined;
186
+ static new(app_id: string, class_hash: JsFelt, rpc_url: string, chain_id: JsFelt, address: JsFelt, username: string, owner: Owner, cartridge_api_url: string): CartridgeAccountWithMeta;
187
+ static fromStorage(app_id: string, cartridge_api_url: string): CartridgeAccountWithMeta | undefined;
186
188
  disconnect(): Promise<void>;
187
189
  registerSession(policies: Policy[], expires_at: bigint, public_key: JsFelt, max_fee?: JsFeeEstimate | null): Promise<any>;
188
190
  registerSessionCalldata(policies: Policy[], expires_at: bigint, public_key: JsFelt): Promise<any>;
189
191
  upgrade(new_class_hash: JsFelt): Promise<JsCall>;
190
- login(expires_at: bigint): Promise<AuthorizedSession>;
192
+ login(expires_at: bigint, is_controller_registered?: boolean | null): Promise<AuthorizedSession>;
191
193
  createSession(policies: Policy[], expires_at: bigint): Promise<AuthorizedSession | undefined>;
192
194
  skipSession(policies: Policy[]): Promise<void>;
193
195
  estimateInvokeFee(calls: JsCall[]): Promise<JsFeeEstimate>;
@@ -196,7 +198,8 @@ export class CartridgeAccount {
196
198
  executeFromOutsideV3(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
197
199
  isRegisteredSessionAuthorized(policies: Policy[], public_key?: JsFelt | null): Promise<AuthorizedSession | undefined>;
198
200
  hasRequestedSession(policies: Policy[]): Promise<boolean>;
199
- revokeSession(): void;
201
+ revokeSession(session: JsRevokableSession): Promise<void>;
202
+ revokeSessions(sessions: JsRevokableSession[]): Promise<void>;
200
203
  signMessage(typed_data: string): Promise<Felts>;
201
204
  getNonce(): Promise<any>;
202
205
  deploySelf(max_fee?: JsFeeEstimate | null): Promise<any>;
@@ -276,7 +276,7 @@ function __wbg_adapter_42(arg0, arg1, arg2) {
276
276
  wasm.__wbindgen_export_5(arg0, arg1, addHeapObject(arg2));
277
277
  }
278
278
 
279
- function __wbg_adapter_226(arg0, arg1, arg2, arg3) {
279
+ function __wbg_adapter_227(arg0, arg1, arg2, arg3) {
280
280
  wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
281
281
  }
282
282
 
@@ -394,9 +394,10 @@ export class CartridgeAccount {
394
394
  * @param {JsFelt} address
395
395
  * @param {string} username
396
396
  * @param {Owner} owner
397
+ * @param {string} cartridge_api_url
397
398
  * @returns {CartridgeAccountWithMeta}
398
399
  */
399
- static new(app_id, class_hash, rpc_url, chain_id, address, username, owner) {
400
+ static new(app_id, class_hash, rpc_url, chain_id, address, username, owner, cartridge_api_url) {
400
401
  try {
401
402
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
402
403
  const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -405,7 +406,9 @@ export class CartridgeAccount {
405
406
  const len1 = WASM_VECTOR_LEN;
406
407
  const ptr2 = passStringToWasm0(username, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
407
408
  const len2 = WASM_VECTOR_LEN;
408
- wasm.cartridgeaccount_new(retptr, ptr0, len0, addHeapObject(class_hash), ptr1, len1, addHeapObject(chain_id), addHeapObject(address), ptr2, len2, addHeapObject(owner));
409
+ const ptr3 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
410
+ const len3 = WASM_VECTOR_LEN;
411
+ wasm.cartridgeaccount_new(retptr, ptr0, len0, addHeapObject(class_hash), ptr1, len1, addHeapObject(chain_id), addHeapObject(address), ptr2, len2, addHeapObject(owner), ptr3, len3);
409
412
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
410
413
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
411
414
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -419,14 +422,17 @@ export class CartridgeAccount {
419
422
  }
420
423
  /**
421
424
  * @param {string} app_id
425
+ * @param {string} cartridge_api_url
422
426
  * @returns {CartridgeAccountWithMeta | undefined}
423
427
  */
424
- static fromStorage(app_id) {
428
+ static fromStorage(app_id, cartridge_api_url) {
425
429
  try {
426
430
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
427
431
  const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
428
432
  const len0 = WASM_VECTOR_LEN;
429
- wasm.cartridgeaccount_fromStorage(retptr, ptr0, len0);
433
+ const ptr1 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
434
+ const len1 = WASM_VECTOR_LEN;
435
+ wasm.cartridgeaccount_fromStorage(retptr, ptr0, len0, ptr1, len1);
430
436
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
431
437
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
432
438
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -480,10 +486,11 @@ export class CartridgeAccount {
480
486
  }
481
487
  /**
482
488
  * @param {bigint} expires_at
489
+ * @param {boolean | null} [is_controller_registered]
483
490
  * @returns {Promise<AuthorizedSession>}
484
491
  */
485
- login(expires_at) {
486
- const ret = wasm.cartridgeaccount_login(this.__wbg_ptr, expires_at);
492
+ login(expires_at, is_controller_registered) {
493
+ const ret = wasm.cartridgeaccount_login(this.__wbg_ptr, expires_at, isLikeNone(is_controller_registered) ? 0xFFFFFF : is_controller_registered ? 1 : 0);
487
494
  return takeObject(ret);
488
495
  }
489
496
  /**
@@ -572,18 +579,23 @@ export class CartridgeAccount {
572
579
  const ret = wasm.cartridgeaccount_hasRequestedSession(this.__wbg_ptr, ptr0, len0);
573
580
  return takeObject(ret);
574
581
  }
575
- revokeSession() {
576
- try {
577
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
578
- wasm.cartridgeaccount_revokeSession(retptr, this.__wbg_ptr);
579
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
580
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
581
- if (r1) {
582
- throw takeObject(r0);
583
- }
584
- } finally {
585
- wasm.__wbindgen_add_to_stack_pointer(16);
586
- }
582
+ /**
583
+ * @param {JsRevokableSession} session
584
+ * @returns {Promise<void>}
585
+ */
586
+ revokeSession(session) {
587
+ const ret = wasm.cartridgeaccount_revokeSession(this.__wbg_ptr, addHeapObject(session));
588
+ return takeObject(ret);
589
+ }
590
+ /**
591
+ * @param {JsRevokableSession[]} sessions
592
+ * @returns {Promise<void>}
593
+ */
594
+ revokeSessions(sessions) {
595
+ const ptr0 = passArrayJsValueToWasm0(sessions, wasm.__wbindgen_export_0);
596
+ const len0 = WASM_VECTOR_LEN;
597
+ const ret = wasm.cartridgeaccount_revokeSessions(this.__wbg_ptr, ptr0, len0);
598
+ return takeObject(ret);
587
599
  }
588
600
  /**
589
601
  * @param {string} typed_data
@@ -998,10 +1010,6 @@ export function __wbg_crypto_574e78ad8b13b65f(arg0) {
998
1010
  return addHeapObject(ret);
999
1011
  };
1000
1012
 
1001
- export function __wbg_debug_3cb59063b29f58c1(arg0) {
1002
- console.debug(getObject(arg0));
1003
- };
1004
-
1005
1013
  export function __wbg_done_769e5ede4b31c67b(arg0) {
1006
1014
  const ret = getObject(arg0).done;
1007
1015
  return ret;
@@ -1175,7 +1183,7 @@ export function __wbg_new_23a2665fac83c611(arg0, arg1) {
1175
1183
  const a = state0.a;
1176
1184
  state0.a = 0;
1177
1185
  try {
1178
- return __wbg_adapter_226(a, state0.b, arg0, arg1);
1186
+ return __wbg_adapter_227(a, state0.b, arg0, arg1);
1179
1187
  } finally {
1180
1188
  state0.a = a;
1181
1189
  }
@@ -1283,6 +1291,10 @@ export function __wbg_randomFillSync_ac0988aba3254290() { return handleError(fun
1283
1291
  getObject(arg0).randomFillSync(takeObject(arg1));
1284
1292
  }, arguments) };
1285
1293
 
1294
+ export function __wbg_removeItem_9d2669ee3bba6f7d() { return handleError(function (arg0, arg1, arg2) {
1295
+ getObject(arg0).removeItem(getStringFromWasm0(arg1, arg2));
1296
+ }, arguments) };
1297
+
1286
1298
  export function __wbg_require_60cc747a6bc5215a() { return handleError(function () {
1287
1299
  const ret = module.require;
1288
1300
  return addHeapObject(ret);
@@ -1449,8 +1461,8 @@ export function __wbindgen_cb_drop(arg0) {
1449
1461
  return ret;
1450
1462
  };
1451
1463
 
1452
- export function __wbindgen_closure_wrapper4027(arg0, arg1, arg2) {
1453
- const ret = makeMutClosure(arg0, arg1, 478, __wbg_adapter_42);
1464
+ export function __wbindgen_closure_wrapper4430(arg0, arg1, arg2) {
1465
+ const ret = makeMutClosure(arg0, arg1, 528, __wbg_adapter_42);
1454
1466
  return addHeapObject(ret);
1455
1467
  };
1456
1468
 
Binary file
@@ -129,6 +129,8 @@ export type Felts = JsFelt[];
129
129
 
130
130
  export type JsFeeSource = "PAYMASTER" | "CREDITS";
131
131
 
132
+ export type JsRevokableSession = RevokableSession;
133
+
132
134
  export interface AuthorizedSession {
133
135
  session: Session;
134
136
  authorization: JsFelt[] | null;
@@ -243,7 +243,7 @@ function __wbg_adapter_42(arg0, arg1, arg2) {
243
243
  wasm.__wbindgen_export_5(arg0, arg1, addHeapObject(arg2));
244
244
  }
245
245
 
246
- function __wbg_adapter_190(arg0, arg1, arg2, arg3) {
246
+ function __wbg_adapter_188(arg0, arg1, arg2, arg3) {
247
247
  wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
248
248
  }
249
249
 
@@ -571,10 +571,6 @@ export function __wbg_crypto_574e78ad8b13b65f(arg0) {
571
571
  return addHeapObject(ret);
572
572
  };
573
573
 
574
- export function __wbg_debug_3cb59063b29f58c1(arg0) {
575
- console.debug(getObject(arg0));
576
- };
577
-
578
574
  export function __wbg_done_769e5ede4b31c67b(arg0) {
579
575
  const ret = getObject(arg0).done;
580
576
  return ret;
@@ -735,7 +731,7 @@ export function __wbg_new_23a2665fac83c611(arg0, arg1) {
735
731
  const a = state0.a;
736
732
  state0.a = 0;
737
733
  try {
738
- return __wbg_adapter_190(a, state0.b, arg0, arg1);
734
+ return __wbg_adapter_188(a, state0.b, arg0, arg1);
739
735
  } finally {
740
736
  state0.a = a;
741
737
  }
@@ -1005,8 +1001,8 @@ export function __wbindgen_cb_drop(arg0) {
1005
1001
  return ret;
1006
1002
  };
1007
1003
 
1008
- export function __wbindgen_closure_wrapper2588(arg0, arg1, arg2) {
1009
- const ret = makeMutClosure(arg0, arg1, 306, __wbg_adapter_42);
1004
+ export function __wbindgen_closure_wrapper2581(arg0, arg1, arg2) {
1005
+ const ret = makeMutClosure(arg0, arg1, 312, __wbg_adapter_42);
1010
1006
  return addHeapObject(ret);
1011
1007
  };
1012
1008
 
Binary file