@cartridge/controller-wasm 0.9.5 → 0.9.6

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.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "Wasm bindings for Cartridge Controller and Session Account",
5
5
  "repository": {
6
6
  "type": "git",
@@ -51,6 +51,41 @@ export interface Eip191Signer {
51
51
  address: string;
52
52
  }
53
53
 
54
+ export interface ImportedControllerMetadata {
55
+ username: string;
56
+ classHash: JsFelt;
57
+ rpcUrl: string;
58
+ salt: JsFelt;
59
+ owner: Owner;
60
+ address: JsFelt;
61
+ chainId: JsFelt;
62
+ }
63
+
64
+ export interface ImportedProvedPolicy {
65
+ policy: Policy;
66
+ proof: JsFelt[];
67
+ }
68
+
69
+ export interface ImportedSession {
70
+ requestedPolicies: Policy[];
71
+ provedPolicies: ImportedProvedPolicy[];
72
+ expiresAt: number;
73
+ allowedPoliciesRoot: JsFelt;
74
+ metadataHash: JsFelt;
75
+ sessionKeyGuid: JsFelt;
76
+ guardianKeyGuid: JsFelt;
77
+ metadata: string;
78
+ }
79
+
80
+ export interface ImportedSessionMetadata {
81
+ session: ImportedSession;
82
+ maxFee?: JsFelt;
83
+ credentials?: Credentials;
84
+ isRegistered: boolean;
85
+ appId?: string;
86
+ policies?: Policy[];
87
+ }
88
+
54
89
  export interface JsCall {
55
90
  contractAddress: JsFelt;
56
91
  entrypoint: string;
@@ -143,6 +178,8 @@ export class CartridgeAccount {
143
178
  execute(calls: JsCall[], max_fee?: JsFeeEstimate | null, fee_source?: JsFeeSource | null): Promise<any>;
144
179
  executeFromOutsideV2(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
145
180
  executeFromOutsideV3(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
181
+ exportAuthorizedSession(app_id?: string | null): Promise<ImportedSessionMetadata | undefined>;
182
+ exportMetadata(): Promise<ImportedControllerMetadata>;
146
183
  static fromStorage(cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
147
184
  getNonce(): Promise<any>;
148
185
  hasAuthorizedPoliciesForCalls(app_id: string, calls: JsCall[]): Promise<boolean>;
@@ -158,6 +195,7 @@ export class CartridgeAccount {
158
195
  */
159
196
  hasPoliciesForAppId(app_id: string): Promise<boolean>;
160
197
  hasRequestedSession(app_id: string, policies: Policy[]): Promise<boolean>;
198
+ importSession(imported_session: ImportedSessionMetadata): Promise<void>;
161
199
  isRegisteredSessionAuthorized(policies: Policy[], public_key?: JsFelt | null): Promise<AuthorizedSession | undefined>;
162
200
  /**
163
201
  * Creates a new `CartridgeAccount` instance.
@@ -249,6 +287,7 @@ export class ControllerFactory {
249
287
  * This should only be used with webauthn signers
250
288
  */
251
289
  static apiLogin(username: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
290
+ static fromMetadata(metadata: ImportedControllerMetadata, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
252
291
  static fromStorage(cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
253
292
  /**
254
293
  * Login to an existing controller account.
@@ -121,6 +121,23 @@ export class CartridgeAccount {
121
121
  const ret = wasm.cartridgeaccount_executeFromOutsideV3(this.__wbg_ptr, ptr0, len0, isLikeNone(fee_source) ? 0 : addHeapObject(fee_source));
122
122
  return takeObject(ret);
123
123
  }
124
+ /**
125
+ * @param {string | null} [app_id]
126
+ * @returns {Promise<ImportedSessionMetadata | undefined>}
127
+ */
128
+ exportAuthorizedSession(app_id) {
129
+ var ptr0 = isLikeNone(app_id) ? 0 : passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
130
+ var len0 = WASM_VECTOR_LEN;
131
+ const ret = wasm.cartridgeaccount_exportAuthorizedSession(this.__wbg_ptr, ptr0, len0);
132
+ return takeObject(ret);
133
+ }
134
+ /**
135
+ * @returns {Promise<ImportedControllerMetadata>}
136
+ */
137
+ exportMetadata() {
138
+ const ret = wasm.cartridgeaccount_exportMetadata(this.__wbg_ptr);
139
+ return takeObject(ret);
140
+ }
124
141
  /**
125
142
  * @param {string} cartridge_api_url
126
143
  * @returns {Promise<CartridgeAccountWithMeta | undefined>}
@@ -194,6 +211,14 @@ export class CartridgeAccount {
194
211
  const ret = wasm.cartridgeaccount_hasRequestedSession(this.__wbg_ptr, ptr0, len0, ptr1, len1);
195
212
  return takeObject(ret);
196
213
  }
214
+ /**
215
+ * @param {ImportedSessionMetadata} imported_session
216
+ * @returns {Promise<void>}
217
+ */
218
+ importSession(imported_session) {
219
+ const ret = wasm.cartridgeaccount_importSession(this.__wbg_ptr, addHeapObject(imported_session));
220
+ return takeObject(ret);
221
+ }
197
222
  /**
198
223
  * @param {Policy[]} policies
199
224
  * @param {JsFelt | null} [public_key]
@@ -598,6 +623,17 @@ export class ControllerFactory {
598
623
  const ret = wasm.controllerfactory_apiLogin(ptr0, len0, addHeapObject(class_hash), ptr1, len1, addHeapObject(address), addHeapObject(owner), ptr2, len2);
599
624
  return takeObject(ret);
600
625
  }
626
+ /**
627
+ * @param {ImportedControllerMetadata} metadata
628
+ * @param {string} cartridge_api_url
629
+ * @returns {Promise<CartridgeAccountWithMeta>}
630
+ */
631
+ static fromMetadata(metadata, cartridge_api_url) {
632
+ const ptr0 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
633
+ const len0 = WASM_VECTOR_LEN;
634
+ const ret = wasm.controllerfactory_fromMetadata(addHeapObject(metadata), ptr0, len0);
635
+ return takeObject(ret);
636
+ }
601
637
  /**
602
638
  * @param {string} cartridge_api_url
603
639
  * @returns {Promise<CartridgeAccountWithMeta | undefined>}
@@ -1472,7 +1508,7 @@ export function __wbg_new_d098e265629cd10f(arg0, arg1) {
1472
1508
  const a = state0.a;
1473
1509
  state0.a = 0;
1474
1510
  try {
1475
- return __wasm_bindgen_func_elem_11044(a, state0.b, arg0, arg1);
1511
+ return __wasm_bindgen_func_elem_11225(a, state0.b, arg0, arg1);
1476
1512
  } finally {
1477
1513
  state0.a = a;
1478
1514
  }
@@ -1494,7 +1530,7 @@ export function __wbg_new_typed_aaaeaf29cf802876(arg0, arg1) {
1494
1530
  const a = state0.a;
1495
1531
  state0.a = 0;
1496
1532
  try {
1497
- return __wasm_bindgen_func_elem_11044(a, state0.b, arg0, arg1);
1533
+ return __wasm_bindgen_func_elem_11225(a, state0.b, arg0, arg1);
1498
1534
  } finally {
1499
1535
  state0.a = a;
1500
1536
  }
@@ -1746,23 +1782,23 @@ export function __wbg_versions_276b2795b1c6a219(arg0) {
1746
1782
  return addHeapObject(ret);
1747
1783
  }
1748
1784
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
1749
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1020, function: Function { arguments: [], shim_idx: 1021, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1750
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_8778, __wasm_bindgen_func_elem_8787);
1785
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1043, function: Function { arguments: [], shim_idx: 1044, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1786
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_8959, __wasm_bindgen_func_elem_8968);
1751
1787
  return addHeapObject(ret);
1752
1788
  }
1753
1789
  export function __wbindgen_cast_0000000000000002(arg0, arg1) {
1754
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1054, function: Function { arguments: [Externref], shim_idx: 1183, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1755
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_8922, __wasm_bindgen_func_elem_11039);
1790
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1077, function: Function { arguments: [Externref], shim_idx: 1206, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1791
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_9103, __wasm_bindgen_func_elem_11220);
1756
1792
  return addHeapObject(ret);
1757
1793
  }
1758
1794
  export function __wbindgen_cast_0000000000000003(arg0, arg1) {
1759
- // Cast intrinsic for `Closure(Closure { dtor_idx: 15, function: Function { arguments: [NamedExternref("Function")], shim_idx: 17, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1760
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_760, __wasm_bindgen_func_elem_3319);
1795
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 15, function: Function { arguments: [NamedExternref("Function")], shim_idx: 16, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1796
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_770, __wasm_bindgen_func_elem_3395);
1761
1797
  return addHeapObject(ret);
1762
1798
  }
1763
1799
  export function __wbindgen_cast_0000000000000004(arg0, arg1) {
1764
- // Cast intrinsic for `Closure(Closure { dtor_idx: 15, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 16, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
1765
- const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_760, __wasm_bindgen_func_elem_3318);
1800
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 15, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 17, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
1801
+ const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_770, __wasm_bindgen_func_elem_3394);
1766
1802
  return addHeapObject(ret);
1767
1803
  }
1768
1804
  export function __wbindgen_cast_0000000000000005(arg0) {
@@ -1792,18 +1828,18 @@ export function __wbindgen_object_clone_ref(arg0) {
1792
1828
  export function __wbindgen_object_drop_ref(arg0) {
1793
1829
  takeObject(arg0);
1794
1830
  }
1795
- function __wasm_bindgen_func_elem_8787(arg0, arg1) {
1796
- wasm.__wasm_bindgen_func_elem_8787(arg0, arg1);
1831
+ function __wasm_bindgen_func_elem_8968(arg0, arg1) {
1832
+ wasm.__wasm_bindgen_func_elem_8968(arg0, arg1);
1797
1833
  }
1798
1834
 
1799
- function __wasm_bindgen_func_elem_3318(arg0, arg1, arg2) {
1800
- wasm.__wasm_bindgen_func_elem_3318(arg0, arg1, addHeapObject(arg2));
1835
+ function __wasm_bindgen_func_elem_3394(arg0, arg1, arg2) {
1836
+ wasm.__wasm_bindgen_func_elem_3394(arg0, arg1, addHeapObject(arg2));
1801
1837
  }
1802
1838
 
1803
- function __wasm_bindgen_func_elem_11039(arg0, arg1, arg2) {
1839
+ function __wasm_bindgen_func_elem_11220(arg0, arg1, arg2) {
1804
1840
  try {
1805
1841
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1806
- wasm.__wasm_bindgen_func_elem_11039(retptr, arg0, arg1, addHeapObject(arg2));
1842
+ wasm.__wasm_bindgen_func_elem_11220(retptr, arg0, arg1, addHeapObject(arg2));
1807
1843
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1808
1844
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1809
1845
  if (r1) {
@@ -1814,10 +1850,10 @@ function __wasm_bindgen_func_elem_11039(arg0, arg1, arg2) {
1814
1850
  }
1815
1851
  }
1816
1852
 
1817
- function __wasm_bindgen_func_elem_3319(arg0, arg1, arg2) {
1853
+ function __wasm_bindgen_func_elem_3395(arg0, arg1, arg2) {
1818
1854
  try {
1819
1855
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1820
- wasm.__wasm_bindgen_func_elem_3319(retptr, arg0, arg1, addHeapObject(arg2));
1856
+ wasm.__wasm_bindgen_func_elem_3395(retptr, arg0, arg1, addHeapObject(arg2));
1821
1857
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1822
1858
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1823
1859
  if (r1) {
@@ -1828,8 +1864,8 @@ function __wasm_bindgen_func_elem_3319(arg0, arg1, arg2) {
1828
1864
  }
1829
1865
  }
1830
1866
 
1831
- function __wasm_bindgen_func_elem_11044(arg0, arg1, arg2, arg3) {
1832
- wasm.__wasm_bindgen_func_elem_11044(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1867
+ function __wasm_bindgen_func_elem_11225(arg0, arg1, arg2, arg3) {
1868
+ wasm.__wasm_bindgen_func_elem_11225(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1833
1869
  }
1834
1870
 
1835
1871
 
Binary file
@@ -51,6 +51,41 @@ export interface Eip191Signer {
51
51
  address: string;
52
52
  }
53
53
 
54
+ export interface ImportedControllerMetadata {
55
+ username: string;
56
+ classHash: JsFelt;
57
+ rpcUrl: string;
58
+ salt: JsFelt;
59
+ owner: Owner;
60
+ address: JsFelt;
61
+ chainId: JsFelt;
62
+ }
63
+
64
+ export interface ImportedProvedPolicy {
65
+ policy: Policy;
66
+ proof: JsFelt[];
67
+ }
68
+
69
+ export interface ImportedSession {
70
+ requestedPolicies: Policy[];
71
+ provedPolicies: ImportedProvedPolicy[];
72
+ expiresAt: number;
73
+ allowedPoliciesRoot: JsFelt;
74
+ metadataHash: JsFelt;
75
+ sessionKeyGuid: JsFelt;
76
+ guardianKeyGuid: JsFelt;
77
+ metadata: string;
78
+ }
79
+
80
+ export interface ImportedSessionMetadata {
81
+ session: ImportedSession;
82
+ maxFee?: JsFelt;
83
+ credentials?: Credentials;
84
+ isRegistered: boolean;
85
+ appId?: string;
86
+ policies?: Policy[];
87
+ }
88
+
54
89
  export interface JsCall {
55
90
  contractAddress: JsFelt;
56
91
  entrypoint: string;
@@ -575,7 +575,7 @@ export function __wbg_new_typed_aaaeaf29cf802876(arg0, arg1) {
575
575
  const a = state0.a;
576
576
  state0.a = 0;
577
577
  try {
578
- return __wasm_bindgen_func_elem_5900(a, state0.b, arg0, arg1);
578
+ return __wasm_bindgen_func_elem_5906(a, state0.b, arg0, arg1);
579
579
  } finally {
580
580
  state0.a = a;
581
581
  }
@@ -785,17 +785,17 @@ export function __wbg_versions_276b2795b1c6a219(arg0) {
785
785
  }
786
786
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
787
787
  // Cast intrinsic for `Closure(Closure { dtor_idx: 4, function: Function { arguments: [NamedExternref("Function")], shim_idx: 5, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
788
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_285, __wasm_bindgen_func_elem_1102);
788
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_285, __wasm_bindgen_func_elem_1104);
789
789
  return addHeapObject(ret);
790
790
  }
791
791
  export function __wbindgen_cast_0000000000000002(arg0, arg1) {
792
792
  // Cast intrinsic for `Closure(Closure { dtor_idx: 482, function: Function { arguments: [], shim_idx: 483, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
793
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3953, __wasm_bindgen_func_elem_3962);
793
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3959, __wasm_bindgen_func_elem_3968);
794
794
  return addHeapObject(ret);
795
795
  }
796
796
  export function __wbindgen_cast_0000000000000003(arg0, arg1) {
797
797
  // Cast intrinsic for `Closure(Closure { dtor_idx: 516, function: Function { arguments: [Externref], shim_idx: 639, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
798
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_4092, __wasm_bindgen_func_elem_5895);
798
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_4098, __wasm_bindgen_func_elem_5901);
799
799
  return addHeapObject(ret);
800
800
  }
801
801
  export function __wbindgen_cast_0000000000000004(arg0) {
@@ -820,14 +820,14 @@ export function __wbindgen_object_clone_ref(arg0) {
820
820
  export function __wbindgen_object_drop_ref(arg0) {
821
821
  takeObject(arg0);
822
822
  }
823
- function __wasm_bindgen_func_elem_3962(arg0, arg1) {
824
- wasm.__wasm_bindgen_func_elem_3962(arg0, arg1);
823
+ function __wasm_bindgen_func_elem_3968(arg0, arg1) {
824
+ wasm.__wasm_bindgen_func_elem_3968(arg0, arg1);
825
825
  }
826
826
 
827
- function __wasm_bindgen_func_elem_1102(arg0, arg1, arg2) {
827
+ function __wasm_bindgen_func_elem_1104(arg0, arg1, arg2) {
828
828
  try {
829
829
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
830
- wasm.__wasm_bindgen_func_elem_1102(retptr, arg0, arg1, addHeapObject(arg2));
830
+ wasm.__wasm_bindgen_func_elem_1104(retptr, arg0, arg1, addHeapObject(arg2));
831
831
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
832
832
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
833
833
  if (r1) {
@@ -838,10 +838,10 @@ function __wasm_bindgen_func_elem_1102(arg0, arg1, arg2) {
838
838
  }
839
839
  }
840
840
 
841
- function __wasm_bindgen_func_elem_5895(arg0, arg1, arg2) {
841
+ function __wasm_bindgen_func_elem_5901(arg0, arg1, arg2) {
842
842
  try {
843
843
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
844
- wasm.__wasm_bindgen_func_elem_5895(retptr, arg0, arg1, addHeapObject(arg2));
844
+ wasm.__wasm_bindgen_func_elem_5901(retptr, arg0, arg1, addHeapObject(arg2));
845
845
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
846
846
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
847
847
  if (r1) {
@@ -852,8 +852,8 @@ function __wasm_bindgen_func_elem_5895(arg0, arg1, arg2) {
852
852
  }
853
853
  }
854
854
 
855
- function __wasm_bindgen_func_elem_5900(arg0, arg1, arg2, arg3) {
856
- wasm.__wasm_bindgen_func_elem_5900(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
855
+ function __wasm_bindgen_func_elem_5906(arg0, arg1, arg2, arg3) {
856
+ wasm.__wasm_bindgen_func_elem_5906(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
857
857
  }
858
858
 
859
859
 
Binary file