@worldcoin/minikit-js 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.cjs CHANGED
@@ -45,6 +45,7 @@ __export(core_exports, {
45
45
  VerificationLevel: () => import_idkit_core4.VerificationLevel,
46
46
  WalletAuthErrorCodes: () => WalletAuthErrorCodes,
47
47
  WalletAuthErrorMessage: () => WalletAuthErrorMessage,
48
+ getIsUserVerified: () => getIsUserVerified,
48
49
  parseSiweMessage: () => parseSiweMessage,
49
50
  tokenToDecimals: () => tokenToDecimals,
50
51
  verifyCloudProof: () => import_backend.verifyCloudProof,
@@ -629,6 +630,9 @@ _MiniKit.listeners = {
629
630
  }
630
631
  };
631
632
  _MiniKit.appId = null;
633
+ /**
634
+ * @deprecated you should use MiniKit.user.walletAddress instead
635
+ */
632
636
  _MiniKit.walletAddress = null;
633
637
  _MiniKit.user = null;
634
638
  _MiniKit.commands = {
@@ -891,6 +895,58 @@ var MiniKit = _MiniKit;
891
895
  // index.ts
892
896
  var import_idkit_core4 = require("@worldcoin/idkit-core");
893
897
  var import_backend = require("@worldcoin/idkit-core/backend");
898
+
899
+ // helpers/address-book/index.ts
900
+ var import_viem2 = require("viem");
901
+ var import_chains2 = require("viem/chains");
902
+ var worldIdAddressBookContractAddress = "0x57b930D551e677CC36e2fA036Ae2fe8FdaE0330D";
903
+ var addressVerifiedUntilAbi = [
904
+ {
905
+ inputs: [
906
+ {
907
+ internalType: "address",
908
+ name: "",
909
+ type: "address"
910
+ }
911
+ ],
912
+ name: "addressVerifiedUntil",
913
+ outputs: [
914
+ {
915
+ internalType: "uint256",
916
+ name: "",
917
+ type: "uint256"
918
+ }
919
+ ],
920
+ stateMutability: "view",
921
+ type: "function"
922
+ }
923
+ ];
924
+ var getIsUserVerified = async (walletAddress, rpcUrl) => {
925
+ const publicClient = (0, import_viem2.createPublicClient)({
926
+ chain: import_chains2.worldchain,
927
+ transport: (0, import_viem2.http)(
928
+ rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
929
+ )
930
+ });
931
+ try {
932
+ const verifiedUntilResponse = await publicClient.readContract({
933
+ address: worldIdAddressBookContractAddress,
934
+ abi: addressVerifiedUntilAbi,
935
+ functionName: "addressVerifiedUntil",
936
+ args: [walletAddress]
937
+ });
938
+ const verifiedUntil = Number(verifiedUntilResponse.toString());
939
+ if (!Number.isFinite(verifiedUntil)) {
940
+ console.warn("Invalid verifiedUntil value:", verifiedUntil);
941
+ return false;
942
+ }
943
+ const currentTime = Math.floor(Date.now() / 1e3);
944
+ return verifiedUntil > currentTime;
945
+ } catch (error) {
946
+ console.error("Error verifying user:", error);
947
+ return false;
948
+ }
949
+ };
894
950
  // Annotate the CommonJS export names for ESM import in node:
895
951
  0 && (module.exports = {
896
952
  Command,
@@ -918,6 +974,7 @@ var import_backend = require("@worldcoin/idkit-core/backend");
918
974
  VerificationLevel,
919
975
  WalletAuthErrorCodes,
920
976
  WalletAuthErrorMessage,
977
+ getIsUserVerified,
921
978
  parseSiweMessage,
922
979
  tokenToDecimals,
923
980
  verifyCloudProof,
package/build/index.d.cts CHANGED
@@ -369,6 +369,9 @@ declare class MiniKit {
369
369
  private static isCommandAvailable;
370
370
  private static listeners;
371
371
  static appId: string | null;
372
+ /**
373
+ * @deprecated you should use MiniKit.user.walletAddress instead
374
+ */
372
375
  static walletAddress: string | null;
373
376
  static user: {
374
377
  walletAddress: string | null;
@@ -431,4 +434,6 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
431
434
  siweMessageData: SiweMessage;
432
435
  }>;
433
436
 
434
- export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, parseSiweMessage, tokenToDecimals, verifySiweMessage };
437
+ declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
438
+
439
+ export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
package/build/index.d.ts CHANGED
@@ -369,6 +369,9 @@ declare class MiniKit {
369
369
  private static isCommandAvailable;
370
370
  private static listeners;
371
371
  static appId: string | null;
372
+ /**
373
+ * @deprecated you should use MiniKit.user.walletAddress instead
374
+ */
372
375
  static walletAddress: string | null;
373
376
  static user: {
374
377
  walletAddress: string | null;
@@ -431,4 +434,6 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
431
434
  siweMessageData: SiweMessage;
432
435
  }>;
433
436
 
434
- export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, parseSiweMessage, tokenToDecimals, verifySiweMessage };
437
+ declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
438
+
439
+ export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
package/build/index.js CHANGED
@@ -580,6 +580,9 @@ _MiniKit.listeners = {
580
580
  }
581
581
  };
582
582
  _MiniKit.appId = null;
583
+ /**
584
+ * @deprecated you should use MiniKit.user.walletAddress instead
585
+ */
583
586
  _MiniKit.walletAddress = null;
584
587
  _MiniKit.user = null;
585
588
  _MiniKit.commands = {
@@ -844,6 +847,58 @@ import { VerificationLevel as VerificationLevel2 } from "@worldcoin/idkit-core";
844
847
  import {
845
848
  verifyCloudProof
846
849
  } from "@worldcoin/idkit-core/backend";
850
+
851
+ // helpers/address-book/index.ts
852
+ import { createPublicClient as createPublicClient2, http as http2 } from "viem";
853
+ import { worldchain } from "viem/chains";
854
+ var worldIdAddressBookContractAddress = "0x57b930D551e677CC36e2fA036Ae2fe8FdaE0330D";
855
+ var addressVerifiedUntilAbi = [
856
+ {
857
+ inputs: [
858
+ {
859
+ internalType: "address",
860
+ name: "",
861
+ type: "address"
862
+ }
863
+ ],
864
+ name: "addressVerifiedUntil",
865
+ outputs: [
866
+ {
867
+ internalType: "uint256",
868
+ name: "",
869
+ type: "uint256"
870
+ }
871
+ ],
872
+ stateMutability: "view",
873
+ type: "function"
874
+ }
875
+ ];
876
+ var getIsUserVerified = async (walletAddress, rpcUrl) => {
877
+ const publicClient = createPublicClient2({
878
+ chain: worldchain,
879
+ transport: http2(
880
+ rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
881
+ )
882
+ });
883
+ try {
884
+ const verifiedUntilResponse = await publicClient.readContract({
885
+ address: worldIdAddressBookContractAddress,
886
+ abi: addressVerifiedUntilAbi,
887
+ functionName: "addressVerifiedUntil",
888
+ args: [walletAddress]
889
+ });
890
+ const verifiedUntil = Number(verifiedUntilResponse.toString());
891
+ if (!Number.isFinite(verifiedUntil)) {
892
+ console.warn("Invalid verifiedUntil value:", verifiedUntil);
893
+ return false;
894
+ }
895
+ const currentTime = Math.floor(Date.now() / 1e3);
896
+ return verifiedUntil > currentTime;
897
+ } catch (error) {
898
+ console.error("Error verifying user:", error);
899
+ return false;
900
+ }
901
+ };
847
902
  export {
848
903
  Command,
849
904
  MiniKit,
@@ -870,6 +925,7 @@ export {
870
925
  VerificationLevel2 as VerificationLevel,
871
926
  WalletAuthErrorCodes,
872
927
  WalletAuthErrorMessage,
928
+ getIsUserVerified,
873
929
  parseSiweMessage,
874
930
  tokenToDecimals,
875
931
  verifyCloudProof,
package/index.ts CHANGED
@@ -25,3 +25,5 @@ export {
25
25
  SAFE_CONTRACT_ABI,
26
26
  verifySiweMessage,
27
27
  } from "helpers/siwe/siwe";
28
+
29
+ export { getIsUserVerified } from "helpers/address-book";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldcoin/minikit-js",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "homepage": "https://docs.worldcoin.org/mini-apps",
5
5
  "description": "minikit-js is our SDK for building mini-apps.",
6
6
  "license": "MIT",