@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.cjs CHANGED
@@ -34,13 +34,14 @@ __export(core_exports, {
34
34
  RequestPermissionErrorCodes: () => RequestPermissionErrorCodes,
35
35
  RequestPermissionErrorMessage: () => RequestPermissionErrorMessage,
36
36
  ResponseEvent: () => ResponseEvent,
37
- SAFE_CONTRACT_ABI: () => SAFE_CONTRACT_ABI,
38
37
  SendHapticFeedbackErrorCodes: () => SendHapticFeedbackErrorCodes,
39
38
  SendHapticFeedbackErrorMessage: () => SendHapticFeedbackErrorMessage,
40
39
  SendTransactionErrorCodes: () => SendTransactionErrorCodes,
41
40
  SendTransactionErrorMessage: () => SendTransactionErrorMessage,
42
41
  ShareContactsErrorCodes: () => ShareContactsErrorCodes,
43
42
  ShareContactsErrorMessage: () => ShareContactsErrorMessage,
43
+ ShareFilesErrorCodes: () => ShareFilesErrorCodes,
44
+ ShareFilesErrorMessage: () => ShareFilesErrorMessage,
44
45
  SignMessageErrorCodes: () => SignMessageErrorCodes,
45
46
  SignMessageErrorMessage: () => SignMessageErrorMessage,
46
47
  SignTypedDataErrorCodes: () => SignTypedDataErrorCodes,
@@ -177,6 +178,52 @@ var EXP_TAG = "Expiration Time: ";
177
178
  var NBF_TAG = "Not Before: ";
178
179
  var RID_TAG = "Request ID: ";
179
180
  var ERC_191_PREFIX = "Ethereum Signed Message:\n";
181
+ var EIP1271_MAGICVALUE = "0x1626ba7e";
182
+ var SAFE_CONTRACT_ABI = [
183
+ {
184
+ inputs: [
185
+ {
186
+ internalType: "address",
187
+ name: "owner",
188
+ type: "address"
189
+ }
190
+ ],
191
+ name: "isOwner",
192
+ outputs: [
193
+ {
194
+ internalType: "bool",
195
+ name: "",
196
+ type: "bool"
197
+ }
198
+ ],
199
+ stateMutability: "view",
200
+ type: "function"
201
+ },
202
+ {
203
+ inputs: [
204
+ {
205
+ internalType: "bytes32",
206
+ name: "_message",
207
+ type: "bytes32"
208
+ },
209
+ {
210
+ internalType: "bytes",
211
+ name: "_signature",
212
+ type: "bytes"
213
+ }
214
+ ],
215
+ name: "isValidSignature",
216
+ outputs: [
217
+ {
218
+ internalType: "bytes4",
219
+ name: "",
220
+ type: "bytes4"
221
+ }
222
+ ],
223
+ stateMutability: "view",
224
+ type: "function"
225
+ }
226
+ ];
180
227
  var tagged = (line, tag) => {
181
228
  if (line && line.includes(tag)) {
182
229
  return line.replace(tag, "");
@@ -273,33 +320,26 @@ var generateSiweMessage = (siweMessageData) => {
273
320
  }
274
321
  return siweMessage;
275
322
  };
276
- var SAFE_CONTRACT_ABI = [
277
- {
278
- inputs: [
279
- {
280
- internalType: "address",
281
- name: "owner",
282
- type: "address"
283
- }
284
- ],
285
- name: "isOwner",
286
- outputs: [
287
- {
288
- internalType: "bool",
289
- name: "",
290
- type: "bool"
291
- }
292
- ],
293
- stateMutability: "view",
294
- type: "function"
295
- }
296
- ];
297
- var verifySiweMessage = async (payload, nonce, statement, requestId, userProvider) => {
298
- if (typeof window !== "undefined") {
299
- throw new Error("Verify can only be called in the backend");
323
+ var verifySiweMessage = (payload, nonce, statement, requestId, userProvider) => {
324
+ if (payload.version === 2) {
325
+ return verifySiweMessageV2(
326
+ payload,
327
+ nonce,
328
+ statement,
329
+ requestId,
330
+ userProvider
331
+ );
332
+ } else {
333
+ return verifySiweMessageV1(
334
+ payload,
335
+ nonce,
336
+ statement,
337
+ requestId,
338
+ userProvider
339
+ );
300
340
  }
301
- const { message, signature, address } = payload;
302
- const siweMessageData = parseSiweMessage(message);
341
+ };
342
+ var validateMessage = (siweMessageData, nonce, statement, requestId) => {
303
343
  if (siweMessageData.expiration_time) {
304
344
  const expirationTime = new Date(siweMessageData.expiration_time);
305
345
  if (expirationTime < /* @__PURE__ */ new Date()) {
@@ -327,6 +367,15 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
327
367
  `Request ID mismatch. Got: ${siweMessageData.request_id}, Expected: ${requestId}`
328
368
  );
329
369
  }
370
+ return true;
371
+ };
372
+ var verifySiweMessageV1 = async (payload, nonce, statement, requestId, userProvider) => {
373
+ if (typeof window !== "undefined") {
374
+ throw new Error("Wallet auth payload can only be verified in the backend");
375
+ }
376
+ const { message, signature, address } = payload;
377
+ const siweMessageData = parseSiweMessage(message);
378
+ validateMessage(siweMessageData, nonce, statement, requestId);
330
379
  let provider = userProvider || (0, import_viem2.createPublicClient)({ chain: import_chains2.worldchain, transport: (0, import_viem2.http)() });
331
380
  const signedMessage = `${ERC_191_PREFIX}${message.length}${message}`;
332
381
  const hashedMessage = (0, import_viem2.hashMessage)(signedMessage);
@@ -349,6 +398,35 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
349
398
  }
350
399
  return { isValid: true, siweMessageData };
351
400
  };
401
+ var verifySiweMessageV2 = async (payload, nonce, statement, requestId, userProvider) => {
402
+ if (typeof window !== "undefined") {
403
+ throw new Error("Wallet auth payload can only be verified in the backend");
404
+ }
405
+ const { message, signature, address } = payload;
406
+ const siweMessageData = parseSiweMessage(message);
407
+ if (!validateMessage(siweMessageData, nonce, statement, requestId)) {
408
+ throw new Error("Validation failed");
409
+ }
410
+ try {
411
+ const walletContract = (0, import_viem2.getContract)({
412
+ address,
413
+ abi: SAFE_CONTRACT_ABI,
414
+ client: userProvider || (0, import_viem2.createPublicClient)({ chain: import_chains2.worldchain, transport: (0, import_viem2.http)() })
415
+ });
416
+ const hashedMessage = (0, import_viem2.hashMessage)(message);
417
+ const res = await walletContract.read.isValidSignature([
418
+ hashedMessage,
419
+ signature
420
+ ]);
421
+ return {
422
+ isValid: res === EIP1271_MAGICVALUE,
423
+ siweMessageData
424
+ };
425
+ } catch (error) {
426
+ console.log(error);
427
+ throw new Error("Signature verification failed");
428
+ }
429
+ };
352
430
 
353
431
  // helpers/siwe/validate-wallet-auth-command-input.ts
354
432
  var validateWalletAuthCommandInput = (params) => {
@@ -428,7 +506,7 @@ var getUserProfile = async (address) => {
428
506
  })
429
507
  });
430
508
  const usernames = await res.json();
431
- return usernames?.[0] ?? { username: null, profilePictureUrl: null };
509
+ return usernames?.[0] ?? { username: null, profile_picture_url: null };
432
510
  };
433
511
 
434
512
  // types/commands.ts
@@ -624,6 +702,17 @@ var SendHapticFeedbackErrorMessage = {
624
702
  ["generic_error" /* GenericError */]: "Something unexpected went wrong.",
625
703
  ["user_rejected" /* UserRejected */]: "User rejected the request."
626
704
  };
705
+ var ShareFilesErrorCodes = /* @__PURE__ */ ((ShareFilesErrorCodes2) => {
706
+ ShareFilesErrorCodes2["UserRejected"] = "user_rejected";
707
+ ShareFilesErrorCodes2["GenericError"] = "generic_error";
708
+ ShareFilesErrorCodes2["InvalidFileName"] = "invalid_file_name";
709
+ return ShareFilesErrorCodes2;
710
+ })(ShareFilesErrorCodes || {});
711
+ var ShareFilesErrorMessage = {
712
+ ["user_rejected" /* UserRejected */]: "User rejected the request.",
713
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong.",
714
+ ["invalid_file_name" /* InvalidFileName */]: "Invalid file name. Make sure you include the extension"
715
+ };
627
716
 
628
717
  // helpers/send-webview-event.ts
629
718
  var sendWebviewEvent = (payload) => {
@@ -646,6 +735,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
646
735
  ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
647
736
  ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
648
737
  ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
738
+ ResponseEvent2["MiniAppShareFiles"] = "miniapp-share-files";
649
739
  return ResponseEvent2;
650
740
  })(ResponseEvent || {});
651
741
 
@@ -663,12 +753,15 @@ var _MiniKit = class _MiniKit {
663
753
  static subscribe(event, handler) {
664
754
  if (event === "miniapp-wallet-auth" /* MiniAppWalletAuth */) {
665
755
  const originalHandler = handler;
666
- const wrappedHandler = (payload) => {
756
+ const wrappedHandler = async (payload) => {
667
757
  if (payload.status === "success") {
668
- _MiniKit.walletAddress = payload.address;
669
- _MiniKit.getUserByAddress(payload.address).then((user) => {
670
- _MiniKit.user = user;
671
- });
758
+ _MiniKit.user.walletAddress = payload.address;
759
+ try {
760
+ const user = await _MiniKit.getUserByAddress(payload.address);
761
+ _MiniKit.user = { ..._MiniKit.user, ...user };
762
+ } catch (error) {
763
+ console.error("Failed to fetch user profile:", error);
764
+ }
672
765
  }
673
766
  originalHandler(payload);
674
767
  };
@@ -697,7 +790,9 @@ var _MiniKit = class _MiniKit {
697
790
  }
698
791
  static trigger(event, payload) {
699
792
  if (!this.listeners[event]) {
700
- console.error(`No handler for event ${event}`);
793
+ console.error(
794
+ `No handler for event ${event}, payload: ${JSON.stringify(payload)}`
795
+ );
701
796
  return;
702
797
  }
703
798
  this.listeners[event](payload);
@@ -714,21 +809,34 @@ var _MiniKit = class _MiniKit {
714
809
  });
715
810
  }
716
811
  static commandsValid(worldAppSupportedCommands) {
717
- return Object.entries(this.miniKitCommandVersion).every(
812
+ let allCommandsValid = true;
813
+ Object.entries(this.miniKitCommandVersion).forEach(
718
814
  ([minikitCommandName, version]) => {
719
815
  const commandInput = worldAppSupportedCommands.find(
720
816
  (command) => command.name === minikitCommandName
721
817
  );
818
+ let isCommandValid = false;
722
819
  if (!commandInput) {
723
820
  console.error(
724
821
  `Command ${minikitCommandName} is not supported by the app. Try updating the app version`
725
822
  );
726
823
  } else {
727
- _MiniKit.isCommandAvailable[minikitCommandName] = true;
824
+ if (commandInput.supported_versions.includes(version)) {
825
+ _MiniKit.isCommandAvailable[minikitCommandName] = true;
826
+ isCommandValid = true;
827
+ } else {
828
+ console.error(
829
+ `Command ${minikitCommandName} version ${version} is not supported by the app. Supported versions: ${commandInput.supported_versions.join(", ")}`
830
+ );
831
+ _MiniKit.isCommandAvailable[minikitCommandName] = isCommandValid;
832
+ }
833
+ }
834
+ if (!isCommandValid) {
835
+ allCommandsValid = false;
728
836
  }
729
- return commandInput ? commandInput.supported_versions.includes(version) : false;
730
837
  }
731
838
  );
839
+ return allCommandsValid;
732
840
  }
733
841
  static install(appId) {
734
842
  if (typeof window === "undefined" || Boolean(window.MiniKit)) {
@@ -750,6 +858,9 @@ var _MiniKit = class _MiniKit {
750
858
  errorMessage: MiniKitInstallErrorMessage["outside_of_worldapp" /* OutsideOfWorldApp */]
751
859
  };
752
860
  }
861
+ _MiniKit.user.optedIntoOptionalAnalytics = window.WorldApp.is_optional_analytics;
862
+ _MiniKit.user.deviceOS = window.WorldApp.device_os;
863
+ _MiniKit.user.worldAppVersion = window.WorldApp.world_app_version;
753
864
  try {
754
865
  window.MiniKit = _MiniKit;
755
866
  this.sendInit();
@@ -771,15 +882,16 @@ var _MiniKit = class _MiniKit {
771
882
  errorMessage: MiniKitInstallErrorMessage["app_out_of_date" /* AppOutOfDate */]
772
883
  };
773
884
  }
885
+ _MiniKit.isReady = true;
774
886
  return { success: true };
775
887
  }
776
888
  static isInstalled(debug) {
777
- if (debug) console.log("MiniKit is alive!");
778
- const isInstalled = Boolean(window.MiniKit);
889
+ const isInstalled = _MiniKit.isReady && Boolean(window.MiniKit);
779
890
  if (!isInstalled)
780
891
  console.error(
781
892
  "MiniKit is not installed. Make sure you're running the application inside of World App"
782
893
  );
894
+ if (debug && isInstalled) console.log("MiniKit is alive!");
783
895
  return isInstalled;
784
896
  }
785
897
  };
@@ -795,6 +907,7 @@ _MiniKit.miniKitCommandVersion = {
795
907
  ["request-permission" /* RequestPermission */]: 1,
796
908
  ["get-permissions" /* GetPermissions */]: 1,
797
909
  ["send-haptic-feedback" /* SendHapticFeedback */]: 1
910
+ // [Command.ShareFiles]: 1,
798
911
  };
799
912
  _MiniKit.isCommandAvailable = {
800
913
  ["verify" /* Verify */]: false,
@@ -807,6 +920,7 @@ _MiniKit.isCommandAvailable = {
807
920
  ["request-permission" /* RequestPermission */]: false,
808
921
  ["get-permissions" /* GetPermissions */]: false,
809
922
  ["send-haptic-feedback" /* SendHapticFeedback */]: false
923
+ // [Command.ShareFiles]: false,
810
924
  };
811
925
  _MiniKit.listeners = {
812
926
  ["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
@@ -828,22 +942,42 @@ _MiniKit.listeners = {
828
942
  ["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
829
943
  },
830
944
  ["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
945
+ },
946
+ ["miniapp-share-files" /* MiniAppShareFiles */]: () => {
831
947
  }
832
948
  };
833
949
  _MiniKit.appId = null;
834
- /**
835
- * @deprecated you should use MiniKit.user.walletAddress instead
836
- */
837
- _MiniKit.walletAddress = null;
838
- _MiniKit.user = null;
950
+ _MiniKit.user = {};
951
+ _MiniKit.isReady = false;
839
952
  _MiniKit.getUserByAddress = async (address) => {
840
- const userProfile = await getUserProfile(address);
953
+ const userProfile = await getUserProfile(
954
+ address ?? _MiniKit.user.walletAddress
955
+ );
841
956
  return {
842
- walletAddress: address,
957
+ walletAddress: address ?? _MiniKit.user.walletAddress,
843
958
  username: userProfile.username,
844
- profilePictureUrl: userProfile.profilePictureUrl
959
+ profilePictureUrl: userProfile.profile_picture_url
960
+ };
961
+ };
962
+ _MiniKit.getUserByUsername = async (username) => {
963
+ const res = await fetch(
964
+ `https://usernames.worldcoin.org/api/v1/${username}`,
965
+ {
966
+ method: "GET",
967
+ headers: {
968
+ "Content-Type": "application/json"
969
+ }
970
+ }
971
+ );
972
+ const user = await res.json();
973
+ return {
974
+ walletAddress: user.address,
975
+ username: user.username,
976
+ profilePictureUrl: user.profile_picture_url
845
977
  };
846
978
  };
979
+ // Simply re-exporting the existing function
980
+ _MiniKit.getUserInfo = _MiniKit.getUserByAddress;
847
981
  _MiniKit.commands = {
848
982
  verify: (payload) => {
849
983
  if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["verify" /* Verify */]) {
@@ -876,10 +1010,9 @@ _MiniKit.commands = {
876
1010
  if (!validatePaymentPayload(payload)) {
877
1011
  return null;
878
1012
  }
879
- const network = "worldchain" /* WorldChain */;
880
1013
  const eventPayload = {
881
1014
  ...payload,
882
- network
1015
+ network: "worldchain" /* WorldChain */
883
1016
  };
884
1017
  sendMiniKitEvent({
885
1018
  command: "pay" /* Pay */,
@@ -916,7 +1049,7 @@ _MiniKit.commands = {
916
1049
  domain: window.location.host,
917
1050
  statement: payload.statement ?? void 0,
918
1051
  uri: window.location.href,
919
- version: 1,
1052
+ version: "1",
920
1053
  chain_id: 480,
921
1054
  nonce: payload.nonce,
922
1055
  issued_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1033,6 +1166,23 @@ _MiniKit.commands = {
1033
1166
  });
1034
1167
  return payload;
1035
1168
  }
1169
+ // shareFiles: (payload: ShareFilesInput): ShareFilesPayload | null => {
1170
+ // if (
1171
+ // typeof window === 'undefined' ||
1172
+ // !this.isCommandAvailable[Command.ShareFiles]
1173
+ // ) {
1174
+ // console.error(
1175
+ // "'shareFiles' command is unavailable. Check MiniKit.install() or update the app version",
1176
+ // );
1177
+ // return null;
1178
+ // }
1179
+ // sendMiniKitEvent<WebViewBasePayload>({
1180
+ // command: Command.ShareFiles,
1181
+ // version: this.miniKitCommandVersion[Command.ShareFiles],
1182
+ // payload,
1183
+ // });
1184
+ // return payload;
1185
+ // },
1036
1186
  };
1037
1187
  /**
1038
1188
  * This object contains async versions of all the commands.
@@ -1190,6 +1340,25 @@ _MiniKit.commandsAsync = {
1190
1340
  }
1191
1341
  });
1192
1342
  }
1343
+ // shareFiles: async (
1344
+ // payload: ShareFilesInput,
1345
+ // ): AsyncHandlerReturn<
1346
+ // ShareFilesPayload | null,
1347
+ // MiniAppShareFilesPayload
1348
+ // > => {
1349
+ // return new Promise(async (resolve, reject) => {
1350
+ // try {
1351
+ // const response = await MiniKit.awaitCommand(
1352
+ // ResponseEvent.MiniAppShareFiles,
1353
+ // Command.ShareFiles,
1354
+ // () => this.commands.shareFiles(payload),
1355
+ // );
1356
+ // resolve(response);
1357
+ // } catch (error) {
1358
+ // reject(error);
1359
+ // }
1360
+ // });
1361
+ // },
1193
1362
  };
1194
1363
  var MiniKit = _MiniKit;
1195
1364
 
@@ -1264,13 +1433,14 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
1264
1433
  RequestPermissionErrorCodes,
1265
1434
  RequestPermissionErrorMessage,
1266
1435
  ResponseEvent,
1267
- SAFE_CONTRACT_ABI,
1268
1436
  SendHapticFeedbackErrorCodes,
1269
1437
  SendHapticFeedbackErrorMessage,
1270
1438
  SendTransactionErrorCodes,
1271
1439
  SendTransactionErrorMessage,
1272
1440
  ShareContactsErrorCodes,
1273
1441
  ShareContactsErrorMessage,
1442
+ ShareFilesErrorCodes,
1443
+ ShareFilesErrorMessage,
1274
1444
  SignMessageErrorCodes,
1275
1445
  SignMessageErrorMessage,
1276
1446
  SignTypedDataErrorCodes,
package/build/index.d.cts 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 };