@worldcoin/minikit-js 1.9.7 → 1.9.9

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.
@@ -193,6 +193,17 @@ var MicrophoneErrorMessage = {
193
193
  ["mini_app_permission_not_enabled" /* MiniAppPermissionNotEnabled */]: "Microphone permission not enabled for your Mini App",
194
194
  ["world_app_permission_not_enabled" /* WorldAppPermissionNotEnabled */]: "Microphone permission not enabled in World App"
195
195
  };
196
+ var ChatErrorCodes = /* @__PURE__ */ ((ChatErrorCodes2) => {
197
+ ChatErrorCodes2["UserRejected"] = "user_rejected";
198
+ ChatErrorCodes2["SendFailed"] = "send_failed";
199
+ ChatErrorCodes2["GenericError"] = "generic_error";
200
+ return ChatErrorCodes2;
201
+ })(ChatErrorCodes || {});
202
+ var ChatErrorMessage = {
203
+ ["user_rejected" /* UserRejected */]: "User rejected the request.",
204
+ ["send_failed" /* SendFailed */]: "Failed to send the message.",
205
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong."
206
+ };
196
207
 
197
208
  // types/responses.ts
198
209
  var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
@@ -208,6 +219,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
208
219
  ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
209
220
  ResponseEvent2["MiniAppShare"] = "miniapp-share";
210
221
  ResponseEvent2["MiniAppMicrophone"] = "miniapp-microphone";
222
+ ResponseEvent2["MiniAppChat"] = "miniapp-chat";
211
223
  return ResponseEvent2;
212
224
  })(ResponseEvent || {});
213
225
 
@@ -539,6 +551,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
539
551
  Command2["GetPermissions"] = "get-permissions";
540
552
  Command2["SendHapticFeedback"] = "send-haptic-feedback";
541
553
  Command2["Share"] = "share";
554
+ Command2["Chat"] = "chat";
542
555
  return Command2;
543
556
  })(Command || {});
544
557
  var Permission = /* @__PURE__ */ ((Permission2) => {
@@ -548,6 +561,32 @@ var Permission = /* @__PURE__ */ ((Permission2) => {
548
561
  return Permission2;
549
562
  })(Permission || {});
550
563
 
564
+ // types/init.ts
565
+ var MiniAppLaunchLocation = /* @__PURE__ */ ((MiniAppLaunchLocation3) => {
566
+ MiniAppLaunchLocation3["Chat"] = "chat";
567
+ MiniAppLaunchLocation3["Home"] = "home";
568
+ MiniAppLaunchLocation3["AppStore"] = "app-store";
569
+ MiniAppLaunchLocation3["DeepLink"] = "deep-link";
570
+ MiniAppLaunchLocation3["WalletTab"] = "wallet-tab";
571
+ return MiniAppLaunchLocation3;
572
+ })(MiniAppLaunchLocation || {});
573
+ var WORLD_APP_LAUNCH_LOCATION_MAP = {
574
+ "app-store": "app-store" /* AppStore */,
575
+ carousel: "app-store" /* AppStore */,
576
+ explore: "app-store" /* AppStore */,
577
+ app_details: "app-store" /* AppStore */,
578
+ deeplink: "deep-link" /* DeepLink */,
579
+ homepage: "home" /* Home */,
580
+ wallet_tab: "wallet-tab" /* WalletTab */,
581
+ world_chat: "chat" /* Chat */
582
+ };
583
+ var mapWorldAppLaunchLocation = (location) => {
584
+ if (!location || typeof location !== "string") return null;
585
+ console.log("MiniKit launch location mapped:", location);
586
+ const normalizedLocation = location.toLowerCase();
587
+ return WORLD_APP_LAUNCH_LOCATION_MAP[normalizedLocation] ?? null;
588
+ };
589
+
551
590
  // minikit.ts
552
591
  import { VerificationLevel } from "@worldcoin/idkit-core";
553
592
  import { encodeAction, generateSignal } from "@worldcoin/idkit-core/hashing";
@@ -901,6 +940,9 @@ var _MiniKit = class _MiniKit {
901
940
  } else if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
902
941
  const originalHandler = handler;
903
942
  const wrappedHandler = (payload) => {
943
+ if (payload.status === "error" && payload.error_code == "user_rejected") {
944
+ payload.error_code = AppErrorCodes2.VerificationRejected;
945
+ }
904
946
  if (payload.status === "success" && payload.verification_level === VerificationLevel.Orb) {
905
947
  compressAndPadProof(payload.proof).then(
906
948
  (compressedProof) => {
@@ -997,6 +1039,7 @@ var _MiniKit = class _MiniKit {
997
1039
  _MiniKit.deviceProperties.safeAreaInsets = window.WorldApp.safe_area_insets;
998
1040
  _MiniKit.deviceProperties.deviceOS = window.WorldApp.device_os;
999
1041
  _MiniKit.deviceProperties.worldAppVersion = window.WorldApp.world_app_version;
1042
+ _MiniKit.location = mapWorldAppLaunchLocation(window.WorldApp.location);
1000
1043
  try {
1001
1044
  window.MiniKit = _MiniKit;
1002
1045
  this.sendInit();
@@ -1045,7 +1088,8 @@ _MiniKit.miniKitCommandVersion = {
1045
1088
  ["request-permission" /* RequestPermission */]: 1,
1046
1089
  ["get-permissions" /* GetPermissions */]: 1,
1047
1090
  ["send-haptic-feedback" /* SendHapticFeedback */]: 1,
1048
- ["share" /* Share */]: 1
1091
+ ["share" /* Share */]: 1,
1092
+ ["chat" /* Chat */]: 1
1049
1093
  };
1050
1094
  _MiniKit.isCommandAvailable = {
1051
1095
  ["verify" /* Verify */]: false,
@@ -1058,7 +1102,8 @@ _MiniKit.isCommandAvailable = {
1058
1102
  ["request-permission" /* RequestPermission */]: false,
1059
1103
  ["get-permissions" /* GetPermissions */]: false,
1060
1104
  ["send-haptic-feedback" /* SendHapticFeedback */]: false,
1061
- ["share" /* Share */]: false
1105
+ ["share" /* Share */]: false,
1106
+ ["chat" /* Chat */]: false
1062
1107
  };
1063
1108
  _MiniKit.listeners = {
1064
1109
  ["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
@@ -1084,11 +1129,14 @@ _MiniKit.listeners = {
1084
1129
  ["miniapp-share" /* MiniAppShare */]: () => {
1085
1130
  },
1086
1131
  ["miniapp-microphone" /* MiniAppMicrophone */]: () => {
1132
+ },
1133
+ ["miniapp-chat" /* MiniAppChat */]: () => {
1087
1134
  }
1088
1135
  };
1089
1136
  _MiniKit.appId = null;
1090
1137
  _MiniKit.user = {};
1091
1138
  _MiniKit.deviceProperties = {};
1139
+ _MiniKit.location = null;
1092
1140
  _MiniKit.isReady = false;
1093
1141
  _MiniKit.getUserByAddress = async (address) => {
1094
1142
  const userProfile = await getUserProfile(
@@ -1117,6 +1165,35 @@ _MiniKit.getUserByUsername = async (username) => {
1117
1165
  profilePictureUrl: user.profile_picture_url
1118
1166
  };
1119
1167
  };
1168
+ // This is a helper function for developers to generate MiniApp URLs
1169
+ _MiniKit.getMiniAppUrl = (appId, path) => {
1170
+ const baseUrl = new URL("https://world.org/mini-app");
1171
+ baseUrl.searchParams.append("app_id", appId);
1172
+ if (path) {
1173
+ const fullPath = path.startsWith("/") ? path : `/${path}`;
1174
+ baseUrl.searchParams.append("path", encodeURIComponent(fullPath));
1175
+ }
1176
+ return baseUrl.toString();
1177
+ };
1178
+ // Opens the profile card for a given username or wallet address
1179
+ _MiniKit.showProfileCard = (username, walletAddress) => {
1180
+ if (!username && !walletAddress) {
1181
+ console.error(
1182
+ "Either username or walletAddress must be provided to show profile card"
1183
+ );
1184
+ return;
1185
+ }
1186
+ if (username) {
1187
+ window.open(
1188
+ `worldapp://profile?username=${encodeURIComponent(username)}`
1189
+ );
1190
+ return;
1191
+ } else {
1192
+ window.open(
1193
+ `worldapp://profile?address=${encodeURIComponent(walletAddress || "")}`
1194
+ );
1195
+ }
1196
+ };
1120
1197
  // Simply re-exporting the existing function
1121
1198
  _MiniKit.getUserInfo = _MiniKit.getUserByAddress;
1122
1199
  _MiniKit.commands = {
@@ -1342,6 +1419,24 @@ _MiniKit.commands = {
1342
1419
  });
1343
1420
  }
1344
1421
  return payload;
1422
+ },
1423
+ chat: (payload) => {
1424
+ if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["chat" /* Chat */]) {
1425
+ console.error(
1426
+ "'chat' command is unavailable. Check MiniKit.install() or update the app version"
1427
+ );
1428
+ return null;
1429
+ }
1430
+ if (payload.message.length === 0) {
1431
+ console.error("'chat' command requires a non-empty message");
1432
+ return null;
1433
+ }
1434
+ sendMiniKitEvent({
1435
+ command: "chat" /* Chat */,
1436
+ version: _MiniKit.miniKitCommandVersion["chat" /* Chat */],
1437
+ payload
1438
+ });
1439
+ return payload;
1345
1440
  }
1346
1441
  };
1347
1442
  /**
@@ -1516,6 +1611,23 @@ _MiniKit.commandsAsync = {
1516
1611
  reject(error);
1517
1612
  }
1518
1613
  });
1614
+ },
1615
+ chat: async (payload) => {
1616
+ return new Promise(async (resolve, reject) => {
1617
+ try {
1618
+ const response = await _MiniKit.awaitCommand(
1619
+ "miniapp-chat" /* MiniAppChat */,
1620
+ "chat" /* Chat */,
1621
+ () => _MiniKit.commands.chat(payload)
1622
+ );
1623
+ resolve({
1624
+ commandPayload: response.commandPayload,
1625
+ finalPayload: response.finalPayload
1626
+ });
1627
+ } catch (error) {
1628
+ reject(error);
1629
+ }
1630
+ });
1519
1631
  }
1520
1632
  };
1521
1633
  var MiniKit = _MiniKit;
@@ -1547,6 +1659,8 @@ export {
1547
1659
  ShareFilesErrorMessage,
1548
1660
  MicrophoneErrorCodes,
1549
1661
  MicrophoneErrorMessage,
1662
+ ChatErrorCodes,
1663
+ ChatErrorMessage,
1550
1664
  AppErrorCodes2 as AppErrorCodes,
1551
1665
  ResponseEvent,
1552
1666
  Tokens,
@@ -1557,5 +1671,7 @@ export {
1557
1671
  verifySiweMessage,
1558
1672
  Command,
1559
1673
  Permission,
1674
+ MiniAppLaunchLocation,
1675
+ mapWorldAppLaunchLocation,
1560
1676
  MiniKit
1561
1677
  };
package/build/index.cjs CHANGED
@@ -20,11 +20,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // index.ts
21
21
  var core_exports = {};
22
22
  __export(core_exports, {
23
+ ChatErrorCodes: () => ChatErrorCodes,
24
+ ChatErrorMessage: () => ChatErrorMessage,
23
25
  Command: () => Command,
24
26
  GetPermissionsErrorCodes: () => GetPermissionsErrorCodes,
25
27
  GetPermissionsErrorMessage: () => GetPermissionsErrorMessage,
26
28
  MicrophoneErrorCodes: () => MicrophoneErrorCodes,
27
29
  MicrophoneErrorMessage: () => MicrophoneErrorMessage,
30
+ MiniAppLaunchLocation: () => MiniAppLaunchLocation,
28
31
  MiniKit: () => MiniKit,
29
32
  MiniKitInstallErrorCodes: () => MiniKitInstallErrorCodes,
30
33
  MiniKitInstallErrorMessage: () => MiniKitInstallErrorMessage,
@@ -56,6 +59,7 @@ __export(core_exports, {
56
59
  WalletAuthErrorCodes: () => WalletAuthErrorCodes,
57
60
  WalletAuthErrorMessage: () => WalletAuthErrorMessage,
58
61
  getIsUserVerified: () => getIsUserVerified,
62
+ mapWorldAppLaunchLocation: () => mapWorldAppLaunchLocation,
59
63
  parseSiweMessage: () => parseSiweMessage,
60
64
  tokenToDecimals: () => tokenToDecimals,
61
65
  verifyCloudProof: () => import_backend.verifyCloudProof,
@@ -271,6 +275,17 @@ var MicrophoneErrorMessage = {
271
275
  ["mini_app_permission_not_enabled" /* MiniAppPermissionNotEnabled */]: "Microphone permission not enabled for your Mini App",
272
276
  ["world_app_permission_not_enabled" /* WorldAppPermissionNotEnabled */]: "Microphone permission not enabled in World App"
273
277
  };
278
+ var ChatErrorCodes = /* @__PURE__ */ ((ChatErrorCodes2) => {
279
+ ChatErrorCodes2["UserRejected"] = "user_rejected";
280
+ ChatErrorCodes2["SendFailed"] = "send_failed";
281
+ ChatErrorCodes2["GenericError"] = "generic_error";
282
+ return ChatErrorCodes2;
283
+ })(ChatErrorCodes || {});
284
+ var ChatErrorMessage = {
285
+ ["user_rejected" /* UserRejected */]: "User rejected the request.",
286
+ ["send_failed" /* SendFailed */]: "Failed to send the message.",
287
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong."
288
+ };
274
289
 
275
290
  // types/responses.ts
276
291
  var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
@@ -286,6 +301,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
286
301
  ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
287
302
  ResponseEvent2["MiniAppShare"] = "miniapp-share";
288
303
  ResponseEvent2["MiniAppMicrophone"] = "miniapp-microphone";
304
+ ResponseEvent2["MiniAppChat"] = "miniapp-chat";
289
305
  return ResponseEvent2;
290
306
  })(ResponseEvent || {});
291
307
 
@@ -913,6 +929,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
913
929
  Command2["GetPermissions"] = "get-permissions";
914
930
  Command2["SendHapticFeedback"] = "send-haptic-feedback";
915
931
  Command2["Share"] = "share";
932
+ Command2["Chat"] = "chat";
916
933
  return Command2;
917
934
  })(Command || {});
918
935
  var Permission = /* @__PURE__ */ ((Permission2) => {
@@ -922,6 +939,32 @@ var Permission = /* @__PURE__ */ ((Permission2) => {
922
939
  return Permission2;
923
940
  })(Permission || {});
924
941
 
942
+ // types/init.ts
943
+ var MiniAppLaunchLocation = /* @__PURE__ */ ((MiniAppLaunchLocation3) => {
944
+ MiniAppLaunchLocation3["Chat"] = "chat";
945
+ MiniAppLaunchLocation3["Home"] = "home";
946
+ MiniAppLaunchLocation3["AppStore"] = "app-store";
947
+ MiniAppLaunchLocation3["DeepLink"] = "deep-link";
948
+ MiniAppLaunchLocation3["WalletTab"] = "wallet-tab";
949
+ return MiniAppLaunchLocation3;
950
+ })(MiniAppLaunchLocation || {});
951
+ var WORLD_APP_LAUNCH_LOCATION_MAP = {
952
+ "app-store": "app-store" /* AppStore */,
953
+ carousel: "app-store" /* AppStore */,
954
+ explore: "app-store" /* AppStore */,
955
+ app_details: "app-store" /* AppStore */,
956
+ deeplink: "deep-link" /* DeepLink */,
957
+ homepage: "home" /* Home */,
958
+ wallet_tab: "wallet-tab" /* WalletTab */,
959
+ world_chat: "chat" /* Chat */
960
+ };
961
+ var mapWorldAppLaunchLocation = (location) => {
962
+ if (!location || typeof location !== "string") return null;
963
+ console.log("MiniKit launch location mapped:", location);
964
+ const normalizedLocation = location.toLowerCase();
965
+ return WORLD_APP_LAUNCH_LOCATION_MAP[normalizedLocation] ?? null;
966
+ };
967
+
925
968
  // minikit.ts
926
969
  var sendMiniKitEvent = (payload) => {
927
970
  sendWebviewEvent(payload);
@@ -955,6 +998,9 @@ var _MiniKit = class _MiniKit {
955
998
  } else if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
956
999
  const originalHandler = handler;
957
1000
  const wrappedHandler = (payload) => {
1001
+ if (payload.status === "error" && payload.error_code == "user_rejected") {
1002
+ payload.error_code = import_idkit_core2.AppErrorCodes.VerificationRejected;
1003
+ }
958
1004
  if (payload.status === "success" && payload.verification_level === import_idkit_core3.VerificationLevel.Orb) {
959
1005
  compressAndPadProof(payload.proof).then(
960
1006
  (compressedProof) => {
@@ -1051,6 +1097,7 @@ var _MiniKit = class _MiniKit {
1051
1097
  _MiniKit.deviceProperties.safeAreaInsets = window.WorldApp.safe_area_insets;
1052
1098
  _MiniKit.deviceProperties.deviceOS = window.WorldApp.device_os;
1053
1099
  _MiniKit.deviceProperties.worldAppVersion = window.WorldApp.world_app_version;
1100
+ _MiniKit.location = mapWorldAppLaunchLocation(window.WorldApp.location);
1054
1101
  try {
1055
1102
  window.MiniKit = _MiniKit;
1056
1103
  this.sendInit();
@@ -1099,7 +1146,8 @@ _MiniKit.miniKitCommandVersion = {
1099
1146
  ["request-permission" /* RequestPermission */]: 1,
1100
1147
  ["get-permissions" /* GetPermissions */]: 1,
1101
1148
  ["send-haptic-feedback" /* SendHapticFeedback */]: 1,
1102
- ["share" /* Share */]: 1
1149
+ ["share" /* Share */]: 1,
1150
+ ["chat" /* Chat */]: 1
1103
1151
  };
1104
1152
  _MiniKit.isCommandAvailable = {
1105
1153
  ["verify" /* Verify */]: false,
@@ -1112,7 +1160,8 @@ _MiniKit.isCommandAvailable = {
1112
1160
  ["request-permission" /* RequestPermission */]: false,
1113
1161
  ["get-permissions" /* GetPermissions */]: false,
1114
1162
  ["send-haptic-feedback" /* SendHapticFeedback */]: false,
1115
- ["share" /* Share */]: false
1163
+ ["share" /* Share */]: false,
1164
+ ["chat" /* Chat */]: false
1116
1165
  };
1117
1166
  _MiniKit.listeners = {
1118
1167
  ["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
@@ -1138,11 +1187,14 @@ _MiniKit.listeners = {
1138
1187
  ["miniapp-share" /* MiniAppShare */]: () => {
1139
1188
  },
1140
1189
  ["miniapp-microphone" /* MiniAppMicrophone */]: () => {
1190
+ },
1191
+ ["miniapp-chat" /* MiniAppChat */]: () => {
1141
1192
  }
1142
1193
  };
1143
1194
  _MiniKit.appId = null;
1144
1195
  _MiniKit.user = {};
1145
1196
  _MiniKit.deviceProperties = {};
1197
+ _MiniKit.location = null;
1146
1198
  _MiniKit.isReady = false;
1147
1199
  _MiniKit.getUserByAddress = async (address) => {
1148
1200
  const userProfile = await getUserProfile(
@@ -1171,6 +1223,35 @@ _MiniKit.getUserByUsername = async (username) => {
1171
1223
  profilePictureUrl: user.profile_picture_url
1172
1224
  };
1173
1225
  };
1226
+ // This is a helper function for developers to generate MiniApp URLs
1227
+ _MiniKit.getMiniAppUrl = (appId, path) => {
1228
+ const baseUrl = new URL("https://world.org/mini-app");
1229
+ baseUrl.searchParams.append("app_id", appId);
1230
+ if (path) {
1231
+ const fullPath = path.startsWith("/") ? path : `/${path}`;
1232
+ baseUrl.searchParams.append("path", encodeURIComponent(fullPath));
1233
+ }
1234
+ return baseUrl.toString();
1235
+ };
1236
+ // Opens the profile card for a given username or wallet address
1237
+ _MiniKit.showProfileCard = (username, walletAddress) => {
1238
+ if (!username && !walletAddress) {
1239
+ console.error(
1240
+ "Either username or walletAddress must be provided to show profile card"
1241
+ );
1242
+ return;
1243
+ }
1244
+ if (username) {
1245
+ window.open(
1246
+ `worldapp://profile?username=${encodeURIComponent(username)}`
1247
+ );
1248
+ return;
1249
+ } else {
1250
+ window.open(
1251
+ `worldapp://profile?address=${encodeURIComponent(walletAddress || "")}`
1252
+ );
1253
+ }
1254
+ };
1174
1255
  // Simply re-exporting the existing function
1175
1256
  _MiniKit.getUserInfo = _MiniKit.getUserByAddress;
1176
1257
  _MiniKit.commands = {
@@ -1396,6 +1477,24 @@ _MiniKit.commands = {
1396
1477
  });
1397
1478
  }
1398
1479
  return payload;
1480
+ },
1481
+ chat: (payload) => {
1482
+ if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["chat" /* Chat */]) {
1483
+ console.error(
1484
+ "'chat' command is unavailable. Check MiniKit.install() or update the app version"
1485
+ );
1486
+ return null;
1487
+ }
1488
+ if (payload.message.length === 0) {
1489
+ console.error("'chat' command requires a non-empty message");
1490
+ return null;
1491
+ }
1492
+ sendMiniKitEvent({
1493
+ command: "chat" /* Chat */,
1494
+ version: _MiniKit.miniKitCommandVersion["chat" /* Chat */],
1495
+ payload
1496
+ });
1497
+ return payload;
1399
1498
  }
1400
1499
  };
1401
1500
  /**
@@ -1570,6 +1669,23 @@ _MiniKit.commandsAsync = {
1570
1669
  reject(error);
1571
1670
  }
1572
1671
  });
1672
+ },
1673
+ chat: async (payload) => {
1674
+ return new Promise(async (resolve, reject) => {
1675
+ try {
1676
+ const response = await _MiniKit.awaitCommand(
1677
+ "miniapp-chat" /* MiniAppChat */,
1678
+ "chat" /* Chat */,
1679
+ () => _MiniKit.commands.chat(payload)
1680
+ );
1681
+ resolve({
1682
+ commandPayload: response.commandPayload,
1683
+ finalPayload: response.finalPayload
1684
+ });
1685
+ } catch (error) {
1686
+ reject(error);
1687
+ }
1688
+ });
1573
1689
  }
1574
1690
  };
1575
1691
  var MiniKit = _MiniKit;
@@ -1631,11 +1747,14 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
1631
1747
  };
1632
1748
  // Annotate the CommonJS export names for ESM import in node:
1633
1749
  0 && (module.exports = {
1750
+ ChatErrorCodes,
1751
+ ChatErrorMessage,
1634
1752
  Command,
1635
1753
  GetPermissionsErrorCodes,
1636
1754
  GetPermissionsErrorMessage,
1637
1755
  MicrophoneErrorCodes,
1638
1756
  MicrophoneErrorMessage,
1757
+ MiniAppLaunchLocation,
1639
1758
  MiniKit,
1640
1759
  MiniKitInstallErrorCodes,
1641
1760
  MiniKitInstallErrorMessage,
@@ -1667,6 +1786,7 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
1667
1786
  WalletAuthErrorCodes,
1668
1787
  WalletAuthErrorMessage,
1669
1788
  getIsUserVerified,
1789
+ mapWorldAppLaunchLocation,
1670
1790
  parseSiweMessage,
1671
1791
  tokenToDecimals,
1672
1792
  verifyCloudProof,
package/build/index.d.cts CHANGED
@@ -148,6 +148,16 @@ declare const MicrophoneErrorMessage: {
148
148
  mini_app_permission_not_enabled: string;
149
149
  world_app_permission_not_enabled: string;
150
150
  };
151
+ declare enum ChatErrorCodes {
152
+ UserRejected = "user_rejected",
153
+ SendFailed = "send_failed",
154
+ GenericError = "generic_error"
155
+ }
156
+ declare const ChatErrorMessage: {
157
+ user_rejected: string;
158
+ send_failed: string;
159
+ generic_error: string;
160
+ };
151
161
 
152
162
  declare enum Tokens {
153
163
  USDC = "USDCE",
@@ -191,7 +201,8 @@ declare enum Command {
191
201
  RequestPermission = "request-permission",
192
202
  GetPermissions = "get-permissions",
193
203
  SendHapticFeedback = "send-haptic-feedback",
194
- Share = "share"
204
+ Share = "share",
205
+ Chat = "chat"
195
206
  }
196
207
  type WebViewBasePayload = {
197
208
  command: Command;
@@ -300,6 +311,10 @@ type SharePayload = {
300
311
  text?: string;
301
312
  url?: string;
302
313
  };
314
+ type ChatPayload = {
315
+ to?: string[];
316
+ message: string;
317
+ };
303
318
  type CommandReturnPayloadMap = {
304
319
  [Command.Verify]: VerifyCommandPayload;
305
320
  [Command.Pay]: PayCommandPayload;
@@ -312,6 +327,7 @@ type CommandReturnPayloadMap = {
312
327
  [Command.GetPermissions]: GetPermissionsPayload;
313
328
  [Command.SendHapticFeedback]: SendHapticFeedbackPayload;
314
329
  [Command.Share]: SharePayload;
330
+ [Command.Chat]: ChatPayload;
315
331
  };
316
332
  type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
317
333
 
@@ -344,6 +360,18 @@ type UserNameService = {
344
360
  username?: string;
345
361
  profilePictureUrl?: string;
346
362
  };
363
+ type MiniAppLocation = {
364
+ countryCode?: string;
365
+ regionCode?: string;
366
+ };
367
+ declare enum MiniAppLaunchLocation {
368
+ Chat = "chat",
369
+ Home = "home",
370
+ AppStore = "app-store",
371
+ DeepLink = "deep-link",
372
+ WalletTab = "wallet-tab"
373
+ }
374
+ declare const mapWorldAppLaunchLocation: (location: string | null | undefined) => MiniAppLaunchLocation | null;
347
375
 
348
376
  declare enum ResponseEvent {
349
377
  MiniAppVerifyAction = "miniapp-verify-action",
@@ -357,7 +385,8 @@ declare enum ResponseEvent {
357
385
  MiniAppGetPermissions = "miniapp-get-permissions",
358
386
  MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
359
387
  MiniAppShare = "miniapp-share",
360
- MiniAppMicrophone = "miniapp-microphone"
388
+ MiniAppMicrophone = "miniapp-microphone",
389
+ MiniAppChat = "miniapp-chat"
361
390
  }
362
391
  type MiniAppVerifyActionSuccessPayload = {
363
392
  status: 'success';
@@ -528,6 +557,18 @@ type MiniAppMicrophoneErrorPayload = {
528
557
  version: number;
529
558
  };
530
559
  type MiniAppMicrophonePayload = MiniAppMicrophoneSuccessPayload | MiniAppMicrophoneErrorPayload;
560
+ type MiniAppChatSuccessPayload = {
561
+ status: 'success';
562
+ count: number;
563
+ timestamp: string;
564
+ version: number;
565
+ };
566
+ type MiniAppChatErrorPayload = {
567
+ status: 'error';
568
+ error_code: ChatErrorCodes;
569
+ version: number;
570
+ };
571
+ type MiniAppChatPayload = MiniAppChatSuccessPayload | MiniAppChatErrorPayload;
531
572
  type EventPayloadMap = {
532
573
  [ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
533
574
  [ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
@@ -541,6 +582,7 @@ type EventPayloadMap = {
541
582
  [ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
542
583
  [ResponseEvent.MiniAppShare]: MiniAppSharePayload;
543
584
  [ResponseEvent.MiniAppMicrophone]: MiniAppMicrophonePayload;
585
+ [ResponseEvent.MiniAppChat]: MiniAppChatPayload;
544
586
  };
545
587
  type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
546
588
  type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
@@ -554,6 +596,7 @@ declare class MiniKit {
554
596
  static appId: string | null;
555
597
  static user: User;
556
598
  static deviceProperties: DeviceProperties;
599
+ static location: MiniAppLaunchLocation | null;
557
600
  private static isReady;
558
601
  private static sendInit;
559
602
  static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
@@ -565,6 +608,8 @@ declare class MiniKit {
565
608
  static isInstalled(debug?: boolean): boolean;
566
609
  static getUserByAddress: (address?: string) => Promise<UserNameService>;
567
610
  static getUserByUsername: (username: string) => Promise<UserNameService>;
611
+ static getMiniAppUrl: (appId: string, path?: string) => string;
612
+ static showProfileCard: (username?: string, walletAddress?: string) => void;
568
613
  static getUserInfo: (address?: string) => Promise<UserNameService>;
569
614
  static commands: {
570
615
  verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
@@ -578,6 +623,7 @@ declare class MiniKit {
578
623
  getPermissions: () => GetPermissionsPayload | null;
579
624
  sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
580
625
  share: (payload: ShareInput) => ShareInput | null;
626
+ chat: (payload: ChatPayload) => ChatPayload | null;
581
627
  };
582
628
  /**
583
629
  * This object contains async versions of all the commands.
@@ -601,6 +647,7 @@ declare class MiniKit {
601
647
  getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
602
648
  sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
603
649
  share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
650
+ chat: (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
604
651
  };
605
652
  }
606
653
 
@@ -629,4 +676,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
629
676
 
630
677
  declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
631
678
 
632
- export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type DeviceProperties, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, MicrophoneErrorCodes, MicrophoneErrorMessage, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, type MiniAppMicrophoneErrorPayload, type MiniAppMicrophonePayload, type MiniAppMicrophoneSuccessPayload, 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 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 ShareInput, type SharePayload, 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 };
679
+ export { type AsyncHandlerReturn, ChatErrorCodes, ChatErrorMessage, type ChatPayload, Command, type CommandReturnPayload, type Contact, type DeviceProperties, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, MicrophoneErrorCodes, MicrophoneErrorMessage, type MiniAppChatErrorPayload, type MiniAppChatPayload, type MiniAppChatSuccessPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, MiniAppLaunchLocation, type MiniAppLocation, type MiniAppMicrophoneErrorPayload, type MiniAppMicrophonePayload, type MiniAppMicrophoneSuccessPayload, 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 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 ShareInput, type SharePayload, 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, mapWorldAppLaunchLocation, parseSiweMessage, tokenToDecimals, verifySiweMessage };
package/build/index.d.ts CHANGED
@@ -148,6 +148,16 @@ declare const MicrophoneErrorMessage: {
148
148
  mini_app_permission_not_enabled: string;
149
149
  world_app_permission_not_enabled: string;
150
150
  };
151
+ declare enum ChatErrorCodes {
152
+ UserRejected = "user_rejected",
153
+ SendFailed = "send_failed",
154
+ GenericError = "generic_error"
155
+ }
156
+ declare const ChatErrorMessage: {
157
+ user_rejected: string;
158
+ send_failed: string;
159
+ generic_error: string;
160
+ };
151
161
 
152
162
  declare enum Tokens {
153
163
  USDC = "USDCE",
@@ -191,7 +201,8 @@ declare enum Command {
191
201
  RequestPermission = "request-permission",
192
202
  GetPermissions = "get-permissions",
193
203
  SendHapticFeedback = "send-haptic-feedback",
194
- Share = "share"
204
+ Share = "share",
205
+ Chat = "chat"
195
206
  }
196
207
  type WebViewBasePayload = {
197
208
  command: Command;
@@ -300,6 +311,10 @@ type SharePayload = {
300
311
  text?: string;
301
312
  url?: string;
302
313
  };
314
+ type ChatPayload = {
315
+ to?: string[];
316
+ message: string;
317
+ };
303
318
  type CommandReturnPayloadMap = {
304
319
  [Command.Verify]: VerifyCommandPayload;
305
320
  [Command.Pay]: PayCommandPayload;
@@ -312,6 +327,7 @@ type CommandReturnPayloadMap = {
312
327
  [Command.GetPermissions]: GetPermissionsPayload;
313
328
  [Command.SendHapticFeedback]: SendHapticFeedbackPayload;
314
329
  [Command.Share]: SharePayload;
330
+ [Command.Chat]: ChatPayload;
315
331
  };
316
332
  type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
317
333
 
@@ -344,6 +360,18 @@ type UserNameService = {
344
360
  username?: string;
345
361
  profilePictureUrl?: string;
346
362
  };
363
+ type MiniAppLocation = {
364
+ countryCode?: string;
365
+ regionCode?: string;
366
+ };
367
+ declare enum MiniAppLaunchLocation {
368
+ Chat = "chat",
369
+ Home = "home",
370
+ AppStore = "app-store",
371
+ DeepLink = "deep-link",
372
+ WalletTab = "wallet-tab"
373
+ }
374
+ declare const mapWorldAppLaunchLocation: (location: string | null | undefined) => MiniAppLaunchLocation | null;
347
375
 
348
376
  declare enum ResponseEvent {
349
377
  MiniAppVerifyAction = "miniapp-verify-action",
@@ -357,7 +385,8 @@ declare enum ResponseEvent {
357
385
  MiniAppGetPermissions = "miniapp-get-permissions",
358
386
  MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
359
387
  MiniAppShare = "miniapp-share",
360
- MiniAppMicrophone = "miniapp-microphone"
388
+ MiniAppMicrophone = "miniapp-microphone",
389
+ MiniAppChat = "miniapp-chat"
361
390
  }
362
391
  type MiniAppVerifyActionSuccessPayload = {
363
392
  status: 'success';
@@ -528,6 +557,18 @@ type MiniAppMicrophoneErrorPayload = {
528
557
  version: number;
529
558
  };
530
559
  type MiniAppMicrophonePayload = MiniAppMicrophoneSuccessPayload | MiniAppMicrophoneErrorPayload;
560
+ type MiniAppChatSuccessPayload = {
561
+ status: 'success';
562
+ count: number;
563
+ timestamp: string;
564
+ version: number;
565
+ };
566
+ type MiniAppChatErrorPayload = {
567
+ status: 'error';
568
+ error_code: ChatErrorCodes;
569
+ version: number;
570
+ };
571
+ type MiniAppChatPayload = MiniAppChatSuccessPayload | MiniAppChatErrorPayload;
531
572
  type EventPayloadMap = {
532
573
  [ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
533
574
  [ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
@@ -541,6 +582,7 @@ type EventPayloadMap = {
541
582
  [ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
542
583
  [ResponseEvent.MiniAppShare]: MiniAppSharePayload;
543
584
  [ResponseEvent.MiniAppMicrophone]: MiniAppMicrophonePayload;
585
+ [ResponseEvent.MiniAppChat]: MiniAppChatPayload;
544
586
  };
545
587
  type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
546
588
  type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
@@ -554,6 +596,7 @@ declare class MiniKit {
554
596
  static appId: string | null;
555
597
  static user: User;
556
598
  static deviceProperties: DeviceProperties;
599
+ static location: MiniAppLaunchLocation | null;
557
600
  private static isReady;
558
601
  private static sendInit;
559
602
  static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
@@ -565,6 +608,8 @@ declare class MiniKit {
565
608
  static isInstalled(debug?: boolean): boolean;
566
609
  static getUserByAddress: (address?: string) => Promise<UserNameService>;
567
610
  static getUserByUsername: (username: string) => Promise<UserNameService>;
611
+ static getMiniAppUrl: (appId: string, path?: string) => string;
612
+ static showProfileCard: (username?: string, walletAddress?: string) => void;
568
613
  static getUserInfo: (address?: string) => Promise<UserNameService>;
569
614
  static commands: {
570
615
  verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
@@ -578,6 +623,7 @@ declare class MiniKit {
578
623
  getPermissions: () => GetPermissionsPayload | null;
579
624
  sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
580
625
  share: (payload: ShareInput) => ShareInput | null;
626
+ chat: (payload: ChatPayload) => ChatPayload | null;
581
627
  };
582
628
  /**
583
629
  * This object contains async versions of all the commands.
@@ -601,6 +647,7 @@ declare class MiniKit {
601
647
  getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
602
648
  sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
603
649
  share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
650
+ chat: (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
604
651
  };
605
652
  }
606
653
 
@@ -629,4 +676,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
629
676
 
630
677
  declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
631
678
 
632
- export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type DeviceProperties, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, MicrophoneErrorCodes, MicrophoneErrorMessage, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, type MiniAppMicrophoneErrorPayload, type MiniAppMicrophonePayload, type MiniAppMicrophoneSuccessPayload, 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 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 ShareInput, type SharePayload, 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 };
679
+ export { type AsyncHandlerReturn, ChatErrorCodes, ChatErrorMessage, type ChatPayload, Command, type CommandReturnPayload, type Contact, type DeviceProperties, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, MicrophoneErrorCodes, MicrophoneErrorMessage, type MiniAppChatErrorPayload, type MiniAppChatPayload, type MiniAppChatSuccessPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, MiniAppLaunchLocation, type MiniAppLocation, type MiniAppMicrophoneErrorPayload, type MiniAppMicrophonePayload, type MiniAppMicrophoneSuccessPayload, 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 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 ShareInput, type SharePayload, 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, mapWorldAppLaunchLocation, parseSiweMessage, tokenToDecimals, verifySiweMessage };
package/build/index.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  AppErrorCodes,
3
+ ChatErrorCodes,
4
+ ChatErrorMessage,
3
5
  Command,
4
6
  GetPermissionsErrorCodes,
5
7
  GetPermissionsErrorMessage,
6
8
  MicrophoneErrorCodes,
7
9
  MicrophoneErrorMessage,
10
+ MiniAppLaunchLocation,
8
11
  MiniKit,
9
12
  MiniKitInstallErrorCodes,
10
13
  MiniKitInstallErrorMessage,
@@ -33,10 +36,11 @@ import {
33
36
  VerificationErrorMessage,
34
37
  WalletAuthErrorCodes,
35
38
  WalletAuthErrorMessage,
39
+ mapWorldAppLaunchLocation,
36
40
  parseSiweMessage,
37
41
  tokenToDecimals,
38
42
  verifySiweMessage
39
- } from "./chunk-Q55KYUW6.js";
43
+ } from "./chunk-VWX7SELF.js";
40
44
 
41
45
  // index.ts
42
46
  import { VerificationLevel } from "@worldcoin/idkit-core";
@@ -96,11 +100,14 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
96
100
  }
97
101
  };
98
102
  export {
103
+ ChatErrorCodes,
104
+ ChatErrorMessage,
99
105
  Command,
100
106
  GetPermissionsErrorCodes,
101
107
  GetPermissionsErrorMessage,
102
108
  MicrophoneErrorCodes,
103
109
  MicrophoneErrorMessage,
110
+ MiniAppLaunchLocation,
104
111
  MiniKit,
105
112
  MiniKitInstallErrorCodes,
106
113
  MiniKitInstallErrorMessage,
@@ -132,6 +139,7 @@ export {
132
139
  WalletAuthErrorCodes,
133
140
  WalletAuthErrorMessage,
134
141
  getIsUserVerified,
142
+ mapWorldAppLaunchLocation,
135
143
  parseSiweMessage,
136
144
  tokenToDecimals,
137
145
  verifyCloudProof,
@@ -433,6 +433,24 @@ var getUserProfile = async (address) => {
433
433
  return usernames?.[0] ?? { username: null, profile_picture_url: null };
434
434
  };
435
435
 
436
+ // types/init.ts
437
+ var WORLD_APP_LAUNCH_LOCATION_MAP = {
438
+ "app-store": "app-store" /* AppStore */,
439
+ carousel: "app-store" /* AppStore */,
440
+ explore: "app-store" /* AppStore */,
441
+ app_details: "app-store" /* AppStore */,
442
+ deeplink: "deep-link" /* DeepLink */,
443
+ homepage: "home" /* Home */,
444
+ wallet_tab: "wallet-tab" /* WalletTab */,
445
+ world_chat: "chat" /* Chat */
446
+ };
447
+ var mapWorldAppLaunchLocation = (location) => {
448
+ if (!location || typeof location !== "string") return null;
449
+ console.log("MiniKit launch location mapped:", location);
450
+ const normalizedLocation = location.toLowerCase();
451
+ return WORLD_APP_LAUNCH_LOCATION_MAP[normalizedLocation] ?? null;
452
+ };
453
+
436
454
  // minikit.ts
437
455
  var sendMiniKitEvent = (payload) => {
438
456
  sendWebviewEvent(payload);
@@ -466,6 +484,9 @@ var _MiniKit = class _MiniKit {
466
484
  } else if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
467
485
  const originalHandler = handler;
468
486
  const wrappedHandler = (payload) => {
487
+ if (payload.status === "error" && payload.error_code == "user_rejected") {
488
+ payload.error_code = import_idkit_core2.AppErrorCodes.VerificationRejected;
489
+ }
469
490
  if (payload.status === "success" && payload.verification_level === import_idkit_core3.VerificationLevel.Orb) {
470
491
  compressAndPadProof(payload.proof).then(
471
492
  (compressedProof) => {
@@ -562,6 +583,7 @@ var _MiniKit = class _MiniKit {
562
583
  _MiniKit.deviceProperties.safeAreaInsets = window.WorldApp.safe_area_insets;
563
584
  _MiniKit.deviceProperties.deviceOS = window.WorldApp.device_os;
564
585
  _MiniKit.deviceProperties.worldAppVersion = window.WorldApp.world_app_version;
586
+ _MiniKit.location = mapWorldAppLaunchLocation(window.WorldApp.location);
565
587
  try {
566
588
  window.MiniKit = _MiniKit;
567
589
  this.sendInit();
@@ -610,7 +632,8 @@ _MiniKit.miniKitCommandVersion = {
610
632
  ["request-permission" /* RequestPermission */]: 1,
611
633
  ["get-permissions" /* GetPermissions */]: 1,
612
634
  ["send-haptic-feedback" /* SendHapticFeedback */]: 1,
613
- ["share" /* Share */]: 1
635
+ ["share" /* Share */]: 1,
636
+ ["chat" /* Chat */]: 1
614
637
  };
615
638
  _MiniKit.isCommandAvailable = {
616
639
  ["verify" /* Verify */]: false,
@@ -623,7 +646,8 @@ _MiniKit.isCommandAvailable = {
623
646
  ["request-permission" /* RequestPermission */]: false,
624
647
  ["get-permissions" /* GetPermissions */]: false,
625
648
  ["send-haptic-feedback" /* SendHapticFeedback */]: false,
626
- ["share" /* Share */]: false
649
+ ["share" /* Share */]: false,
650
+ ["chat" /* Chat */]: false
627
651
  };
628
652
  _MiniKit.listeners = {
629
653
  ["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
@@ -649,11 +673,14 @@ _MiniKit.listeners = {
649
673
  ["miniapp-share" /* MiniAppShare */]: () => {
650
674
  },
651
675
  ["miniapp-microphone" /* MiniAppMicrophone */]: () => {
676
+ },
677
+ ["miniapp-chat" /* MiniAppChat */]: () => {
652
678
  }
653
679
  };
654
680
  _MiniKit.appId = null;
655
681
  _MiniKit.user = {};
656
682
  _MiniKit.deviceProperties = {};
683
+ _MiniKit.location = null;
657
684
  _MiniKit.isReady = false;
658
685
  _MiniKit.getUserByAddress = async (address) => {
659
686
  const userProfile = await getUserProfile(
@@ -682,6 +709,35 @@ _MiniKit.getUserByUsername = async (username) => {
682
709
  profilePictureUrl: user.profile_picture_url
683
710
  };
684
711
  };
712
+ // This is a helper function for developers to generate MiniApp URLs
713
+ _MiniKit.getMiniAppUrl = (appId, path) => {
714
+ const baseUrl = new URL("https://world.org/mini-app");
715
+ baseUrl.searchParams.append("app_id", appId);
716
+ if (path) {
717
+ const fullPath = path.startsWith("/") ? path : `/${path}`;
718
+ baseUrl.searchParams.append("path", encodeURIComponent(fullPath));
719
+ }
720
+ return baseUrl.toString();
721
+ };
722
+ // Opens the profile card for a given username or wallet address
723
+ _MiniKit.showProfileCard = (username, walletAddress) => {
724
+ if (!username && !walletAddress) {
725
+ console.error(
726
+ "Either username or walletAddress must be provided to show profile card"
727
+ );
728
+ return;
729
+ }
730
+ if (username) {
731
+ window.open(
732
+ `worldapp://profile?username=${encodeURIComponent(username)}`
733
+ );
734
+ return;
735
+ } else {
736
+ window.open(
737
+ `worldapp://profile?address=${encodeURIComponent(walletAddress || "")}`
738
+ );
739
+ }
740
+ };
685
741
  // Simply re-exporting the existing function
686
742
  _MiniKit.getUserInfo = _MiniKit.getUserByAddress;
687
743
  _MiniKit.commands = {
@@ -907,6 +963,24 @@ _MiniKit.commands = {
907
963
  });
908
964
  }
909
965
  return payload;
966
+ },
967
+ chat: (payload) => {
968
+ if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["chat" /* Chat */]) {
969
+ console.error(
970
+ "'chat' command is unavailable. Check MiniKit.install() or update the app version"
971
+ );
972
+ return null;
973
+ }
974
+ if (payload.message.length === 0) {
975
+ console.error("'chat' command requires a non-empty message");
976
+ return null;
977
+ }
978
+ sendMiniKitEvent({
979
+ command: "chat" /* Chat */,
980
+ version: _MiniKit.miniKitCommandVersion["chat" /* Chat */],
981
+ payload
982
+ });
983
+ return payload;
910
984
  }
911
985
  };
912
986
  /**
@@ -1081,6 +1155,23 @@ _MiniKit.commandsAsync = {
1081
1155
  reject(error);
1082
1156
  }
1083
1157
  });
1158
+ },
1159
+ chat: async (payload) => {
1160
+ return new Promise(async (resolve, reject) => {
1161
+ try {
1162
+ const response = await _MiniKit.awaitCommand(
1163
+ "miniapp-chat" /* MiniAppChat */,
1164
+ "chat" /* Chat */,
1165
+ () => _MiniKit.commands.chat(payload)
1166
+ );
1167
+ resolve({
1168
+ commandPayload: response.commandPayload,
1169
+ finalPayload: response.finalPayload
1170
+ });
1171
+ } catch (error) {
1172
+ reject(error);
1173
+ }
1174
+ });
1084
1175
  }
1085
1176
  };
1086
1177
  var MiniKit = _MiniKit;
@@ -1100,14 +1191,9 @@ var MiniKitProvider = ({
1100
1191
  (0, import_react.useEffect)(() => {
1101
1192
  const { success } = MiniKit.install(props?.appId);
1102
1193
  if (!success) return setIsInstalled(false);
1103
- MiniKit.commandsAsync.getPermissions().then(({ commandPayload: _, finalPayload }) => {
1104
- if (finalPayload.status === "success") {
1105
- MiniKit.user.permissions = {
1106
- notifications: finalPayload.permissions.notifications,
1107
- contacts: finalPayload.permissions.contacts
1108
- };
1109
- }
1110
- });
1194
+ console.warn(
1195
+ "MiniKit permissions not fetched in provider. MiniKit.user.permissions will be inaccurate."
1196
+ );
1111
1197
  setIsInstalled(success);
1112
1198
  }, [props?.appId]);
1113
1199
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MiniKitContext.Provider, { value: { isInstalled }, children });
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  MiniKit
4
- } from "./chunk-Q55KYUW6.js";
4
+ } from "./chunk-VWX7SELF.js";
5
5
 
6
6
  // minikit-provider.tsx
7
7
  import {
@@ -24,14 +24,9 @@ var MiniKitProvider = ({
24
24
  useEffect(() => {
25
25
  const { success } = MiniKit.install(props?.appId);
26
26
  if (!success) return setIsInstalled(false);
27
- MiniKit.commandsAsync.getPermissions().then(({ commandPayload: _, finalPayload }) => {
28
- if (finalPayload.status === "success") {
29
- MiniKit.user.permissions = {
30
- notifications: finalPayload.permissions.notifications,
31
- contacts: finalPayload.permissions.contacts
32
- };
33
- }
34
- });
27
+ console.warn(
28
+ "MiniKit permissions not fetched in provider. MiniKit.user.permissions will be inaccurate."
29
+ );
35
30
  setIsInstalled(success);
36
31
  }, [props?.appId]);
37
32
  return /* @__PURE__ */ jsx(MiniKitContext.Provider, { value: { isInstalled }, children });
package/package.json CHANGED
@@ -1,4 +1,8 @@
1
1
  {
2
+ "repository": {
3
+ "type": "git",
4
+ "url": "git+https://github.com/worldcoin/minikit-js.git"
5
+ },
2
6
  "dependencies": {
3
7
  "@worldcoin/idkit-core": "^2.0.2",
4
8
  "abitype": "^1.0.6"
@@ -74,7 +78,7 @@
74
78
  ]
75
79
  }
76
80
  },
77
- "version": "1.9.7",
81
+ "version": "1.9.9",
78
82
  "scripts": {
79
83
  "build": "tsup",
80
84
  "dev": "tsup --watch",