@worldcoin/minikit-js 1.9.11 → 2.0.0-dev.0

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/build/index.d.cts CHANGED
@@ -1,597 +1,116 @@
1
- import { TypedData, TypedDataDomain, Abi, AbiStateMutability, ExtractAbiFunctionNames, AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype';
2
- import { IDKitConfig, VerificationLevel } from '@worldcoin/idkit-core';
3
- export { ISuccessResult, AppErrorCodes as VerificationErrorCodes, VerificationLevel } from '@worldcoin/idkit-core';
4
- export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
5
- import { Client } from 'viem';
6
-
7
- type User = {
8
- walletAddress?: string;
9
- username?: string;
10
- profilePictureUrl?: string;
11
- permissions?: {
12
- notifications: boolean;
13
- contacts: boolean;
14
- };
15
- optedIntoOptionalAnalytics?: boolean;
16
- /** @deprecated Moved to DeviceProperties */
17
- worldAppVersion?: number;
18
- /** @deprecated Moved to DeviceProperties */
19
- deviceOS?: string;
20
- };
21
- type DeviceProperties = {
22
- safeAreaInsets?: {
23
- top: number;
24
- right: number;
25
- bottom: number;
26
- left: number;
27
- };
28
- deviceOS?: string;
29
- worldAppVersion?: number;
30
- };
31
- type UserNameService = {
32
- walletAddress: string;
33
- username?: string;
34
- profilePictureUrl?: string;
35
- };
36
- type MiniAppLocation = {
37
- countryCode?: string;
38
- regionCode?: string;
39
- };
40
- declare enum MiniAppLaunchLocation {
41
- Chat = "chat",
42
- Home = "home",
43
- AppStore = "app-store",
44
- DeepLink = "deep-link",
45
- WalletTab = "wallet-tab"
46
- }
47
- declare const mapWorldAppLaunchLocation: (location: string | null | undefined) => MiniAppLaunchLocation | null;
48
-
49
- type EventPayload<T extends ResponseEvent = ResponseEvent> = any;
50
- type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
51
- declare class EventManager {
52
- private listeners;
53
- private verifyActionProcessingOptionsQueue;
54
- subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
55
- unsubscribe(event: ResponseEvent): void;
56
- setVerifyActionProcessingOptions(options?: {
57
- skip_proof_compression?: boolean;
58
- }): void;
59
- trigger(event: ResponseEvent, payload: EventPayload): void;
60
- private processVerifyActionPayload;
61
- private compressProofSafely;
62
- }
63
-
64
- declare class MiniKitState {
65
- appId: string | null;
66
- user: User;
67
- deviceProperties: DeviceProperties;
68
- location: MiniAppLaunchLocation | null;
69
- isReady: boolean;
70
- initFromWorldApp(worldApp: typeof window.WorldApp): void;
71
- updateUserFromWalletAuth(address: string): Promise<void>;
72
- getUserByAddress(address?: string): Promise<UserNameService>;
73
- getUserByUsername(username: string): Promise<UserNameService>;
74
- }
75
-
76
- declare enum MiniKitInstallErrorCodes {
77
- Unknown = "unknown",
78
- AlreadyInstalled = "already_installed",
79
- OutsideOfWorldApp = "outside_of_worldapp",
80
- NotOnClient = "not_on_client",
81
- AppOutOfDate = "app_out_of_date"
82
- }
83
- declare const MiniKitInstallErrorMessage: {
84
- unknown: string;
85
- already_installed: string;
86
- outside_of_worldapp: string;
87
- not_on_client: string;
88
- app_out_of_date: string;
89
- };
90
-
91
- declare enum Command {
92
- Verify = "verify",
93
- Pay = "pay",
94
- WalletAuth = "wallet-auth",
95
- SendTransaction = "send-transaction",
96
- SignMessage = "sign-message",
97
- SignTypedData = "sign-typed-data",
98
- ShareContacts = "share-contacts",
99
- RequestPermission = "request-permission",
100
- GetPermissions = "get-permissions",
101
- SendHapticFeedback = "send-haptic-feedback",
102
- Share = "share",
103
- Chat = "chat"
104
- }
105
- declare enum ResponseEvent {
106
- MiniAppVerifyAction = "miniapp-verify-action",
107
- MiniAppPayment = "miniapp-payment",
108
- MiniAppWalletAuth = "miniapp-wallet-auth",
109
- MiniAppSendTransaction = "miniapp-send-transaction",
110
- MiniAppSignMessage = "miniapp-sign-message",
111
- MiniAppSignTypedData = "miniapp-sign-typed-data",
112
- MiniAppShareContacts = "miniapp-share-contacts",
113
- MiniAppRequestPermission = "miniapp-request-permission",
114
- MiniAppGetPermissions = "miniapp-get-permissions",
115
- MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
116
- MiniAppShare = "miniapp-share",
117
- MiniAppMicrophone = "miniapp-microphone",
118
- MiniAppChat = "miniapp-chat"
119
- }
120
- declare const COMMAND_VERSIONS: Record<Command, number>;
121
- declare function isCommandAvailable(command: Command): boolean;
122
- declare function setCommandAvailable(command: Command, available: boolean): void;
123
- declare function validateCommands(worldAppSupportedCommands: NonNullable<typeof window.WorldApp>['supported_commands']): boolean;
124
- interface CommandContext {
125
- events: EventManager;
126
- state: MiniKitState;
127
- }
128
- type MiniAppBaseSuccessPayload = {
129
- status: 'success';
130
- version: number;
131
- };
132
- type MiniAppBaseErrorPayload<TErrorCode = string> = {
133
- status: 'error';
134
- error_code: TErrorCode;
135
- version: number;
136
- };
137
- type AsyncHandlerReturn<CommandPayload, FinalPayload> = Promise<{
138
- commandPayload: CommandPayload;
139
- finalPayload: FinalPayload;
140
- }>;
141
- type WebViewBasePayload = {
142
- command: Command;
143
- version: number;
144
- payload: Record<string, any>;
145
- };
146
-
147
- type MiniKitInstallReturnType = {
148
- success: true;
149
- } | {
150
- success: false;
151
- errorCode: MiniKitInstallErrorCodes;
152
- errorMessage: (typeof MiniKitInstallErrorMessage)[MiniKitInstallErrorCodes];
153
- };
154
- declare function sendMiniKitEvent<T extends WebViewBasePayload = WebViewBasePayload>(payload: T): void;
155
-
156
- type ChatPayload = {
157
- to?: string[];
158
- message: string;
159
- };
160
- declare enum ChatErrorCodes {
161
- UserRejected = "user_rejected",
162
- SendFailed = "send_failed",
163
- GenericError = "generic_error"
164
- }
165
- declare const ChatErrorMessage: {
166
- user_rejected: string;
167
- send_failed: string;
168
- generic_error: string;
169
- };
170
- type MiniAppChatSuccessPayload = MiniAppBaseSuccessPayload & {
171
- count: number;
172
- timestamp: string;
173
- };
174
- type MiniAppChatErrorPayload = MiniAppBaseErrorPayload<ChatErrorCodes>;
175
- type MiniAppChatPayload = MiniAppChatSuccessPayload | MiniAppChatErrorPayload;
176
- declare function createChatCommand(_ctx: CommandContext): (payload: ChatPayload) => ChatPayload | null;
177
- declare function createChatAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createChatCommand>): (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
178
-
179
- type ShareInput = {
180
- files?: File[];
181
- title?: string;
182
- text?: string;
183
- url?: string;
184
- };
185
- type SharePayload = {
186
- files?: Array<{
187
- name: string;
188
- type: string;
189
- data: string;
190
- }>;
191
- title?: string;
192
- text?: string;
193
- url?: string;
194
- };
195
- declare enum ShareFilesErrorCodes {
196
- UserRejected = "user_rejected",
197
- GenericError = "generic_error",
198
- InvalidFileName = "invalid_file_name"
199
- }
200
- declare const ShareFilesErrorMessage: {
201
- user_rejected: string;
202
- generic_error: string;
203
- invalid_file_name: string;
204
- };
205
- type MiniAppShareSuccessPayload = MiniAppBaseSuccessPayload & {
206
- shared_files_count: number;
207
- timestamp: string;
208
- };
209
- type MiniAppShareErrorPayload = MiniAppBaseErrorPayload<ShareFilesErrorCodes>;
210
- type MiniAppSharePayload = MiniAppShareSuccessPayload | MiniAppShareErrorPayload;
211
- declare function createShareCommand(ctx: CommandContext): (payload: ShareInput) => ShareInput | null;
212
- declare function createShareAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createShareCommand>): (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
213
-
214
- type SendHapticFeedbackInput = {
215
- hapticsType: 'notification';
216
- style: 'error' | 'success' | 'warning';
217
- } | {
218
- hapticsType: 'selection-changed';
219
- style?: never;
220
- } | {
221
- hapticsType: 'impact';
222
- style: 'light' | 'medium' | 'heavy';
223
- };
224
- type SendHapticFeedbackPayload = SendHapticFeedbackInput;
225
- declare enum SendHapticFeedbackErrorCodes {
226
- GenericError = "generic_error",
227
- UserRejected = "user_rejected"
228
- }
229
- declare const SendHapticFeedbackErrorMessage: {
230
- generic_error: string;
231
- user_rejected: string;
232
- };
233
- type MiniAppSendHapticFeedbackSuccessPayload = MiniAppBaseSuccessPayload & {
234
- timestamp: string;
235
- };
236
- type MiniAppSendHapticFeedbackErrorPayload = MiniAppBaseErrorPayload<SendHapticFeedbackErrorCodes>;
237
- type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
238
- declare function createSendHapticFeedbackCommand(_ctx: CommandContext): (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
239
- declare function createSendHapticFeedbackAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createSendHapticFeedbackCommand>): (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
240
-
241
- type GetPermissionsInput = {};
242
- type GetPermissionsPayload = {
243
- status?: string;
244
- };
245
- declare enum GetPermissionsErrorCodes {
246
- GenericError = "generic_error"
247
- }
248
- declare const GetPermissionsErrorMessage: {
249
- generic_error: string;
250
- };
251
- declare enum Permission {
252
- Notifications = "notifications",
253
- Contacts = "contacts",
254
- Microphone = "microphone"
255
- }
256
- type PermissionSettings = {
257
- [K in Permission]?: any;
258
- };
259
- type MiniAppGetPermissionsSuccessPayload = MiniAppBaseSuccessPayload & {
260
- permissions: PermissionSettings;
261
- timestamp: string;
262
- };
263
- type MiniAppGetPermissionsErrorPayload = MiniAppBaseErrorPayload<GetPermissionsErrorCodes> & {
264
- details: string;
265
- };
266
- type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
267
- declare function createGetPermissionsCommand(_ctx: CommandContext): () => GetPermissionsPayload | null;
268
- declare function createGetPermissionsAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createGetPermissionsCommand>): () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
269
-
270
- type RequestPermissionInput = {
271
- permission: Permission;
272
- };
273
- type RequestPermissionPayload = RequestPermissionInput;
274
- declare enum RequestPermissionErrorCodes {
275
- UserRejected = "user_rejected",
276
- GenericError = "generic_error",
277
- AlreadyRequested = "already_requested",
278
- PermissionDisabled = "permission_disabled",
279
- AlreadyGranted = "already_granted",
280
- UnsupportedPermission = "unsupported_permission"
281
- }
282
- declare const RequestPermissionErrorMessage: {
283
- user_rejected: string;
284
- generic_error: string;
285
- already_requested: string;
286
- permission_disabled: string;
287
- already_granted: string;
288
- unsupported_permission: string;
289
- };
290
- type MiniAppRequestPermissionSuccessPayload = MiniAppBaseSuccessPayload & {
291
- permission: Permission;
292
- timestamp: string;
293
- };
294
- type MiniAppRequestPermissionErrorPayload = MiniAppBaseErrorPayload<RequestPermissionErrorCodes> & {
295
- description: string;
296
- };
297
- type MiniAppRequestPermissionPayload = MiniAppRequestPermissionSuccessPayload | MiniAppRequestPermissionErrorPayload;
298
- declare function createRequestPermissionCommand(_ctx: CommandContext): (payload: RequestPermissionInput) => RequestPermissionPayload | null;
299
- declare function createRequestPermissionAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createRequestPermissionCommand>): (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
300
-
301
- type ShareContactsInput = {
302
- isMultiSelectEnabled: boolean;
303
- inviteMessage?: string;
304
- };
305
- type ShareContactsPayload = ShareContactsInput;
306
- declare enum ShareContactsErrorCodes {
307
- UserRejected = "user_rejected",
308
- GenericError = "generic_error"
309
- }
310
- declare const ShareContactsErrorMessage: {
311
- user_rejected: string;
312
- generic_error: string;
313
- };
314
- type Contact = {
315
- username: string;
316
- walletAddress: string;
317
- profilePictureUrl: string | null;
318
- };
319
- type MiniAppShareContactsSuccessPayload = MiniAppBaseSuccessPayload & {
320
- contacts: Contact[];
321
- timestamp: string;
322
- };
323
- type MiniAppShareContactsErrorPayload = MiniAppBaseErrorPayload<ShareContactsErrorCodes>;
324
- type MiniAppShareContactsPayload = MiniAppShareContactsSuccessPayload | MiniAppShareContactsErrorPayload;
325
- declare function createShareContactsCommand(_ctx: CommandContext): (payload: ShareContactsPayload) => ShareContactsPayload | null;
326
- declare function createShareContactsAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createShareContactsCommand>): (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
327
-
328
- type SignTypedDataInput = {
329
- types: TypedData;
330
- primaryType: string;
331
- message: Record<string, unknown>;
332
- domain?: TypedDataDomain;
333
- chainId?: number;
334
- };
335
- type SignTypedDataPayload = SignTypedDataInput;
336
- declare enum SignTypedDataErrorCodes {
337
- InvalidOperation = "invalid_operation",
338
- UserRejected = "user_rejected",
339
- InputError = "input_error",
340
- SimulationFailed = "simulation_failed",
341
- GenericError = "generic_error",
342
- DisallowedOperation = "disallowed_operation",
343
- InvalidContract = "invalid_contract",
344
- MaliciousOperation = "malicious_operation"
345
- }
346
- declare const SignTypedDataErrorMessage: {
347
- invalid_operation: string;
348
- user_rejected: string;
349
- input_error: string;
350
- simulation_failed: string;
351
- generic_error: string;
352
- disallowed_operation: string;
353
- invalid_contract: string;
354
- malicious_operation: string;
355
- };
356
- type MiniAppSignTypedDataSuccessPayload = MiniAppBaseSuccessPayload & {
357
- signature: string;
358
- address: string;
359
- };
360
- type MiniAppSignTypedDataErrorPayload = MiniAppBaseErrorPayload<SignTypedDataErrorCodes> & {
361
- details?: Record<string, any>;
362
- };
363
- type MiniAppSignTypedDataPayload = MiniAppSignTypedDataSuccessPayload | MiniAppSignTypedDataErrorPayload;
364
- declare function createSignTypedDataCommand(_ctx: CommandContext): (payload: SignTypedDataInput) => SignTypedDataPayload | null;
365
- declare function createSignTypedDataAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createSignTypedDataCommand>): (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
366
-
367
- type SignMessageInput = {
368
- message: string;
369
- };
370
- type SignMessagePayload = SignMessageInput;
371
- declare enum SignMessageErrorCodes {
372
- InvalidMessage = "invalid_message",
373
- UserRejected = "user_rejected",
374
- GenericError = "generic_error"
375
- }
376
- declare const SignMessageErrorMessage: {
377
- invalid_message: string;
378
- user_rejected: string;
379
- generic_error: string;
380
- };
381
- type MiniAppSignMessageSuccessPayload = MiniAppBaseSuccessPayload & {
382
- signature: string;
383
- address: string;
384
- };
385
- type MiniAppSignMessageErrorPayload = MiniAppBaseErrorPayload<SignMessageErrorCodes> & {
386
- details?: Record<string, any>;
387
- };
388
- type MiniAppSignMessagePayload = MiniAppSignMessageSuccessPayload | MiniAppSignMessageErrorPayload;
389
- declare function createSignMessageCommand(_ctx: CommandContext): (payload: SignMessageInput) => SignMessagePayload | null;
390
- declare function createSignMessageAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createSignMessageCommand>): (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
391
-
392
- declare enum Tokens {
393
- USDC = "USDCE",
394
- WLD = "WLD"
395
- }
396
- declare const TokenDecimals: {
397
- [key in Tokens]: number;
398
- };
399
- declare enum Network {
400
- Optimism = "optimism",
401
- WorldChain = "worldchain"
402
- }
403
-
404
- type Permit2 = {
405
- permitted: {
406
- token: string;
407
- amount: string | unknown;
408
- };
409
- spender: string;
410
- nonce: string | unknown;
411
- deadline: string | unknown;
412
- };
413
- type Transaction = {
414
- address: string;
415
- abi: Abi | readonly unknown[];
416
- functionName: ContractFunctionName<Abi | readonly unknown[], 'payable' | 'nonpayable'>;
417
- value?: string | undefined;
418
- args: ContractFunctionArgs<Abi | readonly unknown[], 'payable' | 'nonpayable', ContractFunctionName<Abi | readonly unknown[], 'payable' | 'nonpayable'>>;
419
- };
420
- type ContractFunctionName<abi extends Abi | readonly unknown[] = Abi, mutability extends AbiStateMutability = AbiStateMutability> = ExtractAbiFunctionNames<abi extends Abi ? abi : Abi, mutability> extends infer functionName extends string ? [functionName] extends [never] ? string : functionName : string;
421
- type ContractFunctionArgs<abi extends Abi | readonly unknown[] = Abi, mutability extends AbiStateMutability = AbiStateMutability, functionName extends ContractFunctionName<abi, mutability> = ContractFunctionName<abi, mutability>> = AbiParametersToPrimitiveTypes<ExtractAbiFunction<abi extends Abi ? abi : Abi, functionName, mutability>['inputs'], 'inputs'> extends infer args ? [args] extends [never] ? readonly unknown[] : args : readonly unknown[];
422
-
423
- type SendTransactionInput = {
424
- transaction: Transaction[];
425
- permit2?: Permit2[];
426
- formatPayload?: boolean;
427
- };
428
- type SendTransactionPayload = SendTransactionInput;
429
- declare enum SendTransactionErrorCodes {
430
- InvalidOperation = "invalid_operation",
431
- UserRejected = "user_rejected",
432
- InputError = "input_error",
433
- SimulationFailed = "simulation_failed",
434
- TransactionFailed = "transaction_failed",
435
- GenericError = "generic_error",
436
- DisallowedOperation = "disallowed_operation",
437
- ValidationError = "validation_error",
438
- InvalidContract = "invalid_contract",
439
- MaliciousOperation = "malicious_operation",
440
- DailyTxLimitReached = "daily_tx_limit_reached",
441
- PermittedAmountExceedsSlippage = "permitted_amount_exceeds_slippage",
442
- PermittedAmountNotFound = "permitted_amount_not_found"
443
- }
444
- declare const SendTransactionErrorMessage: Record<SendTransactionErrorCodes, string>;
445
- type MiniAppSendTransactionSuccessPayload = MiniAppBaseSuccessPayload & {
446
- transaction_status: 'submitted';
447
- transaction_id: string;
448
- reference: string;
449
- from: string;
450
- chain: Network;
451
- timestamp: string;
452
- mini_app_id?: string;
453
- };
454
- type MiniAppSendTransactionErrorPayload = MiniAppBaseErrorPayload<SendTransactionErrorCodes> & {
455
- details?: Record<string, any>;
456
- mini_app_id?: string;
457
- };
458
- type MiniAppSendTransactionPayload = MiniAppSendTransactionSuccessPayload | MiniAppSendTransactionErrorPayload;
459
- declare function createSendTransactionCommand(_ctx: CommandContext): (payload: SendTransactionInput) => SendTransactionPayload | null;
460
- declare function createSendTransactionAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createSendTransactionCommand>): (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
461
-
462
- type WalletAuthInput = {
463
- nonce: string;
464
- statement?: string;
465
- requestId?: string;
466
- expirationTime?: Date;
467
- notBefore?: Date;
468
- };
469
- type WalletAuthPayload = {
470
- siweMessage: string;
471
- };
472
- declare enum WalletAuthErrorCodes {
473
- MalformedRequest = "malformed_request",
474
- UserRejected = "user_rejected",
475
- GenericError = "generic_error"
476
- }
477
- declare const WalletAuthErrorMessage: {
478
- malformed_request: string;
479
- user_rejected: string;
480
- generic_error: string;
481
- };
482
- type MiniAppWalletAuthSuccessPayload$1 = MiniAppBaseSuccessPayload & {
483
- message: string;
484
- signature: string;
485
- address: string;
486
- };
487
- type MiniAppWalletAuthErrorPayload = MiniAppBaseErrorPayload<WalletAuthErrorCodes> & {
488
- details: (typeof WalletAuthErrorMessage)[WalletAuthErrorCodes];
489
- };
490
- type MiniAppWalletAuthPayload = MiniAppWalletAuthSuccessPayload$1 | MiniAppWalletAuthErrorPayload;
491
- declare function createWalletAuthCommand(ctx: CommandContext): (payload: WalletAuthInput) => WalletAuthPayload | null;
492
- declare function createWalletAuthAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createWalletAuthCommand>): (payload: WalletAuthInput) => AsyncHandlerReturn<WalletAuthPayload | null, MiniAppWalletAuthPayload>;
493
-
494
- type TokensPayload = {
495
- symbol: Tokens;
496
- token_amount: string;
497
- };
498
- type PayCommandInput = {
499
- reference: string;
500
- to: `0x${string}` | string;
501
- tokens: TokensPayload[];
502
- network?: Network;
503
- description: string;
504
- };
505
- type PayCommandPayload = PayCommandInput;
506
- declare enum PaymentErrorCodes {
507
- InputError = "input_error",
508
- UserRejected = "user_rejected",
509
- PaymentRejected = "payment_rejected",
510
- InvalidReceiver = "invalid_receiver",
511
- InsufficientBalance = "insufficient_balance",
512
- TransactionFailed = "transaction_failed",
513
- GenericError = "generic_error",
514
- UserBlocked = "user_blocked"
515
- }
516
- declare const PaymentErrorMessage: Record<PaymentErrorCodes, string>;
517
- type MiniAppPaymentSuccessPayload = MiniAppBaseSuccessPayload & {
518
- transaction_status: 'submitted';
519
- transaction_id: string;
520
- reference: string;
521
- from: string;
522
- chain: Network;
523
- timestamp: string;
524
- };
525
- type MiniAppPaymentErrorPayload = MiniAppBaseErrorPayload<PaymentErrorCodes>;
526
- type MiniAppPaymentPayload = MiniAppPaymentSuccessPayload | MiniAppPaymentErrorPayload;
527
- declare function createPayCommand(_ctx: CommandContext): (payload: PayCommandInput) => PayCommandPayload | null;
528
- declare function createPayAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createPayCommand>): (payload: PayCommandInput) => AsyncHandlerReturn<PayCommandPayload | null, MiniAppPaymentPayload>;
529
-
530
- type VerifyCommandInput = {
531
- action: IDKitConfig['action'];
532
- signal?: IDKitConfig['signal'];
533
- verification_level?: VerificationLevel | [VerificationLevel, ...VerificationLevel[]];
534
- skip_proof_compression?: boolean;
535
- };
536
- type VerifyCommandPayload = Omit<VerifyCommandInput, 'skip_proof_compression'> & {
537
- timestamp: string;
538
- };
539
-
540
- type MiniAppVerifyActionSuccessPayload = MiniAppBaseSuccessPayload & {
541
- proof: string;
542
- merkle_root: string;
543
- nullifier_hash: string;
544
- verification_level: VerificationLevel;
545
- };
546
- type VerificationResult = Omit<MiniAppVerifyActionSuccessPayload, 'status' | 'version'>;
547
- type MiniAppVerifyActionMultiSuccessPayload = MiniAppBaseSuccessPayload & {
548
- verifications: VerificationResult[];
549
- };
550
- type MiniAppVerifyActionErrorPayload = MiniAppBaseErrorPayload<string>;
551
- type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionMultiSuccessPayload | MiniAppVerifyActionErrorPayload;
552
- declare function createVerifyCommand(ctx: CommandContext): (payload: VerifyCommandInput) => VerifyCommandPayload | null;
553
- declare function createVerifyAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createVerifyCommand>): (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
554
-
555
- declare function createCommands(ctx: CommandContext): {
556
- verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
557
- pay: (payload: PayCommandInput) => PayCommandPayload | null;
558
- walletAuth: (payload: WalletAuthInput) => WalletAuthPayload | null;
559
- sendTransaction: (payload: SendTransactionInput) => SendTransactionPayload | null;
560
- signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
561
- signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
562
- shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
563
- requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
564
- getPermissions: () => GetPermissionsPayload | null;
565
- sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
566
- share: (payload: ShareInput) => ShareInput | null;
567
- chat: (payload: ChatPayload) => ChatPayload | null;
568
- };
569
- type Commands = ReturnType<typeof createCommands>;
570
- declare function createAsyncCommands(ctx: CommandContext, commands: Commands): {
571
- verify: (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
572
- pay: (payload: PayCommandInput) => AsyncHandlerReturn<PayCommandPayload | null, MiniAppPaymentPayload>;
573
- walletAuth: (payload: WalletAuthInput) => AsyncHandlerReturn<WalletAuthPayload | null, MiniAppWalletAuthPayload>;
574
- sendTransaction: (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
575
- signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
576
- signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
577
- shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
578
- requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
579
- getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
580
- sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
581
- share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
582
- chat: (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
583
- };
584
- type AsyncCommands = ReturnType<typeof createAsyncCommands>;
1
+ import { W as WalletAuthResult, M as MiniKitWalletAuthOptions, C as CommandResultByVia, i as isInWorldApp, U as User, D as DeviceProperties, a as MiniAppLaunchLocation, R as ResponseEvent, b as MiniKitInstallReturnType, c as UserNameService } from './types-CKn5C-Ro.cjs';
2
+ import { S as SendTransactionResult, M as MiniKitSendTransactionOptions, P as PayResult, a as MiniKitPayOptions, b as ShareContactsResult, c as MiniKitShareContactsOptions, d as MiniAppSignMessageSuccessPayload, e as MiniKitSignMessageOptions, f as MiniAppSignTypedDataPayload, g as MiniKitSignTypedDataOptions, h as MiniAppSignTypedDataSuccessPayload, i as MiniAppChatPayload, j as MiniKitChatOptions, k as MiniAppChatSuccessPayload, l as MiniAppSharePayload, m as MiniKitShareOptions, n as MiniAppShareSuccessPayload, o as MiniAppGetPermissionsPayload, p as MiniKitGetPermissionsOptions, q as MiniAppGetPermissionsSuccessPayload, r as MiniAppRequestPermissionPayload, s as MiniKitRequestPermissionOptions, t as MiniAppRequestPermissionSuccessPayload, u as MiniAppSendHapticFeedbackPayload, v as MiniKitSendHapticFeedbackOptions, w as MiniAppSendHapticFeedbackSuccessPayload } from './types-DO2UGrgp.cjs';
3
+ export { W as WorldAppProvider, g as getWorldAppProvider } from './provider-DeDUsLbs.cjs';
4
+ import 'abitype';
585
5
 
586
6
  declare class MiniKit {
587
7
  private static eventManager;
588
- private static stateManager;
589
- private static commandsInstance;
590
- private static asyncCommandsInstance;
8
+ private static _appId;
9
+ private static _user;
10
+ private static _deviceProperties;
11
+ private static _location;
12
+ private static _isReady;
13
+ private static getActiveMiniKit;
14
+ /**
15
+ * Authenticate user via wallet signature (SIWE)
16
+ *
17
+ * Works in World App (native SIWE) and web (Wagmi + SIWE fallback).
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const result = await MiniKit.walletAuth({ nonce: 'randomnonce123' });
22
+ * console.log(result.data.address);
23
+ * console.log(result.executedWith); // 'minikit' | 'wagmi' | 'fallback'
24
+ * ```
25
+ */
26
+ static walletAuth<TFallback = WalletAuthResult>(options: MiniKitWalletAuthOptions<TFallback>): Promise<CommandResultByVia<WalletAuthResult, TFallback>>;
27
+ /**
28
+ * Send one or more transactions
29
+ *
30
+ * World App: batch + permit2 + gas sponsorship
31
+ * Web: sequential execution via Wagmi
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const result = await MiniKit.sendTransaction({
36
+ * chainId: 480,
37
+ * transaction: [{
38
+ * address: '0x...',
39
+ * abi: ContractABI,
40
+ * functionName: 'mint',
41
+ * args: [],
42
+ * }],
43
+ * });
44
+ * ```
45
+ */
46
+ static sendTransaction<TFallback = SendTransactionResult>(options: MiniKitSendTransactionOptions<TFallback>): Promise<CommandResultByVia<SendTransactionResult, TFallback>>;
47
+ /**
48
+ * Send a payment (World App only)
49
+ *
50
+ * Requires custom fallback on web.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const result = await MiniKit.pay({
55
+ * reference: crypto.randomUUID(),
56
+ * to: '0x...',
57
+ * tokens: [{ symbol: Tokens.WLD, token_amount: '1.0' }],
58
+ * description: 'Payment for coffee',
59
+ * fallback: () => showStripeCheckout(),
60
+ * });
61
+ * ```
62
+ */
63
+ static pay<TFallback = PayResult>(options: MiniKitPayOptions<TFallback>): Promise<CommandResultByVia<PayResult, TFallback, 'minikit'>>;
64
+ /**
65
+ * Open the contact picker (World App only)
66
+ *
67
+ * Requires custom fallback on web.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const result = await MiniKit.shareContacts({
72
+ * isMultiSelectEnabled: true,
73
+ * fallback: () => showManualAddressInput(),
74
+ * });
75
+ * ```
76
+ */
77
+ static shareContacts<TFallback = ShareContactsResult>(options?: MiniKitShareContactsOptions<TFallback>): Promise<CommandResultByVia<ShareContactsResult, TFallback, 'minikit'>>;
78
+ /**
79
+ * Sign a message
80
+ */
81
+ static signMessage<TFallback = MiniAppSignMessageSuccessPayload>(options: MiniKitSignMessageOptions<TFallback>): Promise<CommandResultByVia<MiniAppSignMessageSuccessPayload, TFallback>>;
82
+ /**
83
+ * Sign typed data (EIP-712)
84
+ */
85
+ static signTypedData<TFallback = MiniAppSignTypedDataPayload>(options: MiniKitSignTypedDataOptions<TFallback>): Promise<CommandResultByVia<MiniAppSignTypedDataSuccessPayload, TFallback>>;
86
+ /**
87
+ * Send a chat message
88
+ */
89
+ static chat<TFallback = MiniAppChatPayload>(options: MiniKitChatOptions<TFallback>): Promise<CommandResultByVia<MiniAppChatSuccessPayload, TFallback, 'minikit'>>;
90
+ /**
91
+ * Share files/text/URL
92
+ */
93
+ static share<TFallback = MiniAppSharePayload>(options: MiniKitShareOptions<TFallback>): Promise<CommandResultByVia<MiniAppShareSuccessPayload, TFallback, 'minikit'>>;
94
+ /**
95
+ * Get current permission settings
96
+ */
97
+ static getPermissions<TFallback = MiniAppGetPermissionsPayload>(options?: MiniKitGetPermissionsOptions<TFallback>): Promise<CommandResultByVia<MiniAppGetPermissionsSuccessPayload, TFallback, 'minikit'>>;
98
+ /**
99
+ * Request a permission from the user
100
+ */
101
+ static requestPermission<TFallback = MiniAppRequestPermissionPayload>(options: MiniKitRequestPermissionOptions<TFallback>): Promise<CommandResultByVia<MiniAppRequestPermissionSuccessPayload, TFallback, 'minikit'>>;
102
+ /**
103
+ * Trigger haptic feedback
104
+ */
105
+ static sendHapticFeedback<TFallback = MiniAppSendHapticFeedbackPayload>(options: MiniKitSendHapticFeedbackOptions<TFallback>): Promise<CommandResultByVia<MiniAppSendHapticFeedbackSuccessPayload, TFallback, 'minikit'>>;
106
+ /**
107
+ * Check if running inside World App
108
+ */
109
+ static isInWorldApp: typeof isInWorldApp;
591
110
  static get appId(): string | null;
592
111
  static set appId(value: string | null);
593
- static get user(): typeof MiniKit.stateManager.user;
594
- static set user(value: typeof MiniKit.stateManager.user);
112
+ static get user(): User;
113
+ static set user(value: User);
595
114
  static get deviceProperties(): DeviceProperties;
596
115
  static get location(): MiniAppLaunchLocation | null;
597
116
  static subscribe<E extends ResponseEvent>(event: E, handler: (payload: any) => void): void;
@@ -600,47 +119,37 @@ declare class MiniKit {
600
119
  private static sendInit;
601
120
  static install(appId?: string): MiniKitInstallReturnType;
602
121
  static isInstalled(debug?: boolean): boolean;
122
+ private static initFromWorldApp;
123
+ private static updateUserFromWalletAuth;
603
124
  private static getContext;
604
- static get commands(): Commands;
605
- static get commandsAsync(): AsyncCommands;
606
125
  static getUserByAddress: (address?: string) => Promise<UserNameService>;
607
126
  static getUserByUsername: (username: string) => Promise<UserNameService>;
608
127
  static getUserInfo: (address?: string) => Promise<UserNameService>;
609
128
  static getMiniAppUrl: (appId: string, path?: string) => string;
610
129
  static showProfileCard: (username?: string, walletAddress?: string) => void;
611
- }
612
-
613
- type SiweMessage = {
614
- scheme?: string;
615
- domain: string;
616
- address?: string;
617
- statement?: string;
618
- uri: string;
619
- version: string;
620
- chain_id: number;
621
- nonce: string;
622
- issued_at: string;
623
- expiration_time?: string;
624
- not_before?: string;
625
- request_id?: string;
626
- };
627
-
628
- declare const tokenToDecimals: (amount: number, token: Tokens) => number;
629
-
630
- type MiniAppWalletAuthSuccessPayload = {
631
- status: 'success';
632
- message: string;
633
- signature: string;
634
- address: string;
635
- version: number;
636
- };
637
-
638
- declare const parseSiweMessage: (inputString: string) => SiweMessage;
639
- declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonce: string, statement?: string, requestId?: string, userProvider?: Client) => Promise<{
640
- isValid: boolean;
641
- siweMessageData: SiweMessage;
642
- }>;
643
-
644
- declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
645
-
646
- export { type AsyncCommands, type AsyncHandlerReturn, COMMAND_VERSIONS, ChatErrorCodes, ChatErrorMessage, type ChatPayload, Command, type CommandContext, type Commands, type Contact, type ContractFunctionArgs, type ContractFunctionName, type DeviceProperties, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppBaseErrorPayload, type MiniAppBaseSuccessPayload, type MiniAppChatErrorPayload, type MiniAppChatPayload, type MiniAppChatSuccessPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, MiniAppLaunchLocation, type MiniAppLocation, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendHapticFeedbackErrorPayload, type MiniAppSendHapticFeedbackPayload, type MiniAppSendHapticFeedbackSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppShareErrorPayload, type MiniAppSharePayload, type MiniAppShareSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionMultiSuccessPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload$1 as MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, Permission, type PermissionSettings, type Permit2, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SendHapticFeedbackErrorCodes, SendHapticFeedbackErrorMessage, type SendHapticFeedbackInput, type SendHapticFeedbackPayload, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, ShareFilesErrorCodes, ShareFilesErrorMessage, type ShareInput, type SharePayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, type Transaction, type User, type UserNameService, type VerificationResult, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, createAsyncCommands, createChatAsyncCommand, createChatCommand, createCommands, createGetPermissionsAsyncCommand, createGetPermissionsCommand, createPayAsyncCommand, createPayCommand, createRequestPermissionAsyncCommand, createRequestPermissionCommand, createSendHapticFeedbackAsyncCommand, createSendHapticFeedbackCommand, createSendTransactionAsyncCommand, createSendTransactionCommand, createShareAsyncCommand, createShareCommand, createShareContactsAsyncCommand, createShareContactsCommand, createSignMessageAsyncCommand, createSignMessageCommand, createSignTypedDataAsyncCommand, createSignTypedDataCommand, createVerifyAsyncCommand, createVerifyCommand, createWalletAuthAsyncCommand, createWalletAuthCommand, getIsUserVerified, isCommandAvailable, mapWorldAppLaunchLocation, parseSiweMessage, sendMiniKitEvent, setCommandAvailable, tokenToDecimals, validateCommands, verifySiweMessage };
130
+ /**
131
+ * @deprecated Use `MiniKit.pay()`, `MiniKit.walletAuth()`, etc. directly.
132
+ *
133
+ * Migration guide:
134
+ * - `MiniKit.commands.pay(payload)` → `await MiniKit.pay(options)`
135
+ * - `MiniKit.commands.walletAuth(payload)` → `await MiniKit.walletAuth(options)`
136
+ * - `MiniKit.commands.sendTransaction(payload)` → `await MiniKit.sendTransaction(options)`
137
+ * - `MiniKit.commands.signMessage(payload)` → `await MiniKit.signMessage(input)`
138
+ * - `MiniKit.commands.signTypedData(payload)` → `await MiniKit.signTypedData(input)`
139
+ * - `MiniKit.commands.shareContacts(payload)` → `await MiniKit.shareContacts(options)`
140
+ * - `MiniKit.commands.chat(payload)` → `await MiniKit.chat(input)`
141
+ * - `MiniKit.commands.share(payload)` → `await MiniKit.share(input)`
142
+ * - `MiniKit.commands.getPermissions()` → `await MiniKit.getPermissions()`
143
+ * - `MiniKit.commands.requestPermission(payload)` → `await MiniKit.requestPermission(input)`
144
+ * - `MiniKit.commands.sendHapticFeedback(payload)` → `await MiniKit.sendHapticFeedback(input)`
145
+ */
146
+ static get commands(): never;
147
+ /**
148
+ * @deprecated Use `MiniKit.pay()`, `MiniKit.walletAuth()`, etc. directly. All commands are now async by default.
149
+ *
150
+ * See `MiniKit.commands` deprecation notice for the full migration guide.
151
+ */
152
+ static get commandsAsync(): never;
153
+ }
154
+
155
+ export { MiniKit };