@worldcoin/minikit-js 1.4.0 → 1.6.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,53 @@ 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
+ value?: string | undefined;
152
+ args: ContractFunctionArgs<Abi | readonly unknown[], 'payable' | 'nonpayable', ContractFunctionName<Abi | readonly unknown[], 'payable' | 'nonpayable'>>;
153
+ };
154
+ 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;
155
+ 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
156
 
140
157
  declare enum Command {
141
158
  Verify = "verify",
@@ -144,7 +161,8 @@ declare enum Command {
144
161
  SendTransaction = "send-transaction",
145
162
  SignMessage = "sign-message",
146
163
  SignTypedData = "sign-typed-data",
147
- ShareContacts = "share-contacts"
164
+ ShareContacts = "share-contacts",
165
+ RequestPermission = "request-permission"
148
166
  }
149
167
  type WebViewBasePayload = {
150
168
  command: Command;
@@ -156,8 +174,8 @@ type AsyncHandlerReturn<CommandPayload, FinalPayload> = Promise<{
156
174
  finalPayload: FinalPayload;
157
175
  }>;
158
176
  type VerifyCommandInput = {
159
- action: IDKitConfig["action"];
160
- signal?: IDKitConfig["signal"];
177
+ action: IDKitConfig['action'];
178
+ signal?: IDKitConfig['signal'];
161
179
  verification_level?: VerificationLevel;
162
180
  };
163
181
  type VerifyCommandPayload = VerifyCommandInput & {
@@ -210,8 +228,16 @@ type SignTypedDataInput = {
210
228
  type SignTypedDataPayload = SignTypedDataInput;
211
229
  type ShareContactsInput = {
212
230
  isMultiSelectEnabled: boolean;
231
+ inviteMessage?: string;
213
232
  };
214
233
  type ShareContactsPayload = ShareContactsInput;
234
+ declare enum Permission {
235
+ Notifications = "notifications"
236
+ }
237
+ type RequestPermissionInput = {
238
+ permission: Permission;
239
+ };
240
+ type RequestPermissionPayload = RequestPermissionInput;
215
241
  type CommandReturnPayloadMap = {
216
242
  [Command.Verify]: VerifyCommandPayload;
217
243
  [Command.Pay]: PayCommandPayload;
@@ -220,6 +246,7 @@ type CommandReturnPayloadMap = {
220
246
  [Command.SignMessage]: SignMessagePayload;
221
247
  [Command.SignTypedData]: SignTypedDataPayload;
222
248
  [Command.ShareContacts]: ShareContactsPayload;
249
+ [Command.RequestPermission]: RequestPermissionPayload;
223
250
  };
224
251
  type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
225
252
 
@@ -230,10 +257,11 @@ declare enum ResponseEvent {
230
257
  MiniAppSendTransaction = "miniapp-send-transaction",
231
258
  MiniAppSignMessage = "miniapp-sign-message",
232
259
  MiniAppSignTypedData = "miniapp-sign-typed-data",
233
- MiniAppShareContacts = "miniapp-share-contacts"
260
+ MiniAppShareContacts = "miniapp-share-contacts",
261
+ MiniAppRequestPermission = "miniapp-request-permission"
234
262
  }
235
263
  type MiniAppVerifyActionSuccessPayload = {
236
- status: "success";
264
+ status: 'success';
237
265
  proof: string;
238
266
  merkle_root: string;
239
267
  nullifier_hash: string;
@@ -241,14 +269,14 @@ type MiniAppVerifyActionSuccessPayload = {
241
269
  version: number;
242
270
  };
243
271
  type MiniAppVerifyActionErrorPayload = {
244
- status: "error";
272
+ status: 'error';
245
273
  error_code: AppErrorCodes;
246
274
  version: number;
247
275
  };
248
276
  type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionErrorPayload;
249
277
  type MiniAppPaymentSuccessPayload = {
250
- status: "success";
251
- transaction_status: "submitted";
278
+ status: 'success';
279
+ transaction_status: 'submitted';
252
280
  transaction_id: string;
253
281
  reference: string;
254
282
  from: string;
@@ -257,28 +285,28 @@ type MiniAppPaymentSuccessPayload = {
257
285
  version: number;
258
286
  };
259
287
  type MiniAppPaymentErrorPayload = {
260
- status: "error";
288
+ status: 'error';
261
289
  error_code: PaymentErrorCodes;
262
290
  version: number;
263
291
  };
264
292
  type MiniAppPaymentPayload = MiniAppPaymentSuccessPayload | MiniAppPaymentErrorPayload;
265
293
  type MiniAppWalletAuthSuccessPayload = {
266
- status: "success";
294
+ status: 'success';
267
295
  message: string;
268
296
  signature: string;
269
297
  address: string;
270
298
  version: number;
271
299
  };
272
300
  type MiniAppWalletAuthErrorPayload = {
273
- status: "error";
301
+ status: 'error';
274
302
  error_code: WalletAuthErrorCodes;
275
303
  details: (typeof WalletAuthErrorMessage)[WalletAuthErrorCodes];
276
304
  version: number;
277
305
  };
278
306
  type MiniAppWalletAuthPayload = MiniAppWalletAuthSuccessPayload | MiniAppWalletAuthErrorPayload;
279
307
  type MiniAppSendTransactionSuccessPayload = {
280
- status: "success";
281
- transaction_status: "submitted";
308
+ status: 'success';
309
+ transaction_status: 'submitted';
282
310
  transaction_id: string;
283
311
  reference: string;
284
312
  from: string;
@@ -287,33 +315,33 @@ type MiniAppSendTransactionSuccessPayload = {
287
315
  version: number;
288
316
  };
289
317
  type MiniAppSendTransactionErrorPayload = {
290
- status: "error";
318
+ status: 'error';
291
319
  error_code: SendTransactionErrorCodes;
292
320
  details?: Record<string, any>;
293
321
  version: number;
294
322
  };
295
323
  type MiniAppSendTransactionPayload = MiniAppSendTransactionSuccessPayload | MiniAppSendTransactionErrorPayload;
296
324
  type MiniAppSignMessageSuccessPayload = {
297
- status: "success";
325
+ status: 'success';
298
326
  signature: string;
299
327
  address: string;
300
328
  version: number;
301
329
  };
302
330
  type MiniAppSignMessageErrorPayload = {
303
- status: "error";
331
+ status: 'error';
304
332
  error_code: SignMessageErrorCodes;
305
333
  details?: Record<string, any>;
306
334
  version: number;
307
335
  };
308
336
  type MiniAppSignMessagePayload = MiniAppSignMessageSuccessPayload | MiniAppSignMessageErrorPayload;
309
337
  type MiniAppSignTypedDataSuccessPayload = {
310
- status: "success";
338
+ status: 'success';
311
339
  signature: string;
312
340
  address: string;
313
341
  version: number;
314
342
  };
315
343
  type MiniAppSignTypedDataErrorPayload = {
316
- status: "error";
344
+ status: 'error';
317
345
  error_code: SignTypedDataErrorCodes;
318
346
  details?: Record<string, any>;
319
347
  version: number;
@@ -325,17 +353,30 @@ type Contact = {
325
353
  profilePictureUrl: string | null;
326
354
  };
327
355
  type MiniAppShareContactsSuccessPayload = {
328
- status: "success";
356
+ status: 'success';
329
357
  contacts: Contact[];
330
358
  version: number;
331
359
  timestamp: string;
332
360
  };
333
361
  type MiniAppShareContactsErrorPayload = {
334
- status: "error";
362
+ status: 'error';
335
363
  error_code: ShareContactsErrorCodes;
336
364
  version: number;
337
365
  };
338
366
  type MiniAppShareContactsPayload = MiniAppShareContactsSuccessPayload | MiniAppShareContactsErrorPayload;
367
+ type MiniAppRequestPermissionSuccessPayload = {
368
+ status: 'success';
369
+ permission: Permission;
370
+ timestamp: string;
371
+ version: number;
372
+ };
373
+ type MiniAppRequestPermissionErrorPayload = {
374
+ status: 'error';
375
+ error_code: RequestPermissionErrorCodes;
376
+ description: string;
377
+ version: number;
378
+ };
379
+ type MiniAppRequestPermissionPayload = MiniAppRequestPermissionSuccessPayload | MiniAppRequestPermissionErrorPayload;
339
380
  type EventPayloadMap = {
340
381
  [ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
341
382
  [ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
@@ -344,23 +385,15 @@ type EventPayloadMap = {
344
385
  [ResponseEvent.MiniAppSignMessage]: MiniAppSignMessagePayload;
345
386
  [ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
346
387
  [ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
388
+ [ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
347
389
  };
348
390
  type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
349
391
  type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
350
392
 
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;
393
+ type User = {
394
+ walletAddress: string;
395
+ username: string | null;
396
+ profilePictureUrl: string | null;
364
397
  };
365
398
 
366
399
  declare class MiniKit {
@@ -373,11 +406,7 @@ declare class MiniKit {
373
406
  * @deprecated you should use MiniKit.user.walletAddress instead
374
407
  */
375
408
  static walletAddress: string | null;
376
- static user: {
377
- walletAddress: string | null;
378
- username: string | null;
379
- profilePictureUrl: string | null;
380
- } | null;
409
+ static user: User | null;
381
410
  private static sendInit;
382
411
  static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
383
412
  static unsubscribe(event: ResponseEvent): void;
@@ -386,6 +415,7 @@ declare class MiniKit {
386
415
  private static commandsValid;
387
416
  static install(appId?: string): MiniKitInstallReturnType;
388
417
  static isInstalled(debug?: boolean): boolean;
418
+ static getUserByAddress: (address: string) => Promise<User>;
389
419
  static commands: {
390
420
  verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
391
421
  pay: (payload: PayCommandInput) => PayCommandPayload | null;
@@ -394,6 +424,7 @@ declare class MiniKit {
394
424
  signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
395
425
  signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
396
426
  shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
427
+ requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
397
428
  };
398
429
  /**
399
430
  * This object contains async versions of all the commands.
@@ -413,21 +444,42 @@ declare class MiniKit {
413
444
  signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
414
445
  signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
415
446
  shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
447
+ requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
416
448
  };
417
449
  }
418
450
 
451
+ type SiweMessage = {
452
+ scheme?: string;
453
+ domain: string;
454
+ address?: string;
455
+ statement?: string;
456
+ uri: string;
457
+ version: number;
458
+ chain_id: number;
459
+ nonce: string;
460
+ issued_at: string;
461
+ expiration_time?: string;
462
+ not_before?: string;
463
+ request_id?: string;
464
+ };
465
+
419
466
  declare const tokenToDecimals: (amount: number, token: Tokens) => number;
420
467
 
421
468
  declare const parseSiweMessage: (inputString: string) => SiweMessage;
422
469
  declare const SAFE_CONTRACT_ABI: {
423
- name: string;
424
- type: string;
425
- stateMutability: string;
426
470
  inputs: {
471
+ internalType: string;
427
472
  name: string;
428
473
  type: string;
429
474
  }[];
430
- outputs: never[];
475
+ name: string;
476
+ outputs: {
477
+ internalType: string;
478
+ name: string;
479
+ type: string;
480
+ }[];
481
+ stateMutability: string;
482
+ type: string;
431
483
  }[];
432
484
  declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonce: string, statement?: string, requestId?: string, userProvider?: Client) => Promise<{
433
485
  isValid: boolean;
@@ -436,4 +488,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
436
488
 
437
489
  declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
438
490
 
439
- 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, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
491
+ 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 };