@cartridge/controller-wasm 0.3.18 → 0.7.14-0df5a4c

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.18",
3
+ "version": "0.7.14-0df5a4c",
4
4
  "description": "Wasm bindings for Cartridge Controller and Session Account",
5
5
  "type": "module",
6
6
  "main": "./pkg-controller/account_wasm.js",
@@ -1,101 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Computes the Starknet contract address for a controller account without needing a full instance.
5
- *
6
- * # Arguments
7
- *
8
- * * `class_hash` - The class hash of the account contract (JsFelt).
9
- * * `owner` - The owner configuration for the account.
10
- * * `salt` - The salt used for address calculation (JsFelt).
11
- *
12
- * # Returns
13
- *
14
- * The computed Starknet contract address as a `JsFelt`.
15
- */
16
- export function computeAccountAddress(class_hash: JsFelt, owner: Owner, salt: JsFelt): JsFelt;
17
- /**
18
- * Subscribes to the creation of a session for a given controller, session_key_guid and cartridge api url.
19
- * The goal of this function is to know from any place when the register session flow has been completed, and to
20
- * get the authorization.
21
- */
22
- export function subscribeCreateSession(session_key_guid: JsFelt, cartridge_api_url: string): Promise<JsSubscribeSessionResult>;
23
- export function signerToGuid(signer: Signer): JsFelt;
24
- export enum ErrorCode {
25
- StarknetFailedToReceiveTransaction = 1,
26
- StarknetContractNotFound = 20,
27
- StarknetBlockNotFound = 24,
28
- StarknetInvalidTransactionIndex = 27,
29
- StarknetClassHashNotFound = 28,
30
- StarknetTransactionHashNotFound = 29,
31
- StarknetPageSizeTooBig = 31,
32
- StarknetNoBlocks = 32,
33
- StarknetInvalidContinuationToken = 33,
34
- StarknetTooManyKeysInFilter = 34,
35
- StarknetContractError = 40,
36
- StarknetTransactionExecutionError = 41,
37
- StarknetClassAlreadyDeclared = 51,
38
- StarknetInvalidTransactionNonce = 52,
39
- StarknetInsufficientMaxFee = 53,
40
- StarknetInsufficientAccountBalance = 54,
41
- StarknetValidationFailure = 55,
42
- StarknetCompilationFailed = 56,
43
- StarknetContractClassSizeIsTooLarge = 57,
44
- StarknetNonAccount = 58,
45
- StarknetDuplicateTx = 59,
46
- StarknetCompiledClassHashMismatch = 60,
47
- StarknetUnsupportedTxVersion = 61,
48
- StarknetUnsupportedContractClassVersion = 62,
49
- StarknetUnexpectedError = 63,
50
- StarknetNoTraceAvailable = 10,
51
- StarknetReplacementTransactionUnderpriced = 64,
52
- StarknetFeeBelowMinimum = 65,
53
- SignError = 101,
54
- StorageError = 102,
55
- AccountFactoryError = 103,
56
- PaymasterExecutionTimeNotReached = 104,
57
- PaymasterExecutionTimePassed = 105,
58
- PaymasterInvalidCaller = 106,
59
- PaymasterRateLimitExceeded = 107,
60
- PaymasterNotSupported = 108,
61
- PaymasterHttp = 109,
62
- PaymasterExcecution = 110,
63
- PaymasterSerialization = 111,
64
- CartridgeControllerNotDeployed = 112,
65
- InsufficientBalance = 113,
66
- OriginError = 114,
67
- EncodingError = 115,
68
- SerdeWasmBindgenError = 116,
69
- CairoSerdeError = 117,
70
- CairoShortStringToFeltError = 118,
71
- DeviceCreateCredential = 119,
72
- DeviceGetAssertion = 120,
73
- DeviceBadAssertion = 121,
74
- DeviceChannel = 122,
75
- DeviceOrigin = 123,
76
- AccountSigning = 124,
77
- AccountProvider = 125,
78
- AccountClassHashCalculation = 126,
79
- AccountFeeOutOfRange = 128,
80
- ProviderRateLimited = 129,
81
- ProviderArrayLengthMismatch = 130,
82
- ProviderOther = 131,
83
- SessionAlreadyRegistered = 132,
84
- UrlParseError = 133,
85
- Base64DecodeError = 134,
86
- CoseError = 135,
87
- PolicyChainIdMismatch = 136,
88
- InvalidOwner = 137,
89
- GasPriceTooHigh = 138,
90
- TransactionTimeout = 139,
91
- ConversionError = 140,
92
- InvalidChainId = 141,
93
- SessionRefreshRequired = 142,
94
- ManualExecutionRequired = 143,
95
- ForbiddenEntrypoint = 144,
96
- GasAmountTooHigh = 145,
97
- ApproveExecutionRequired = 146,
98
- }
99
3
  export interface JsCall {
100
4
  contractAddress: JsFelt;
101
5
  entrypoint: string;
@@ -224,6 +128,7 @@ export interface Credentials {
224
128
  privateKey: JsFelt;
225
129
  }
226
130
 
131
+
227
132
  export class CartridgeAccount {
228
133
  private constructor();
229
134
  free(): void;
@@ -232,31 +137,29 @@ export class CartridgeAccount {
232
137
  * Creates a new `CartridgeAccount` instance.
233
138
  *
234
139
  * # Parameters
235
- * - `app_id`: Application identifier.
236
140
  * - `rpc_url`: The URL of the JSON-RPC endpoint.
237
141
  * - `address`: The blockchain address associated with the account.
238
142
  * - `username`: Username associated with the account.
239
143
  * - `owner`: A Owner struct containing the owner signer and associated data.
240
144
  */
241
- static new(app_id: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, username: string, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
145
+ static new(class_hash: JsFelt, rpc_url: string, address: JsFelt, username: string, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
242
146
  /**
243
147
  * Creates a new `CartridgeAccount` instance with a randomly generated Starknet signer.
244
148
  * The controller address is computed internally based on the generated signer.
245
149
  *
246
150
  * # Parameters
247
- * - `app_id`: Application identifier.
248
151
  * - `rpc_url`: The URL of the JSON-RPC endpoint.
249
152
  * - `username`: Username associated with the account.
250
153
  */
251
- static newHeadless(app_id: string, class_hash: JsFelt, rpc_url: string, username: string, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
252
- static fromStorage(app_id: string, cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
154
+ static newHeadless(class_hash: JsFelt, rpc_url: string, username: string, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
155
+ static fromStorage(cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
253
156
  disconnect(): Promise<void>;
254
- registerSession(policies: Policy[], expires_at: bigint, public_key: JsFelt, max_fee?: JsFeeEstimate | null): Promise<any>;
157
+ registerSession(app_id: string, policies: Policy[], expires_at: bigint, public_key: JsFelt, max_fee?: JsFeeEstimate | null): Promise<any>;
255
158
  registerSessionCalldata(policies: Policy[], expires_at: bigint, public_key: JsFelt): Promise<any>;
256
159
  upgrade(new_class_hash: JsFelt): Promise<JsCall>;
257
160
  register(register: JsRegister): Promise<JsRegisterResponse>;
258
- createSession(policies: Policy[], expires_at: bigint, authorize_user_execution?: boolean | null): Promise<AuthorizedSession | undefined>;
259
- skipSession(policies: Policy[]): Promise<void>;
161
+ createSession(app_id: string, policies: Policy[], expires_at: bigint, authorize_user_execution?: boolean | null): Promise<AuthorizedSession | undefined>;
162
+ skipSession(app_id: string, policies: Policy[]): Promise<void>;
260
163
  addOwner(owner?: Signer | null, signer_input?: JsAddSignerInput | null, rp_id?: string | null): Promise<void>;
261
164
  removeOwner(signer: JsRemoveSignerInput): Promise<void>;
262
165
  createPasskeySigner(rp_id: string): Promise<JsAddSignerInput>;
@@ -264,17 +167,17 @@ export class CartridgeAccount {
264
167
  execute(calls: JsCall[], max_fee?: JsFeeEstimate | null, fee_source?: JsFeeSource | null): Promise<any>;
265
168
  executeFromOutsideV2(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
266
169
  executeFromOutsideV3(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
267
- trySessionExecute(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
170
+ trySessionExecute(app_id: string, calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
268
171
  isRegisteredSessionAuthorized(policies: Policy[], public_key?: JsFelt | null): Promise<AuthorizedSession | undefined>;
269
- hasRequestedSession(policies: Policy[]): Promise<boolean>;
172
+ hasRequestedSession(app_id: string, policies: Policy[]): Promise<boolean>;
270
173
  revokeSession(session: JsRevokableSession): Promise<void>;
271
174
  revokeSessions(sessions: JsRevokableSession[]): Promise<void>;
272
175
  signMessage(typed_data: string): Promise<Felts>;
273
176
  getNonce(): Promise<any>;
274
177
  deploySelf(max_fee?: JsFeeEstimate | null): Promise<any>;
275
178
  delegateAccount(): Promise<JsFelt>;
276
- hasAuthorizedPoliciesForCalls(calls: JsCall[]): Promise<boolean>;
277
- hasAuthorizedPoliciesForMessage(typed_data: string): Promise<boolean>;
179
+ hasAuthorizedPoliciesForCalls(app_id: string, calls: JsCall[]): Promise<boolean>;
180
+ hasAuthorizedPoliciesForMessage(app_id: string, typed_data: string): Promise<boolean>;
278
181
  /**
279
182
  * Signs an OutsideExecution V3 transaction and returns both the OutsideExecution object and its signature.
280
183
  *
@@ -285,25 +188,22 @@ export class CartridgeAccount {
285
188
  * A `JsSignedOutsideExecution` containing the OutsideExecution V3 object and its signature
286
189
  */
287
190
  signExecuteFromOutside(calls: JsCall[]): Promise<JsSignedOutsideExecution>;
191
+ /**
192
+ * Checks if there are stored policies for a given app_id.
193
+ *
194
+ * # Parameters
195
+ * - `app_id`: The application identifier to check for stored policies
196
+ *
197
+ * # Returns
198
+ * `true` if policies exist for the given app_id, `false` otherwise
199
+ */
200
+ hasPoliciesForAppId(app_id: string): Promise<boolean>;
288
201
  }
289
- /**
290
- * A type for accessing fixed attributes of `CartridgeAccount`.
291
- *
292
- * This type exists as concurrent mutable and immutable calls to `CartridgeAccount` are guarded
293
- * with `WasmMutex`, which only operates under an `async` context. If these getters were directly
294
- * implemented under `CartridgeAccount`:
295
- *
296
- * - calls to them would unnecessarily have to be `async` as well;
297
- * - there would be excessive locking.
298
- *
299
- * This type is supposed to only ever be borrowed immutably. So no concurrent access control would
300
- * be needed.
301
- */
202
+
302
203
  export class CartridgeAccountMeta {
303
204
  private constructor();
304
205
  free(): void;
305
206
  [Symbol.dispose](): void;
306
- appId(): string;
307
207
  username(): string;
308
208
  address(): string;
309
209
  classHash(): string;
@@ -312,13 +212,7 @@ export class CartridgeAccountMeta {
312
212
  owner(): Owner;
313
213
  ownerGuid(): JsFelt;
314
214
  }
315
- /**
316
- * A type used as the return type for constructing `CartridgeAccount` to provide an extra,
317
- * separately borrowable `meta` field for synchronously accessing fixed fields.
318
- *
319
- * This type exists instead of simply having `CartridgeAccount::new()` return a tuple as tuples
320
- * don't implement `IntoWasmAbi` which is needed for crossing JS-WASM boundary.
321
- */
215
+
322
216
  export class CartridgeAccountWithMeta {
323
217
  private constructor();
324
218
  free(): void;
@@ -326,11 +220,12 @@ export class CartridgeAccountWithMeta {
326
220
  meta(): CartridgeAccountMeta;
327
221
  intoAccount(): CartridgeAccount;
328
222
  }
223
+
329
224
  export class ControllerFactory {
330
225
  private constructor();
331
226
  free(): void;
332
227
  [Symbol.dispose](): void;
333
- static fromStorage(app_id: string, cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
228
+ static fromStorage(cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
334
229
  /**
335
230
  * Login to an existing controller account.
336
231
  *
@@ -359,15 +254,89 @@ export class ControllerFactory {
359
254
  * 3. Handles WebAuthn signer updates when multiple signers are present
360
255
  * 4. Registers the session with Cartridge API if requested
361
256
  */
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>;
257
+ 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<LoginResult>;
363
258
  /**
364
259
  * This should only be used with webauthn signers
365
260
  */
366
- static apiLogin(app_id: string, username: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
261
+ static apiLogin(username: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
367
262
  }
368
- /**
369
- * JavaScript-friendly chain configuration
370
- */
263
+
264
+ export enum ErrorCode {
265
+ StarknetFailedToReceiveTransaction = 1,
266
+ StarknetContractNotFound = 20,
267
+ StarknetBlockNotFound = 24,
268
+ StarknetInvalidTransactionIndex = 27,
269
+ StarknetClassHashNotFound = 28,
270
+ StarknetTransactionHashNotFound = 29,
271
+ StarknetPageSizeTooBig = 31,
272
+ StarknetNoBlocks = 32,
273
+ StarknetInvalidContinuationToken = 33,
274
+ StarknetTooManyKeysInFilter = 34,
275
+ StarknetContractError = 40,
276
+ StarknetTransactionExecutionError = 41,
277
+ StarknetClassAlreadyDeclared = 51,
278
+ StarknetInvalidTransactionNonce = 52,
279
+ StarknetInsufficientMaxFee = 53,
280
+ StarknetInsufficientAccountBalance = 54,
281
+ StarknetValidationFailure = 55,
282
+ StarknetCompilationFailed = 56,
283
+ StarknetContractClassSizeIsTooLarge = 57,
284
+ StarknetNonAccount = 58,
285
+ StarknetDuplicateTx = 59,
286
+ StarknetCompiledClassHashMismatch = 60,
287
+ StarknetUnsupportedTxVersion = 61,
288
+ StarknetUnsupportedContractClassVersion = 62,
289
+ StarknetUnexpectedError = 63,
290
+ StarknetNoTraceAvailable = 10,
291
+ StarknetReplacementTransactionUnderpriced = 64,
292
+ StarknetFeeBelowMinimum = 65,
293
+ SignError = 101,
294
+ StorageError = 102,
295
+ AccountFactoryError = 103,
296
+ PaymasterExecutionTimeNotReached = 104,
297
+ PaymasterExecutionTimePassed = 105,
298
+ PaymasterInvalidCaller = 106,
299
+ PaymasterRateLimitExceeded = 107,
300
+ PaymasterNotSupported = 108,
301
+ PaymasterHttp = 109,
302
+ PaymasterExcecution = 110,
303
+ PaymasterSerialization = 111,
304
+ CartridgeControllerNotDeployed = 112,
305
+ InsufficientBalance = 113,
306
+ OriginError = 114,
307
+ EncodingError = 115,
308
+ SerdeWasmBindgenError = 116,
309
+ CairoSerdeError = 117,
310
+ CairoShortStringToFeltError = 118,
311
+ DeviceCreateCredential = 119,
312
+ DeviceGetAssertion = 120,
313
+ DeviceBadAssertion = 121,
314
+ DeviceChannel = 122,
315
+ DeviceOrigin = 123,
316
+ AccountSigning = 124,
317
+ AccountProvider = 125,
318
+ AccountClassHashCalculation = 126,
319
+ AccountFeeOutOfRange = 128,
320
+ ProviderRateLimited = 129,
321
+ ProviderArrayLengthMismatch = 130,
322
+ ProviderOther = 131,
323
+ SessionAlreadyRegistered = 132,
324
+ UrlParseError = 133,
325
+ Base64DecodeError = 134,
326
+ CoseError = 135,
327
+ PolicyChainIdMismatch = 136,
328
+ InvalidOwner = 137,
329
+ GasPriceTooHigh = 138,
330
+ TransactionTimeout = 139,
331
+ ConversionError = 140,
332
+ InvalidChainId = 141,
333
+ SessionRefreshRequired = 142,
334
+ ManualExecutionRequired = 143,
335
+ ForbiddenEntrypoint = 144,
336
+ GasAmountTooHigh = 145,
337
+ ApproveExecutionRequired = 146,
338
+ }
339
+
371
340
  export class JsChainConfig {
372
341
  free(): void;
373
342
  [Symbol.dispose](): void;
@@ -377,6 +346,7 @@ export class JsChainConfig {
377
346
  readonly owner: Owner;
378
347
  readonly address: JsFelt | undefined;
379
348
  }
349
+
380
350
  export class JsControllerError {
381
351
  private constructor();
382
352
  free(): void;
@@ -386,15 +356,14 @@ export class JsControllerError {
386
356
  get data(): string | undefined;
387
357
  set data(value: string | null | undefined);
388
358
  }
359
+
389
360
  export class LoginResult {
390
361
  private constructor();
391
362
  free(): void;
392
363
  [Symbol.dispose](): void;
393
364
  intoValues(): Array<any>;
394
365
  }
395
- /**
396
- * WASM bindings for MultiChainController
397
- */
366
+
398
367
  export class MultiChainAccount {
399
368
  private constructor();
400
369
  free(): void;
@@ -402,11 +371,11 @@ export class MultiChainAccount {
402
371
  /**
403
372
  * Creates a new MultiChainAccount with multiple chain configurations
404
373
  */
405
- static create(app_id: string, username: string, chain_configs: JsChainConfig[], cartridge_api_url: string): Promise<MultiChainAccount>;
374
+ static create(username: string, chain_configs: JsChainConfig[], cartridge_api_url: string): Promise<MultiChainAccount>;
406
375
  /**
407
376
  * Loads a MultiChainAccount from storage
408
377
  */
409
- static fromStorage(app_id: string, cartridge_api_url: string): Promise<MultiChainAccount | undefined>;
378
+ static fromStorage(cartridge_api_url: string): Promise<MultiChainAccount | undefined>;
410
379
  /**
411
380
  * Adds a new chain configuration
412
381
  */
@@ -420,14 +389,35 @@ export class MultiChainAccount {
420
389
  */
421
390
  controller(chain_id: JsFelt): Promise<CartridgeAccount>;
422
391
  }
423
- /**
424
- * Metadata for displaying multi-chain information
425
- */
392
+
426
393
  export class MultiChainAccountMeta {
427
394
  private constructor();
428
395
  free(): void;
429
396
  [Symbol.dispose](): void;
430
- readonly app_id: string;
431
397
  readonly username: string;
432
398
  readonly chains: JsFelt[];
433
399
  }
400
+
401
+ /**
402
+ * Computes the Starknet contract address for a controller account without needing a full instance.
403
+ *
404
+ * # Arguments
405
+ *
406
+ * * `class_hash` - The class hash of the account contract (JsFelt).
407
+ * * `owner` - The owner configuration for the account.
408
+ * * `salt` - The salt used for address calculation (JsFelt).
409
+ *
410
+ * # Returns
411
+ *
412
+ * The computed Starknet contract address as a `JsFelt`.
413
+ */
414
+ export function computeAccountAddress(class_hash: JsFelt, owner: Owner, salt: JsFelt): JsFelt;
415
+
416
+ export function signerToGuid(signer: Signer): JsFelt;
417
+
418
+ /**
419
+ * Subscribes to the creation of a session for a given controller, session_key_guid and cartridge api url.
420
+ * The goal of this function is to know from any place when the register session flow has been completed, and to
421
+ * get the authorization.
422
+ */
423
+ export function subscribeCreateSession(session_key_guid: JsFelt, cartridge_api_url: string): Promise<JsSubscribeSessionResult>;