@cartridge/controller-wasm 0.3.0 → 0.3.2

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.0",
3
+ "version": "0.3.2",
4
4
  "description": "Wasm bindings for Cartridge Controller and Session Account",
5
5
  "type": "module",
6
6
  "main": "./pkg-controller/account_wasm.js",
@@ -81,6 +81,8 @@ export enum ErrorCode {
81
81
  PolicyChainIdMismatch = 136,
82
82
  InvalidOwner = 137,
83
83
  GasPriceTooHigh = 138,
84
+ TransactionTimeout = 139,
85
+ ConversionError = 140,
84
86
  }
85
87
  export interface JsCall {
86
88
  contractAddress: JsFelt;
@@ -216,7 +218,6 @@ export class CartridgeAccount {
216
218
  registerSession(policies: Policy[], expires_at: bigint, public_key: JsFelt, max_fee?: JsFeeEstimate | null): Promise<any>;
217
219
  registerSessionCalldata(policies: Policy[], expires_at: bigint, public_key: JsFelt): Promise<any>;
218
220
  upgrade(new_class_hash: JsFelt): Promise<JsCall>;
219
- login(expires_at: bigint, is_controller_registered?: boolean | null, signers?: Signer | null): Promise<AuthorizedSession>;
220
221
  register(register: JsRegister): Promise<JsRegisterResponse>;
221
222
  createSession(policies: Policy[], expires_at: bigint): Promise<AuthorizedSession | undefined>;
222
223
  skipSession(policies: Policy[]): Promise<void>;
@@ -261,8 +262,8 @@ export class CartridgeAccountMeta {
261
262
  classHash(): string;
262
263
  rpcUrl(): string;
263
264
  chainId(): string;
264
- ownerGuid(): JsFelt;
265
265
  owner(): Owner;
266
+ ownerGuid(): JsFelt;
266
267
  }
267
268
  /**
268
269
  * A type used as the return type for constructing `CartridgeAccount` to provide an extra,
@@ -277,6 +278,16 @@ export class CartridgeAccountWithMeta {
277
278
  meta(): CartridgeAccountMeta;
278
279
  intoAccount(): CartridgeAccount;
279
280
  }
281
+ export class ControllerFactory {
282
+ private constructor();
283
+ free(): void;
284
+ static fromStorage(app_id: string, cartridge_api_url: string): CartridgeAccountWithMeta | undefined;
285
+ static login(app_id: string, username: string, class_hash: JsFelt, rpc_url: string, chain_id: JsFelt, address: JsFelt, owner: Owner, cartridge_api_url: string, session_expires_at_s: bigint, is_controller_registered?: boolean | null): Promise<LoginResult>;
286
+ /**
287
+ * This should only be used with webauthn signers
288
+ */
289
+ static apiLogin(app_id: string, username: string, class_hash: JsFelt, rpc_url: string, chain_id: JsFelt, address: JsFelt, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
290
+ }
280
291
  export class JsControllerError {
281
292
  private constructor();
282
293
  free(): void;
@@ -285,3 +296,8 @@ export class JsControllerError {
285
296
  get data(): string | undefined;
286
297
  set data(value: string | null | undefined);
287
298
  }
299
+ export class LoginResult {
300
+ private constructor();
301
+ free(): void;
302
+ intoValues(): Array<any>;
303
+ }
@@ -315,12 +315,12 @@ function __wbg_adapter_50(arg0, arg1, arg2) {
315
315
  wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2));
316
316
  }
317
317
 
318
- function __wbg_adapter_280(arg0, arg1, arg2, arg3) {
318
+ function __wbg_adapter_287(arg0, arg1, arg2, arg3) {
319
319
  wasm.__wbindgen_export_8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
320
320
  }
321
321
 
322
322
  /**
323
- * @enum {1 | 20 | 24 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 10 | 64 | 65 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138}
323
+ * @enum {1 | 20 | 24 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 10 | 64 | 65 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140}
324
324
  */
325
325
  export const ErrorCode = Object.freeze({
326
326
  StarknetFailedToReceiveTransaction: 1, "1": "StarknetFailedToReceiveTransaction",
@@ -388,6 +388,8 @@ export const ErrorCode = Object.freeze({
388
388
  PolicyChainIdMismatch: 136, "136": "PolicyChainIdMismatch",
389
389
  InvalidOwner: 137, "137": "InvalidOwner",
390
390
  GasPriceTooHigh: 138, "138": "GasPriceTooHigh",
391
+ TransactionTimeout: 139, "139": "TransactionTimeout",
392
+ ConversionError: 140, "140": "ConversionError",
391
393
  });
392
394
 
393
395
  const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
@@ -568,16 +570,6 @@ export class CartridgeAccount {
568
570
  const ret = wasm.cartridgeaccount_upgrade(this.__wbg_ptr, addHeapObject(new_class_hash));
569
571
  return takeObject(ret);
570
572
  }
571
- /**
572
- * @param {bigint} expires_at
573
- * @param {boolean | null} [is_controller_registered]
574
- * @param {Signer | null} [signers]
575
- * @returns {Promise<AuthorizedSession>}
576
- */
577
- login(expires_at, is_controller_registered, signers) {
578
- const ret = wasm.cartridgeaccount_login(this.__wbg_ptr, expires_at, isLikeNone(is_controller_registered) ? 0xFFFFFF : is_controller_registered ? 1 : 0, isLikeNone(signers) ? 0 : addHeapObject(signers));
579
- return takeObject(ret);
580
- }
581
573
  /**
582
574
  * @param {JsRegister} register
583
575
  * @returns {Promise<JsRegisterResponse>}
@@ -937,17 +929,17 @@ export class CartridgeAccountMeta {
937
929
  }
938
930
  }
939
931
  /**
940
- * @returns {JsFelt}
932
+ * @returns {Owner}
941
933
  */
942
- ownerGuid() {
943
- const ret = wasm.cartridgeaccountmeta_ownerGuid(this.__wbg_ptr);
934
+ owner() {
935
+ const ret = wasm.cartridgeaccountmeta_owner(this.__wbg_ptr);
944
936
  return takeObject(ret);
945
937
  }
946
938
  /**
947
- * @returns {Owner}
939
+ * @returns {JsFelt}
948
940
  */
949
- owner() {
950
- const ret = wasm.cartridgeaccountmeta_owner(this.__wbg_ptr);
941
+ ownerGuid() {
942
+ const ret = wasm.cartridgeaccountmeta_ownerGuid(this.__wbg_ptr);
951
943
  return takeObject(ret);
952
944
  }
953
945
  }
@@ -1000,6 +992,98 @@ export class CartridgeAccountWithMeta {
1000
992
  }
1001
993
  }
1002
994
 
995
+ const ControllerFactoryFinalization = (typeof FinalizationRegistry === 'undefined')
996
+ ? { register: () => {}, unregister: () => {} }
997
+ : new FinalizationRegistry(ptr => wasm.__wbg_controllerfactory_free(ptr >>> 0, 1));
998
+
999
+ export class ControllerFactory {
1000
+
1001
+ __destroy_into_raw() {
1002
+ const ptr = this.__wbg_ptr;
1003
+ this.__wbg_ptr = 0;
1004
+ ControllerFactoryFinalization.unregister(this);
1005
+ return ptr;
1006
+ }
1007
+
1008
+ free() {
1009
+ const ptr = this.__destroy_into_raw();
1010
+ wasm.__wbg_controllerfactory_free(ptr, 0);
1011
+ }
1012
+ /**
1013
+ * @param {string} app_id
1014
+ * @param {string} cartridge_api_url
1015
+ * @returns {CartridgeAccountWithMeta | undefined}
1016
+ */
1017
+ static fromStorage(app_id, cartridge_api_url) {
1018
+ try {
1019
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1020
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1021
+ const len0 = WASM_VECTOR_LEN;
1022
+ const ptr1 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1023
+ const len1 = WASM_VECTOR_LEN;
1024
+ wasm.cartridgeaccount_fromStorage(retptr, ptr0, len0, ptr1, len1);
1025
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1026
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1027
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1028
+ if (r2) {
1029
+ throw takeObject(r1);
1030
+ }
1031
+ return r0 === 0 ? undefined : CartridgeAccountWithMeta.__wrap(r0);
1032
+ } finally {
1033
+ wasm.__wbindgen_add_to_stack_pointer(16);
1034
+ }
1035
+ }
1036
+ /**
1037
+ * @param {string} app_id
1038
+ * @param {string} username
1039
+ * @param {JsFelt} class_hash
1040
+ * @param {string} rpc_url
1041
+ * @param {JsFelt} chain_id
1042
+ * @param {JsFelt} address
1043
+ * @param {Owner} owner
1044
+ * @param {string} cartridge_api_url
1045
+ * @param {bigint} session_expires_at_s
1046
+ * @param {boolean | null} [is_controller_registered]
1047
+ * @returns {Promise<LoginResult>}
1048
+ */
1049
+ static login(app_id, username, class_hash, rpc_url, chain_id, address, owner, cartridge_api_url, session_expires_at_s, is_controller_registered) {
1050
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1051
+ const len0 = WASM_VECTOR_LEN;
1052
+ const ptr1 = passStringToWasm0(username, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1053
+ const len1 = WASM_VECTOR_LEN;
1054
+ const ptr2 = passStringToWasm0(rpc_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1055
+ const len2 = WASM_VECTOR_LEN;
1056
+ const ptr3 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1057
+ const len3 = WASM_VECTOR_LEN;
1058
+ const ret = wasm.controllerfactory_login(ptr0, len0, ptr1, len1, addHeapObject(class_hash), ptr2, len2, addHeapObject(chain_id), addHeapObject(address), addHeapObject(owner), ptr3, len3, session_expires_at_s, isLikeNone(is_controller_registered) ? 0xFFFFFF : is_controller_registered ? 1 : 0);
1059
+ return takeObject(ret);
1060
+ }
1061
+ /**
1062
+ * This should only be used with webauthn signers
1063
+ * @param {string} app_id
1064
+ * @param {string} username
1065
+ * @param {JsFelt} class_hash
1066
+ * @param {string} rpc_url
1067
+ * @param {JsFelt} chain_id
1068
+ * @param {JsFelt} address
1069
+ * @param {Owner} owner
1070
+ * @param {string} cartridge_api_url
1071
+ * @returns {Promise<CartridgeAccountWithMeta>}
1072
+ */
1073
+ static apiLogin(app_id, username, class_hash, rpc_url, chain_id, address, owner, cartridge_api_url) {
1074
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1075
+ const len0 = WASM_VECTOR_LEN;
1076
+ const ptr1 = passStringToWasm0(username, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1077
+ const len1 = WASM_VECTOR_LEN;
1078
+ const ptr2 = passStringToWasm0(rpc_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1079
+ const len2 = WASM_VECTOR_LEN;
1080
+ const ptr3 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1081
+ const len3 = WASM_VECTOR_LEN;
1082
+ const ret = wasm.controllerfactory_apiLogin(ptr0, len0, ptr1, len1, addHeapObject(class_hash), ptr2, len2, addHeapObject(chain_id), addHeapObject(address), addHeapObject(owner), ptr3, len3);
1083
+ return takeObject(ret);
1084
+ }
1085
+ }
1086
+
1003
1087
  const JsControllerErrorFinalization = (typeof FinalizationRegistry === 'undefined')
1004
1088
  ? { register: () => {}, unregister: () => {} }
1005
1089
  : new FinalizationRegistry(ptr => wasm.__wbg_jscontrollererror_free(ptr >>> 0, 1));
@@ -1094,6 +1178,41 @@ export class JsControllerError {
1094
1178
  }
1095
1179
  }
1096
1180
 
1181
+ const LoginResultFinalization = (typeof FinalizationRegistry === 'undefined')
1182
+ ? { register: () => {}, unregister: () => {} }
1183
+ : new FinalizationRegistry(ptr => wasm.__wbg_loginresult_free(ptr >>> 0, 1));
1184
+
1185
+ export class LoginResult {
1186
+
1187
+ static __wrap(ptr) {
1188
+ ptr = ptr >>> 0;
1189
+ const obj = Object.create(LoginResult.prototype);
1190
+ obj.__wbg_ptr = ptr;
1191
+ LoginResultFinalization.register(obj, obj.__wbg_ptr, obj);
1192
+ return obj;
1193
+ }
1194
+
1195
+ __destroy_into_raw() {
1196
+ const ptr = this.__wbg_ptr;
1197
+ this.__wbg_ptr = 0;
1198
+ LoginResultFinalization.unregister(this);
1199
+ return ptr;
1200
+ }
1201
+
1202
+ free() {
1203
+ const ptr = this.__destroy_into_raw();
1204
+ wasm.__wbg_loginresult_free(ptr, 0);
1205
+ }
1206
+ /**
1207
+ * @returns {Array<any>}
1208
+ */
1209
+ intoValues() {
1210
+ const ptr = this.__destroy_into_raw();
1211
+ const ret = wasm.loginresult_intoValues(ptr);
1212
+ return takeObject(ret);
1213
+ }
1214
+ }
1215
+
1097
1216
  export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
1098
1217
  const ret = String(getObject(arg1));
1099
1218
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -1138,6 +1257,11 @@ export function __wbg_call_7cccdd69e0791ae2() { return handleError(function (arg
1138
1257
  return addHeapObject(ret);
1139
1258
  }, arguments) };
1140
1259
 
1260
+ export function __wbg_cartridgeaccountwithmeta_new(arg0) {
1261
+ const ret = CartridgeAccountWithMeta.__wrap(arg0);
1262
+ return addHeapObject(ret);
1263
+ };
1264
+
1141
1265
  export function __wbg_clearTimeout_6222fede17abcb1a(arg0) {
1142
1266
  const ret = clearTimeout(takeObject(arg0));
1143
1267
  return addHeapObject(ret);
@@ -1333,6 +1457,11 @@ export function __wbg_log_c222819a41e063d3(arg0) {
1333
1457
  console.log(getObject(arg0));
1334
1458
  };
1335
1459
 
1460
+ export function __wbg_loginresult_new(arg0) {
1461
+ const ret = LoginResult.__wrap(arg0);
1462
+ return addHeapObject(ret);
1463
+ };
1464
+
1336
1465
  export function __wbg_msCrypto_a61aeb35a24c1329(arg0) {
1337
1466
  const ret = getObject(arg0).msCrypto;
1338
1467
  return addHeapObject(ret);
@@ -1360,7 +1489,7 @@ export function __wbg_new_23a2665fac83c611(arg0, arg1) {
1360
1489
  const a = state0.a;
1361
1490
  state0.a = 0;
1362
1491
  try {
1363
- return __wbg_adapter_280(a, state0.b, arg0, arg1);
1492
+ return __wbg_adapter_287(a, state0.b, arg0, arg1);
1364
1493
  } finally {
1365
1494
  state0.a = a;
1366
1495
  }
@@ -1702,18 +1831,18 @@ export function __wbindgen_cb_drop(arg0) {
1702
1831
  return ret;
1703
1832
  };
1704
1833
 
1705
- export function __wbindgen_closure_wrapper2565(arg0, arg1, arg2) {
1834
+ export function __wbindgen_closure_wrapper2599(arg0, arg1, arg2) {
1706
1835
  const ret = makeClosure(arg0, arg1, 33, __wbg_adapter_44);
1707
1836
  return addHeapObject(ret);
1708
1837
  };
1709
1838
 
1710
- export function __wbindgen_closure_wrapper8144(arg0, arg1, arg2) {
1711
- const ret = makeMutClosure(arg0, arg1, 871, __wbg_adapter_47);
1839
+ export function __wbindgen_closure_wrapper8287(arg0, arg1, arg2) {
1840
+ const ret = makeMutClosure(arg0, arg1, 880, __wbg_adapter_47);
1712
1841
  return addHeapObject(ret);
1713
1842
  };
1714
1843
 
1715
- export function __wbindgen_closure_wrapper8293(arg0, arg1, arg2) {
1716
- const ret = makeMutClosure(arg0, arg1, 905, __wbg_adapter_50);
1844
+ export function __wbindgen_closure_wrapper8436(arg0, arg1, arg2) {
1845
+ const ret = makeMutClosure(arg0, arg1, 914, __wbg_adapter_50);
1717
1846
  return addHeapObject(ret);
1718
1847
  };
1719
1848
 
Binary file
@@ -66,6 +66,8 @@ export enum ErrorCode {
66
66
  PolicyChainIdMismatch = 136,
67
67
  InvalidOwner = 137,
68
68
  GasPriceTooHigh = 138,
69
+ TransactionTimeout = 139,
70
+ ConversionError = 140,
69
71
  }
70
72
  export interface JsCall {
71
73
  contractAddress: JsFelt;
@@ -252,7 +252,7 @@ function __wbg_adapter_201(arg0, arg1, arg2, arg3) {
252
252
  }
253
253
 
254
254
  /**
255
- * @enum {1 | 20 | 24 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 10 | 64 | 65 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138}
255
+ * @enum {1 | 20 | 24 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 10 | 64 | 65 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140}
256
256
  */
257
257
  export const ErrorCode = Object.freeze({
258
258
  StarknetFailedToReceiveTransaction: 1, "1": "StarknetFailedToReceiveTransaction",
@@ -320,6 +320,8 @@ export const ErrorCode = Object.freeze({
320
320
  PolicyChainIdMismatch: 136, "136": "PolicyChainIdMismatch",
321
321
  InvalidOwner: 137, "137": "InvalidOwner",
322
322
  GasPriceTooHigh: 138, "138": "GasPriceTooHigh",
323
+ TransactionTimeout: 139, "139": "TransactionTimeout",
324
+ ConversionError: 140, "140": "ConversionError",
323
325
  });
324
326
 
325
327
  const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
@@ -1033,13 +1035,13 @@ export function __wbindgen_cb_drop(arg0) {
1033
1035
  return ret;
1034
1036
  };
1035
1037
 
1036
- export function __wbindgen_closure_wrapper3363(arg0, arg1, arg2) {
1037
- const ret = makeMutClosure(arg0, arg1, 401, __wbg_adapter_42);
1038
+ export function __wbindgen_closure_wrapper3368(arg0, arg1, arg2) {
1039
+ const ret = makeMutClosure(arg0, arg1, 402, __wbg_adapter_42);
1038
1040
  return addHeapObject(ret);
1039
1041
  };
1040
1042
 
1041
- export function __wbindgen_closure_wrapper3499(arg0, arg1, arg2) {
1042
- const ret = makeMutClosure(arg0, arg1, 436, __wbg_adapter_45);
1043
+ export function __wbindgen_closure_wrapper3504(arg0, arg1, arg2) {
1044
+ const ret = makeMutClosure(arg0, arg1, 437, __wbg_adapter_45);
1043
1045
  return addHeapObject(ret);
1044
1046
  };
1045
1047
 
Binary file