@worldcoin/minikit-js 1.8.0 → 1.9.1

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
@@ -129,6 +129,16 @@ declare const SendHapticFeedbackErrorMessage: {
129
129
  generic_error: string;
130
130
  user_rejected: string;
131
131
  };
132
+ declare enum ShareFilesErrorCodes {
133
+ UserRejected = "user_rejected",
134
+ GenericError = "generic_error",
135
+ InvalidFileName = "invalid_file_name"
136
+ }
137
+ declare const ShareFilesErrorMessage: {
138
+ user_rejected: string;
139
+ generic_error: string;
140
+ invalid_file_name: string;
141
+ };
132
142
 
133
143
  declare enum Tokens {
134
144
  USDCE = "USDCE",
@@ -196,7 +206,7 @@ type TokensPayload = {
196
206
  };
197
207
  type PayCommandInput = {
198
208
  reference: string;
199
- to: string;
209
+ to: `0x${string}` | string;
200
210
  tokens: TokensPayload[];
201
211
  network?: Network;
202
212
  description: string;
@@ -261,6 +271,15 @@ type SendHapticFeedbackInput = {
261
271
  style: 'light' | 'medium' | 'heavy';
262
272
  };
263
273
  type SendHapticFeedbackPayload = SendHapticFeedbackInput;
274
+ type ShareFile = {
275
+ url: string;
276
+ saved_file_name_with_extension: string;
277
+ };
278
+ type ShareFilesInput = {
279
+ files: ShareFile[];
280
+ mime_type: string;
281
+ };
282
+ type ShareFilesPayload = ShareFilesInput;
264
283
  type CommandReturnPayloadMap = {
265
284
  [Command.Verify]: VerifyCommandPayload;
266
285
  [Command.Pay]: PayCommandPayload;
@@ -285,7 +304,8 @@ declare enum ResponseEvent {
285
304
  MiniAppShareContacts = "miniapp-share-contacts",
286
305
  MiniAppRequestPermission = "miniapp-request-permission",
287
306
  MiniAppGetPermissions = "miniapp-get-permissions",
288
- MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback"
307
+ MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
308
+ MiniAppShareFiles = "miniapp-share-files"
289
309
  }
290
310
  type MiniAppVerifyActionSuccessPayload = {
291
311
  status: 'success';
@@ -433,6 +453,18 @@ type MiniAppSendHapticFeedbackErrorPayload = {
433
453
  version: number;
434
454
  };
435
455
  type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
456
+ type MiniAppShareFilesSuccessPayload = {
457
+ status: 'success';
458
+ shared_files_count: number;
459
+ version: number;
460
+ timestamp: string;
461
+ };
462
+ type MiniAppShareFilesErrorPayload = {
463
+ status: 'error';
464
+ error_code: ShareFilesErrorCodes;
465
+ version: number;
466
+ };
467
+ type MiniAppShareFilesPayload = MiniAppShareFilesSuccessPayload | MiniAppShareFilesErrorPayload;
436
468
  type EventPayloadMap = {
437
469
  [ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
438
470
  [ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
@@ -444,14 +476,27 @@ type EventPayloadMap = {
444
476
  [ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
445
477
  [ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
446
478
  [ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
479
+ [ResponseEvent.MiniAppShareFiles]: MiniAppShareFilesPayload;
447
480
  };
448
481
  type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
449
482
  type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
450
483
 
451
484
  type User = {
485
+ walletAddress?: string;
486
+ username?: string;
487
+ profilePictureUrl?: string;
488
+ permissions?: {
489
+ notifications: boolean;
490
+ contacts: boolean;
491
+ };
492
+ optedIntoOptionalAnalytics?: boolean;
493
+ worldAppVersion?: number;
494
+ deviceOS?: string;
495
+ };
496
+ type UserNameService = {
452
497
  walletAddress: string;
453
- username: string | null;
454
- profilePictureUrl: string | null;
498
+ username?: string;
499
+ profilePictureUrl?: string;
455
500
  };
456
501
 
457
502
  declare class MiniKit {
@@ -460,11 +505,8 @@ declare class MiniKit {
460
505
  private static isCommandAvailable;
461
506
  private static listeners;
462
507
  static appId: string | null;
463
- /**
464
- * @deprecated you should use MiniKit.user.walletAddress instead
465
- */
466
- static walletAddress: string | null;
467
- static user: User | null;
508
+ static user: User;
509
+ private static isReady;
468
510
  private static sendInit;
469
511
  static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
470
512
  static unsubscribe(event: ResponseEvent): void;
@@ -473,7 +515,9 @@ declare class MiniKit {
473
515
  private static commandsValid;
474
516
  static install(appId?: string): MiniKitInstallReturnType;
475
517
  static isInstalled(debug?: boolean): boolean;
476
- static getUserByAddress: (address: string) => Promise<User>;
518
+ static getUserByAddress: (address?: string) => Promise<UserNameService>;
519
+ static getUserByUsername: (username: string) => Promise<UserNameService>;
520
+ static getUserInfo: (address?: string) => Promise<UserNameService>;
477
521
  static commands: {
478
522
  verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
479
523
  pay: (payload: PayCommandInput) => PayCommandPayload | null;
@@ -516,7 +560,7 @@ type SiweMessage = {
516
560
  address?: string;
517
561
  statement?: string;
518
562
  uri: string;
519
- version: number;
563
+ version: string;
520
564
  chain_id: number;
521
565
  nonce: string;
522
566
  issued_at: string;
@@ -528,21 +572,6 @@ type SiweMessage = {
528
572
  declare const tokenToDecimals: (amount: number, token: Tokens) => number;
529
573
 
530
574
  declare const parseSiweMessage: (inputString: string) => SiweMessage;
531
- declare const SAFE_CONTRACT_ABI: {
532
- inputs: {
533
- internalType: string;
534
- name: string;
535
- type: string;
536
- }[];
537
- name: string;
538
- outputs: {
539
- internalType: string;
540
- name: string;
541
- type: string;
542
- }[];
543
- stateMutability: string;
544
- type: string;
545
- }[];
546
575
  declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonce: string, statement?: string, requestId?: string, userProvider?: Client) => Promise<{
547
576
  isValid: boolean;
548
577
  siweMessageData: SiweMessage;
@@ -550,4 +579,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
550
579
 
551
580
  declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
552
581
 
553
- export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, 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 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, type PermissionSettings, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SAFE_CONTRACT_ABI, SendHapticFeedbackErrorCodes, SendHapticFeedbackErrorMessage, type SendHapticFeedbackInput, type SendHapticFeedbackPayload, 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 };
582
+ export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, 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 MiniAppShareFilesErrorPayload, type MiniAppShareFilesPayload, type MiniAppShareFilesSuccessPayload, 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, type PermissionSettings, 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 ShareFilesInput, type ShareFilesPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, type User, type UserNameService, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };