@worldcoin/minikit-js 1.3.0 → 1.5.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.ts CHANGED
@@ -4,36 +4,6 @@ import { Abi, AbiStateMutability, ExtractAbiFunctionNames, AbiParametersToPrimit
4
4
  export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
5
5
  import { Client } from 'viem';
6
6
 
7
- declare enum Tokens {
8
- USDCE = "USDCE",
9
- WLD = "WLD"
10
- }
11
- declare const TokenDecimals: {
12
- [key in Tokens]: number;
13
- };
14
- declare enum Network {
15
- Optimism = "optimism",
16
- WorldChain = "worldchain"
17
- }
18
-
19
- type Permit2 = {
20
- permitted: {
21
- token: string;
22
- amount: string | unknown;
23
- };
24
- spender: string;
25
- nonce: string | unknown;
26
- deadline: string | unknown;
27
- };
28
- type Transaction = {
29
- address: string;
30
- abi: Abi | readonly unknown[];
31
- functionName: ContractFunctionName<Abi | readonly unknown[], "payable" | "nonpayable">;
32
- args: ContractFunctionArgs<Abi | readonly unknown[], "payable" | "nonpayable", ContractFunctionName<Abi | readonly unknown[], "payable" | "nonpayable">>;
33
- };
34
- 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;
35
- 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[];
36
-
37
7
  declare const VerificationErrorMessage: Record<AppErrorCodes, string>;
38
8
  declare enum PaymentErrorCodes {
39
9
  InputError = "input_error",
@@ -136,6 +106,52 @@ declare const ShareContactsErrorMessage: {
136
106
  user_rejected: string;
137
107
  generic_error: string;
138
108
  };
109
+ declare enum RequestPermissionErrorCodes {
110
+ UserRejected = "user_rejected",
111
+ GenericError = "generic_error",
112
+ AlreadyRequested = "already_requested",
113
+ PermissionDisabled = "permission_disabled",
114
+ AlreadyGranted = "already_granted",
115
+ UnsupportedPermission = "unsupported_permission"
116
+ }
117
+ declare const RequestPermissionErrorMessage: {
118
+ user_rejected: string;
119
+ generic_error: string;
120
+ already_requested: string;
121
+ permission_disabled: string;
122
+ already_granted: string;
123
+ unsupported_permission: string;
124
+ };
125
+
126
+ declare enum Tokens {
127
+ USDCE = "USDCE",
128
+ WLD = "WLD"
129
+ }
130
+ declare const TokenDecimals: {
131
+ [key in Tokens]: number;
132
+ };
133
+ declare enum Network {
134
+ Optimism = "optimism",
135
+ WorldChain = "worldchain"
136
+ }
137
+
138
+ type Permit2 = {
139
+ permitted: {
140
+ token: string;
141
+ amount: string | unknown;
142
+ };
143
+ spender: string;
144
+ nonce: string | unknown;
145
+ deadline: string | unknown;
146
+ };
147
+ type Transaction = {
148
+ address: string;
149
+ abi: Abi | readonly unknown[];
150
+ functionName: ContractFunctionName<Abi | readonly unknown[], 'payable' | 'nonpayable'>;
151
+ args: ContractFunctionArgs<Abi | readonly unknown[], 'payable' | 'nonpayable', ContractFunctionName<Abi | readonly unknown[], 'payable' | 'nonpayable'>>;
152
+ };
153
+ 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;
154
+ 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[];
139
155
 
140
156
  declare enum Command {
141
157
  Verify = "verify",
@@ -144,7 +160,8 @@ declare enum Command {
144
160
  SendTransaction = "send-transaction",
145
161
  SignMessage = "sign-message",
146
162
  SignTypedData = "sign-typed-data",
147
- ShareContacts = "share-contacts"
163
+ ShareContacts = "share-contacts",
164
+ RequestPermission = "request-permission"
148
165
  }
149
166
  type WebViewBasePayload = {
150
167
  command: Command;
@@ -156,8 +173,8 @@ type AsyncHandlerReturn<CommandPayload, FinalPayload> = Promise<{
156
173
  finalPayload: FinalPayload;
157
174
  }>;
158
175
  type VerifyCommandInput = {
159
- action: IDKitConfig["action"];
160
- signal?: IDKitConfig["signal"];
176
+ action: IDKitConfig['action'];
177
+ signal?: IDKitConfig['signal'];
161
178
  verification_level?: VerificationLevel;
162
179
  };
163
180
  type VerifyCommandPayload = VerifyCommandInput & {
@@ -210,8 +227,16 @@ type SignTypedDataInput = {
210
227
  type SignTypedDataPayload = SignTypedDataInput;
211
228
  type ShareContactsInput = {
212
229
  isMultiSelectEnabled: boolean;
230
+ inviteMessage?: string;
213
231
  };
214
232
  type ShareContactsPayload = ShareContactsInput;
233
+ declare enum Permission {
234
+ Notifications = "notifications"
235
+ }
236
+ type RequestPermissionInput = {
237
+ permission: Permission;
238
+ };
239
+ type RequestPermissionPayload = RequestPermissionInput;
215
240
  type CommandReturnPayloadMap = {
216
241
  [Command.Verify]: VerifyCommandPayload;
217
242
  [Command.Pay]: PayCommandPayload;
@@ -220,6 +245,7 @@ type CommandReturnPayloadMap = {
220
245
  [Command.SignMessage]: SignMessagePayload;
221
246
  [Command.SignTypedData]: SignTypedDataPayload;
222
247
  [Command.ShareContacts]: ShareContactsPayload;
248
+ [Command.RequestPermission]: RequestPermissionPayload;
223
249
  };
224
250
  type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
225
251
 
@@ -230,10 +256,11 @@ declare enum ResponseEvent {
230
256
  MiniAppSendTransaction = "miniapp-send-transaction",
231
257
  MiniAppSignMessage = "miniapp-sign-message",
232
258
  MiniAppSignTypedData = "miniapp-sign-typed-data",
233
- MiniAppShareContacts = "miniapp-share-contacts"
259
+ MiniAppShareContacts = "miniapp-share-contacts",
260
+ MiniAppRequestPermission = "miniapp-request-permission"
234
261
  }
235
262
  type MiniAppVerifyActionSuccessPayload = {
236
- status: "success";
263
+ status: 'success';
237
264
  proof: string;
238
265
  merkle_root: string;
239
266
  nullifier_hash: string;
@@ -241,14 +268,14 @@ type MiniAppVerifyActionSuccessPayload = {
241
268
  version: number;
242
269
  };
243
270
  type MiniAppVerifyActionErrorPayload = {
244
- status: "error";
271
+ status: 'error';
245
272
  error_code: AppErrorCodes;
246
273
  version: number;
247
274
  };
248
275
  type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionErrorPayload;
249
276
  type MiniAppPaymentSuccessPayload = {
250
- status: "success";
251
- transaction_status: "submitted";
277
+ status: 'success';
278
+ transaction_status: 'submitted';
252
279
  transaction_id: string;
253
280
  reference: string;
254
281
  from: string;
@@ -257,28 +284,28 @@ type MiniAppPaymentSuccessPayload = {
257
284
  version: number;
258
285
  };
259
286
  type MiniAppPaymentErrorPayload = {
260
- status: "error";
287
+ status: 'error';
261
288
  error_code: PaymentErrorCodes;
262
289
  version: number;
263
290
  };
264
291
  type MiniAppPaymentPayload = MiniAppPaymentSuccessPayload | MiniAppPaymentErrorPayload;
265
292
  type MiniAppWalletAuthSuccessPayload = {
266
- status: "success";
293
+ status: 'success';
267
294
  message: string;
268
295
  signature: string;
269
296
  address: string;
270
297
  version: number;
271
298
  };
272
299
  type MiniAppWalletAuthErrorPayload = {
273
- status: "error";
300
+ status: 'error';
274
301
  error_code: WalletAuthErrorCodes;
275
302
  details: (typeof WalletAuthErrorMessage)[WalletAuthErrorCodes];
276
303
  version: number;
277
304
  };
278
305
  type MiniAppWalletAuthPayload = MiniAppWalletAuthSuccessPayload | MiniAppWalletAuthErrorPayload;
279
306
  type MiniAppSendTransactionSuccessPayload = {
280
- status: "success";
281
- transaction_status: "submitted";
307
+ status: 'success';
308
+ transaction_status: 'submitted';
282
309
  transaction_id: string;
283
310
  reference: string;
284
311
  from: string;
@@ -287,33 +314,33 @@ type MiniAppSendTransactionSuccessPayload = {
287
314
  version: number;
288
315
  };
289
316
  type MiniAppSendTransactionErrorPayload = {
290
- status: "error";
317
+ status: 'error';
291
318
  error_code: SendTransactionErrorCodes;
292
319
  details?: Record<string, any>;
293
320
  version: number;
294
321
  };
295
322
  type MiniAppSendTransactionPayload = MiniAppSendTransactionSuccessPayload | MiniAppSendTransactionErrorPayload;
296
323
  type MiniAppSignMessageSuccessPayload = {
297
- status: "success";
324
+ status: 'success';
298
325
  signature: string;
299
326
  address: string;
300
327
  version: number;
301
328
  };
302
329
  type MiniAppSignMessageErrorPayload = {
303
- status: "error";
330
+ status: 'error';
304
331
  error_code: SignMessageErrorCodes;
305
332
  details?: Record<string, any>;
306
333
  version: number;
307
334
  };
308
335
  type MiniAppSignMessagePayload = MiniAppSignMessageSuccessPayload | MiniAppSignMessageErrorPayload;
309
336
  type MiniAppSignTypedDataSuccessPayload = {
310
- status: "success";
337
+ status: 'success';
311
338
  signature: string;
312
339
  address: string;
313
340
  version: number;
314
341
  };
315
342
  type MiniAppSignTypedDataErrorPayload = {
316
- status: "error";
343
+ status: 'error';
317
344
  error_code: SignTypedDataErrorCodes;
318
345
  details?: Record<string, any>;
319
346
  version: number;
@@ -325,17 +352,30 @@ type Contact = {
325
352
  profilePictureUrl: string | null;
326
353
  };
327
354
  type MiniAppShareContactsSuccessPayload = {
328
- status: "success";
355
+ status: 'success';
329
356
  contacts: Contact[];
330
357
  version: number;
331
358
  timestamp: string;
332
359
  };
333
360
  type MiniAppShareContactsErrorPayload = {
334
- status: "error";
361
+ status: 'error';
335
362
  error_code: ShareContactsErrorCodes;
336
363
  version: number;
337
364
  };
338
365
  type MiniAppShareContactsPayload = MiniAppShareContactsSuccessPayload | MiniAppShareContactsErrorPayload;
366
+ type MiniAppRequestPermissionSuccessPayload = {
367
+ status: 'success';
368
+ permission: Permission;
369
+ timestamp: string;
370
+ version: number;
371
+ };
372
+ type MiniAppRequestPermissionErrorPayload = {
373
+ status: 'error';
374
+ error_code: RequestPermissionErrorCodes;
375
+ description: string;
376
+ version: number;
377
+ };
378
+ type MiniAppRequestPermissionPayload = MiniAppRequestPermissionSuccessPayload | MiniAppRequestPermissionErrorPayload;
339
379
  type EventPayloadMap = {
340
380
  [ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
341
381
  [ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
@@ -344,23 +384,15 @@ type EventPayloadMap = {
344
384
  [ResponseEvent.MiniAppSignMessage]: MiniAppSignMessagePayload;
345
385
  [ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
346
386
  [ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
387
+ [ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
347
388
  };
348
389
  type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
349
390
  type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
350
391
 
351
- type SiweMessage = {
352
- scheme?: string;
353
- domain: string;
354
- address?: string;
355
- statement?: string;
356
- uri: string;
357
- version: number;
358
- chain_id: number;
359
- nonce: string;
360
- issued_at: string;
361
- expiration_time?: string;
362
- not_before?: string;
363
- request_id?: string;
392
+ type User = {
393
+ walletAddress: string;
394
+ username: string | null;
395
+ profilePictureUrl: string | null;
364
396
  };
365
397
 
366
398
  declare class MiniKit {
@@ -369,12 +401,11 @@ declare class MiniKit {
369
401
  private static isCommandAvailable;
370
402
  private static listeners;
371
403
  static appId: string | null;
404
+ /**
405
+ * @deprecated you should use MiniKit.user.walletAddress instead
406
+ */
372
407
  static walletAddress: string | null;
373
- static user: {
374
- walletAddress: string | null;
375
- username: string | null;
376
- profilePictureUrl: string | null;
377
- } | null;
408
+ static user: User | null;
378
409
  private static sendInit;
379
410
  static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
380
411
  static unsubscribe(event: ResponseEvent): void;
@@ -383,6 +414,7 @@ declare class MiniKit {
383
414
  private static commandsValid;
384
415
  static install(appId?: string): MiniKitInstallReturnType;
385
416
  static isInstalled(debug?: boolean): boolean;
417
+ static getUserByAddress: (address: string) => Promise<User>;
386
418
  static commands: {
387
419
  verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
388
420
  pay: (payload: PayCommandInput) => PayCommandPayload | null;
@@ -391,6 +423,7 @@ declare class MiniKit {
391
423
  signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
392
424
  signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
393
425
  shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
426
+ requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
394
427
  };
395
428
  /**
396
429
  * This object contains async versions of all the commands.
@@ -410,25 +443,48 @@ declare class MiniKit {
410
443
  signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
411
444
  signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
412
445
  shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
446
+ requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
413
447
  };
414
448
  }
415
449
 
450
+ type SiweMessage = {
451
+ scheme?: string;
452
+ domain: string;
453
+ address?: string;
454
+ statement?: string;
455
+ uri: string;
456
+ version: number;
457
+ chain_id: number;
458
+ nonce: string;
459
+ issued_at: string;
460
+ expiration_time?: string;
461
+ not_before?: string;
462
+ request_id?: string;
463
+ };
464
+
416
465
  declare const tokenToDecimals: (amount: number, token: Tokens) => number;
417
466
 
418
467
  declare const parseSiweMessage: (inputString: string) => SiweMessage;
419
468
  declare const SAFE_CONTRACT_ABI: {
420
- name: string;
421
- type: string;
422
- stateMutability: string;
423
469
  inputs: {
470
+ internalType: string;
424
471
  name: string;
425
472
  type: string;
426
473
  }[];
427
- outputs: never[];
474
+ name: string;
475
+ outputs: {
476
+ internalType: string;
477
+ name: string;
478
+ type: string;
479
+ }[];
480
+ stateMutability: string;
481
+ type: string;
428
482
  }[];
429
483
  declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonce: string, statement?: string, requestId?: string, userProvider?: Client) => Promise<{
430
484
  isValid: boolean;
431
485
  siweMessageData: SiweMessage;
432
486
  }>;
433
487
 
434
- export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, parseSiweMessage, tokenToDecimals, verifySiweMessage };
488
+ declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
489
+
490
+ export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, Permission, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };