@worldcoin/minikit-js 1.2.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 +106 -2
- package/build/index.d.cts +43 -3
- package/build/index.d.ts +43 -3
- package/build/index.js +103 -2
- package/index.ts +2 -0
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -32,6 +32,8 @@ __export(core_exports, {
|
|
|
32
32
|
SAFE_CONTRACT_ABI: () => SAFE_CONTRACT_ABI,
|
|
33
33
|
SendTransactionErrorCodes: () => SendTransactionErrorCodes,
|
|
34
34
|
SendTransactionErrorMessage: () => SendTransactionErrorMessage,
|
|
35
|
+
ShareContactsErrorCodes: () => ShareContactsErrorCodes,
|
|
36
|
+
ShareContactsErrorMessage: () => ShareContactsErrorMessage,
|
|
35
37
|
SignMessageErrorCodes: () => SignMessageErrorCodes,
|
|
36
38
|
SignMessageErrorMessage: () => SignMessageErrorMessage,
|
|
37
39
|
SignTypedDataErrorCodes: () => SignTypedDataErrorCodes,
|
|
@@ -43,6 +45,7 @@ __export(core_exports, {
|
|
|
43
45
|
VerificationLevel: () => import_idkit_core4.VerificationLevel,
|
|
44
46
|
WalletAuthErrorCodes: () => WalletAuthErrorCodes,
|
|
45
47
|
WalletAuthErrorMessage: () => WalletAuthErrorMessage,
|
|
48
|
+
getIsUserVerified: () => getIsUserVerified,
|
|
46
49
|
parseSiweMessage: () => parseSiweMessage,
|
|
47
50
|
tokenToDecimals: () => tokenToDecimals,
|
|
48
51
|
verifyCloudProof: () => import_backend.verifyCloudProof,
|
|
@@ -67,6 +70,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
67
70
|
Command2["SendTransaction"] = "send-transaction";
|
|
68
71
|
Command2["SignMessage"] = "sign-message";
|
|
69
72
|
Command2["SignTypedData"] = "sign-typed-data";
|
|
73
|
+
Command2["ShareContacts"] = "share-contacts";
|
|
70
74
|
return Command2;
|
|
71
75
|
})(Command || {});
|
|
72
76
|
|
|
@@ -78,6 +82,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
78
82
|
ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
|
|
79
83
|
ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
|
|
80
84
|
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
85
|
+
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
81
86
|
return ResponseEvent2;
|
|
82
87
|
})(ResponseEvent || {});
|
|
83
88
|
|
|
@@ -211,6 +216,15 @@ var MiniKitInstallErrorMessage = {
|
|
|
211
216
|
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
212
217
|
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
213
218
|
};
|
|
219
|
+
var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
|
|
220
|
+
ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
|
|
221
|
+
ShareContactsErrorCodes2["GenericError"] = "generic_error";
|
|
222
|
+
return ShareContactsErrorCodes2;
|
|
223
|
+
})(ShareContactsErrorCodes || {});
|
|
224
|
+
var ShareContactsErrorMessage = {
|
|
225
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
226
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
227
|
+
};
|
|
214
228
|
|
|
215
229
|
// minikit.ts
|
|
216
230
|
var import_idkit_core3 = require("@worldcoin/idkit-core");
|
|
@@ -587,7 +601,8 @@ _MiniKit.commandVersion = {
|
|
|
587
601
|
["wallet-auth" /* WalletAuth */]: 1,
|
|
588
602
|
["send-transaction" /* SendTransaction */]: 1,
|
|
589
603
|
["sign-message" /* SignMessage */]: 1,
|
|
590
|
-
["sign-typed-data" /* SignTypedData */]: 1
|
|
604
|
+
["sign-typed-data" /* SignTypedData */]: 1,
|
|
605
|
+
["share-contacts" /* ShareContacts */]: 1
|
|
591
606
|
};
|
|
592
607
|
_MiniKit.isCommandAvailable = {
|
|
593
608
|
["verify" /* Verify */]: false,
|
|
@@ -595,7 +610,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
595
610
|
["wallet-auth" /* WalletAuth */]: false,
|
|
596
611
|
["send-transaction" /* SendTransaction */]: false,
|
|
597
612
|
["sign-message" /* SignMessage */]: false,
|
|
598
|
-
["sign-typed-data" /* SignTypedData */]: false
|
|
613
|
+
["sign-typed-data" /* SignTypedData */]: false,
|
|
614
|
+
["share-contacts" /* ShareContacts */]: false
|
|
599
615
|
};
|
|
600
616
|
_MiniKit.listeners = {
|
|
601
617
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -609,9 +625,14 @@ _MiniKit.listeners = {
|
|
|
609
625
|
["miniapp-sign-message" /* MiniAppSignMessage */]: () => {
|
|
610
626
|
},
|
|
611
627
|
["miniapp-sign-typed-data" /* MiniAppSignTypedData */]: () => {
|
|
628
|
+
},
|
|
629
|
+
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
612
630
|
}
|
|
613
631
|
};
|
|
614
632
|
_MiniKit.appId = null;
|
|
633
|
+
/**
|
|
634
|
+
* @deprecated you should use MiniKit.user.walletAddress instead
|
|
635
|
+
*/
|
|
615
636
|
_MiniKit.walletAddress = null;
|
|
616
637
|
_MiniKit.user = null;
|
|
617
638
|
_MiniKit.commands = {
|
|
@@ -743,6 +764,20 @@ _MiniKit.commands = {
|
|
|
743
764
|
payload
|
|
744
765
|
});
|
|
745
766
|
return payload;
|
|
767
|
+
},
|
|
768
|
+
shareContacts: (payload) => {
|
|
769
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-typed-data" /* SignTypedData */]) {
|
|
770
|
+
console.error(
|
|
771
|
+
"'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
|
|
772
|
+
);
|
|
773
|
+
return null;
|
|
774
|
+
}
|
|
775
|
+
sendMiniKitEvent({
|
|
776
|
+
command: "share-contacts" /* ShareContacts */,
|
|
777
|
+
version: 1,
|
|
778
|
+
payload
|
|
779
|
+
});
|
|
780
|
+
return payload;
|
|
746
781
|
}
|
|
747
782
|
};
|
|
748
783
|
/**
|
|
@@ -839,6 +874,20 @@ _MiniKit.commandsAsync = {
|
|
|
839
874
|
reject(error);
|
|
840
875
|
}
|
|
841
876
|
});
|
|
877
|
+
},
|
|
878
|
+
shareContacts: async (payload) => {
|
|
879
|
+
return new Promise(async (resolve, reject) => {
|
|
880
|
+
try {
|
|
881
|
+
const response = await _MiniKit.awaitCommand(
|
|
882
|
+
"miniapp-share-contacts" /* MiniAppShareContacts */,
|
|
883
|
+
"share-contacts" /* ShareContacts */,
|
|
884
|
+
() => _MiniKit.commands.shareContacts(payload)
|
|
885
|
+
);
|
|
886
|
+
return resolve(response);
|
|
887
|
+
} catch (error) {
|
|
888
|
+
reject(error);
|
|
889
|
+
}
|
|
890
|
+
});
|
|
842
891
|
}
|
|
843
892
|
};
|
|
844
893
|
var MiniKit = _MiniKit;
|
|
@@ -846,6 +895,58 @@ var MiniKit = _MiniKit;
|
|
|
846
895
|
// index.ts
|
|
847
896
|
var import_idkit_core4 = require("@worldcoin/idkit-core");
|
|
848
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
|
+
};
|
|
849
950
|
// Annotate the CommonJS export names for ESM import in node:
|
|
850
951
|
0 && (module.exports = {
|
|
851
952
|
Command,
|
|
@@ -860,6 +961,8 @@ var import_backend = require("@worldcoin/idkit-core/backend");
|
|
|
860
961
|
SAFE_CONTRACT_ABI,
|
|
861
962
|
SendTransactionErrorCodes,
|
|
862
963
|
SendTransactionErrorMessage,
|
|
964
|
+
ShareContactsErrorCodes,
|
|
965
|
+
ShareContactsErrorMessage,
|
|
863
966
|
SignMessageErrorCodes,
|
|
864
967
|
SignMessageErrorMessage,
|
|
865
968
|
SignTypedDataErrorCodes,
|
|
@@ -871,6 +974,7 @@ var import_backend = require("@worldcoin/idkit-core/backend");
|
|
|
871
974
|
VerificationLevel,
|
|
872
975
|
WalletAuthErrorCodes,
|
|
873
976
|
WalletAuthErrorMessage,
|
|
977
|
+
getIsUserVerified,
|
|
874
978
|
parseSiweMessage,
|
|
875
979
|
tokenToDecimals,
|
|
876
980
|
verifyCloudProof,
|
package/build/index.d.cts
CHANGED
|
@@ -128,6 +128,14 @@ declare const MiniKitInstallErrorMessage: {
|
|
|
128
128
|
not_on_client: string;
|
|
129
129
|
app_out_of_date: string;
|
|
130
130
|
};
|
|
131
|
+
declare enum ShareContactsErrorCodes {
|
|
132
|
+
UserRejected = "user_rejected",
|
|
133
|
+
GenericError = "generic_error"
|
|
134
|
+
}
|
|
135
|
+
declare const ShareContactsErrorMessage: {
|
|
136
|
+
user_rejected: string;
|
|
137
|
+
generic_error: string;
|
|
138
|
+
};
|
|
131
139
|
|
|
132
140
|
declare enum Command {
|
|
133
141
|
Verify = "verify",
|
|
@@ -135,7 +143,8 @@ declare enum Command {
|
|
|
135
143
|
WalletAuth = "wallet-auth",
|
|
136
144
|
SendTransaction = "send-transaction",
|
|
137
145
|
SignMessage = "sign-message",
|
|
138
|
-
SignTypedData = "sign-typed-data"
|
|
146
|
+
SignTypedData = "sign-typed-data",
|
|
147
|
+
ShareContacts = "share-contacts"
|
|
139
148
|
}
|
|
140
149
|
type WebViewBasePayload = {
|
|
141
150
|
command: Command;
|
|
@@ -199,6 +208,10 @@ type SignTypedDataInput = {
|
|
|
199
208
|
domain?: TypedDataDomain;
|
|
200
209
|
};
|
|
201
210
|
type SignTypedDataPayload = SignTypedDataInput;
|
|
211
|
+
type ShareContactsInput = {
|
|
212
|
+
isMultiSelectEnabled: boolean;
|
|
213
|
+
};
|
|
214
|
+
type ShareContactsPayload = ShareContactsInput;
|
|
202
215
|
type CommandReturnPayloadMap = {
|
|
203
216
|
[Command.Verify]: VerifyCommandPayload;
|
|
204
217
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -206,6 +219,7 @@ type CommandReturnPayloadMap = {
|
|
|
206
219
|
[Command.SendTransaction]: SendTransactionPayload;
|
|
207
220
|
[Command.SignMessage]: SignMessagePayload;
|
|
208
221
|
[Command.SignTypedData]: SignTypedDataPayload;
|
|
222
|
+
[Command.ShareContacts]: ShareContactsPayload;
|
|
209
223
|
};
|
|
210
224
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
211
225
|
|
|
@@ -215,7 +229,8 @@ declare enum ResponseEvent {
|
|
|
215
229
|
MiniAppWalletAuth = "miniapp-wallet-auth",
|
|
216
230
|
MiniAppSendTransaction = "miniapp-send-transaction",
|
|
217
231
|
MiniAppSignMessage = "miniapp-sign-message",
|
|
218
|
-
MiniAppSignTypedData = "miniapp-sign-typed-data"
|
|
232
|
+
MiniAppSignTypedData = "miniapp-sign-typed-data",
|
|
233
|
+
MiniAppShareContacts = "miniapp-share-contacts"
|
|
219
234
|
}
|
|
220
235
|
type MiniAppVerifyActionSuccessPayload = {
|
|
221
236
|
status: "success";
|
|
@@ -304,6 +319,23 @@ type MiniAppSignTypedDataErrorPayload = {
|
|
|
304
319
|
version: number;
|
|
305
320
|
};
|
|
306
321
|
type MiniAppSignTypedDataPayload = MiniAppSignTypedDataSuccessPayload | MiniAppSignTypedDataErrorPayload;
|
|
322
|
+
type Contact = {
|
|
323
|
+
username: string;
|
|
324
|
+
walletAddress: string;
|
|
325
|
+
profilePictureUrl: string | null;
|
|
326
|
+
};
|
|
327
|
+
type MiniAppShareContactsSuccessPayload = {
|
|
328
|
+
status: "success";
|
|
329
|
+
contacts: Contact[];
|
|
330
|
+
version: number;
|
|
331
|
+
timestamp: string;
|
|
332
|
+
};
|
|
333
|
+
type MiniAppShareContactsErrorPayload = {
|
|
334
|
+
status: "error";
|
|
335
|
+
error_code: ShareContactsErrorCodes;
|
|
336
|
+
version: number;
|
|
337
|
+
};
|
|
338
|
+
type MiniAppShareContactsPayload = MiniAppShareContactsSuccessPayload | MiniAppShareContactsErrorPayload;
|
|
307
339
|
type EventPayloadMap = {
|
|
308
340
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
309
341
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -311,6 +343,7 @@ type EventPayloadMap = {
|
|
|
311
343
|
[ResponseEvent.MiniAppSendTransaction]: MiniAppSendTransactionPayload;
|
|
312
344
|
[ResponseEvent.MiniAppSignMessage]: MiniAppSignMessagePayload;
|
|
313
345
|
[ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
|
|
346
|
+
[ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
|
|
314
347
|
};
|
|
315
348
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
316
349
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -336,6 +369,9 @@ declare class MiniKit {
|
|
|
336
369
|
private static isCommandAvailable;
|
|
337
370
|
private static listeners;
|
|
338
371
|
static appId: string | null;
|
|
372
|
+
/**
|
|
373
|
+
* @deprecated you should use MiniKit.user.walletAddress instead
|
|
374
|
+
*/
|
|
339
375
|
static walletAddress: string | null;
|
|
340
376
|
static user: {
|
|
341
377
|
walletAddress: string | null;
|
|
@@ -357,6 +393,7 @@ declare class MiniKit {
|
|
|
357
393
|
sendTransaction: (payload: SendTransactionInput) => SendTransactionPayload | null;
|
|
358
394
|
signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
|
|
359
395
|
signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
|
|
396
|
+
shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
|
|
360
397
|
};
|
|
361
398
|
/**
|
|
362
399
|
* This object contains async versions of all the commands.
|
|
@@ -375,6 +412,7 @@ declare class MiniKit {
|
|
|
375
412
|
sendTransaction: (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
|
|
376
413
|
signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
|
|
377
414
|
signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
|
|
415
|
+
shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
|
|
378
416
|
};
|
|
379
417
|
}
|
|
380
418
|
|
|
@@ -396,4 +434,6 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
396
434
|
siweMessageData: SiweMessage;
|
|
397
435
|
}>;
|
|
398
436
|
|
|
399
|
-
|
|
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
|
@@ -128,6 +128,14 @@ declare const MiniKitInstallErrorMessage: {
|
|
|
128
128
|
not_on_client: string;
|
|
129
129
|
app_out_of_date: string;
|
|
130
130
|
};
|
|
131
|
+
declare enum ShareContactsErrorCodes {
|
|
132
|
+
UserRejected = "user_rejected",
|
|
133
|
+
GenericError = "generic_error"
|
|
134
|
+
}
|
|
135
|
+
declare const ShareContactsErrorMessage: {
|
|
136
|
+
user_rejected: string;
|
|
137
|
+
generic_error: string;
|
|
138
|
+
};
|
|
131
139
|
|
|
132
140
|
declare enum Command {
|
|
133
141
|
Verify = "verify",
|
|
@@ -135,7 +143,8 @@ declare enum Command {
|
|
|
135
143
|
WalletAuth = "wallet-auth",
|
|
136
144
|
SendTransaction = "send-transaction",
|
|
137
145
|
SignMessage = "sign-message",
|
|
138
|
-
SignTypedData = "sign-typed-data"
|
|
146
|
+
SignTypedData = "sign-typed-data",
|
|
147
|
+
ShareContacts = "share-contacts"
|
|
139
148
|
}
|
|
140
149
|
type WebViewBasePayload = {
|
|
141
150
|
command: Command;
|
|
@@ -199,6 +208,10 @@ type SignTypedDataInput = {
|
|
|
199
208
|
domain?: TypedDataDomain;
|
|
200
209
|
};
|
|
201
210
|
type SignTypedDataPayload = SignTypedDataInput;
|
|
211
|
+
type ShareContactsInput = {
|
|
212
|
+
isMultiSelectEnabled: boolean;
|
|
213
|
+
};
|
|
214
|
+
type ShareContactsPayload = ShareContactsInput;
|
|
202
215
|
type CommandReturnPayloadMap = {
|
|
203
216
|
[Command.Verify]: VerifyCommandPayload;
|
|
204
217
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -206,6 +219,7 @@ type CommandReturnPayloadMap = {
|
|
|
206
219
|
[Command.SendTransaction]: SendTransactionPayload;
|
|
207
220
|
[Command.SignMessage]: SignMessagePayload;
|
|
208
221
|
[Command.SignTypedData]: SignTypedDataPayload;
|
|
222
|
+
[Command.ShareContacts]: ShareContactsPayload;
|
|
209
223
|
};
|
|
210
224
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
211
225
|
|
|
@@ -215,7 +229,8 @@ declare enum ResponseEvent {
|
|
|
215
229
|
MiniAppWalletAuth = "miniapp-wallet-auth",
|
|
216
230
|
MiniAppSendTransaction = "miniapp-send-transaction",
|
|
217
231
|
MiniAppSignMessage = "miniapp-sign-message",
|
|
218
|
-
MiniAppSignTypedData = "miniapp-sign-typed-data"
|
|
232
|
+
MiniAppSignTypedData = "miniapp-sign-typed-data",
|
|
233
|
+
MiniAppShareContacts = "miniapp-share-contacts"
|
|
219
234
|
}
|
|
220
235
|
type MiniAppVerifyActionSuccessPayload = {
|
|
221
236
|
status: "success";
|
|
@@ -304,6 +319,23 @@ type MiniAppSignTypedDataErrorPayload = {
|
|
|
304
319
|
version: number;
|
|
305
320
|
};
|
|
306
321
|
type MiniAppSignTypedDataPayload = MiniAppSignTypedDataSuccessPayload | MiniAppSignTypedDataErrorPayload;
|
|
322
|
+
type Contact = {
|
|
323
|
+
username: string;
|
|
324
|
+
walletAddress: string;
|
|
325
|
+
profilePictureUrl: string | null;
|
|
326
|
+
};
|
|
327
|
+
type MiniAppShareContactsSuccessPayload = {
|
|
328
|
+
status: "success";
|
|
329
|
+
contacts: Contact[];
|
|
330
|
+
version: number;
|
|
331
|
+
timestamp: string;
|
|
332
|
+
};
|
|
333
|
+
type MiniAppShareContactsErrorPayload = {
|
|
334
|
+
status: "error";
|
|
335
|
+
error_code: ShareContactsErrorCodes;
|
|
336
|
+
version: number;
|
|
337
|
+
};
|
|
338
|
+
type MiniAppShareContactsPayload = MiniAppShareContactsSuccessPayload | MiniAppShareContactsErrorPayload;
|
|
307
339
|
type EventPayloadMap = {
|
|
308
340
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
309
341
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -311,6 +343,7 @@ type EventPayloadMap = {
|
|
|
311
343
|
[ResponseEvent.MiniAppSendTransaction]: MiniAppSendTransactionPayload;
|
|
312
344
|
[ResponseEvent.MiniAppSignMessage]: MiniAppSignMessagePayload;
|
|
313
345
|
[ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
|
|
346
|
+
[ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
|
|
314
347
|
};
|
|
315
348
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
316
349
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -336,6 +369,9 @@ declare class MiniKit {
|
|
|
336
369
|
private static isCommandAvailable;
|
|
337
370
|
private static listeners;
|
|
338
371
|
static appId: string | null;
|
|
372
|
+
/**
|
|
373
|
+
* @deprecated you should use MiniKit.user.walletAddress instead
|
|
374
|
+
*/
|
|
339
375
|
static walletAddress: string | null;
|
|
340
376
|
static user: {
|
|
341
377
|
walletAddress: string | null;
|
|
@@ -357,6 +393,7 @@ declare class MiniKit {
|
|
|
357
393
|
sendTransaction: (payload: SendTransactionInput) => SendTransactionPayload | null;
|
|
358
394
|
signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
|
|
359
395
|
signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
|
|
396
|
+
shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
|
|
360
397
|
};
|
|
361
398
|
/**
|
|
362
399
|
* This object contains async versions of all the commands.
|
|
@@ -375,6 +412,7 @@ declare class MiniKit {
|
|
|
375
412
|
sendTransaction: (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
|
|
376
413
|
signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
|
|
377
414
|
signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
|
|
415
|
+
shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
|
|
378
416
|
};
|
|
379
417
|
}
|
|
380
418
|
|
|
@@ -396,4 +434,6 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
396
434
|
siweMessageData: SiweMessage;
|
|
397
435
|
}>;
|
|
398
436
|
|
|
399
|
-
|
|
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
|
@@ -15,6 +15,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
15
15
|
Command2["SendTransaction"] = "send-transaction";
|
|
16
16
|
Command2["SignMessage"] = "sign-message";
|
|
17
17
|
Command2["SignTypedData"] = "sign-typed-data";
|
|
18
|
+
Command2["ShareContacts"] = "share-contacts";
|
|
18
19
|
return Command2;
|
|
19
20
|
})(Command || {});
|
|
20
21
|
|
|
@@ -26,6 +27,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
26
27
|
ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
|
|
27
28
|
ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
|
|
28
29
|
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
30
|
+
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
29
31
|
return ResponseEvent2;
|
|
30
32
|
})(ResponseEvent || {});
|
|
31
33
|
|
|
@@ -159,6 +161,15 @@ var MiniKitInstallErrorMessage = {
|
|
|
159
161
|
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
160
162
|
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
161
163
|
};
|
|
164
|
+
var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
|
|
165
|
+
ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
|
|
166
|
+
ShareContactsErrorCodes2["GenericError"] = "generic_error";
|
|
167
|
+
return ShareContactsErrorCodes2;
|
|
168
|
+
})(ShareContactsErrorCodes || {});
|
|
169
|
+
var ShareContactsErrorMessage = {
|
|
170
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
171
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
172
|
+
};
|
|
162
173
|
|
|
163
174
|
// minikit.ts
|
|
164
175
|
import { VerificationLevel } from "@worldcoin/idkit-core";
|
|
@@ -540,7 +551,8 @@ _MiniKit.commandVersion = {
|
|
|
540
551
|
["wallet-auth" /* WalletAuth */]: 1,
|
|
541
552
|
["send-transaction" /* SendTransaction */]: 1,
|
|
542
553
|
["sign-message" /* SignMessage */]: 1,
|
|
543
|
-
["sign-typed-data" /* SignTypedData */]: 1
|
|
554
|
+
["sign-typed-data" /* SignTypedData */]: 1,
|
|
555
|
+
["share-contacts" /* ShareContacts */]: 1
|
|
544
556
|
};
|
|
545
557
|
_MiniKit.isCommandAvailable = {
|
|
546
558
|
["verify" /* Verify */]: false,
|
|
@@ -548,7 +560,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
548
560
|
["wallet-auth" /* WalletAuth */]: false,
|
|
549
561
|
["send-transaction" /* SendTransaction */]: false,
|
|
550
562
|
["sign-message" /* SignMessage */]: false,
|
|
551
|
-
["sign-typed-data" /* SignTypedData */]: false
|
|
563
|
+
["sign-typed-data" /* SignTypedData */]: false,
|
|
564
|
+
["share-contacts" /* ShareContacts */]: false
|
|
552
565
|
};
|
|
553
566
|
_MiniKit.listeners = {
|
|
554
567
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -562,9 +575,14 @@ _MiniKit.listeners = {
|
|
|
562
575
|
["miniapp-sign-message" /* MiniAppSignMessage */]: () => {
|
|
563
576
|
},
|
|
564
577
|
["miniapp-sign-typed-data" /* MiniAppSignTypedData */]: () => {
|
|
578
|
+
},
|
|
579
|
+
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
565
580
|
}
|
|
566
581
|
};
|
|
567
582
|
_MiniKit.appId = null;
|
|
583
|
+
/**
|
|
584
|
+
* @deprecated you should use MiniKit.user.walletAddress instead
|
|
585
|
+
*/
|
|
568
586
|
_MiniKit.walletAddress = null;
|
|
569
587
|
_MiniKit.user = null;
|
|
570
588
|
_MiniKit.commands = {
|
|
@@ -696,6 +714,20 @@ _MiniKit.commands = {
|
|
|
696
714
|
payload
|
|
697
715
|
});
|
|
698
716
|
return payload;
|
|
717
|
+
},
|
|
718
|
+
shareContacts: (payload) => {
|
|
719
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-typed-data" /* SignTypedData */]) {
|
|
720
|
+
console.error(
|
|
721
|
+
"'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
|
|
722
|
+
);
|
|
723
|
+
return null;
|
|
724
|
+
}
|
|
725
|
+
sendMiniKitEvent({
|
|
726
|
+
command: "share-contacts" /* ShareContacts */,
|
|
727
|
+
version: 1,
|
|
728
|
+
payload
|
|
729
|
+
});
|
|
730
|
+
return payload;
|
|
699
731
|
}
|
|
700
732
|
};
|
|
701
733
|
/**
|
|
@@ -792,6 +824,20 @@ _MiniKit.commandsAsync = {
|
|
|
792
824
|
reject(error);
|
|
793
825
|
}
|
|
794
826
|
});
|
|
827
|
+
},
|
|
828
|
+
shareContacts: async (payload) => {
|
|
829
|
+
return new Promise(async (resolve, reject) => {
|
|
830
|
+
try {
|
|
831
|
+
const response = await _MiniKit.awaitCommand(
|
|
832
|
+
"miniapp-share-contacts" /* MiniAppShareContacts */,
|
|
833
|
+
"share-contacts" /* ShareContacts */,
|
|
834
|
+
() => _MiniKit.commands.shareContacts(payload)
|
|
835
|
+
);
|
|
836
|
+
return resolve(response);
|
|
837
|
+
} catch (error) {
|
|
838
|
+
reject(error);
|
|
839
|
+
}
|
|
840
|
+
});
|
|
795
841
|
}
|
|
796
842
|
};
|
|
797
843
|
var MiniKit = _MiniKit;
|
|
@@ -801,6 +847,58 @@ import { VerificationLevel as VerificationLevel2 } from "@worldcoin/idkit-core";
|
|
|
801
847
|
import {
|
|
802
848
|
verifyCloudProof
|
|
803
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
|
+
};
|
|
804
902
|
export {
|
|
805
903
|
Command,
|
|
806
904
|
MiniKit,
|
|
@@ -814,6 +912,8 @@ export {
|
|
|
814
912
|
SAFE_CONTRACT_ABI,
|
|
815
913
|
SendTransactionErrorCodes,
|
|
816
914
|
SendTransactionErrorMessage,
|
|
915
|
+
ShareContactsErrorCodes,
|
|
916
|
+
ShareContactsErrorMessage,
|
|
817
917
|
SignMessageErrorCodes,
|
|
818
918
|
SignMessageErrorMessage,
|
|
819
919
|
SignTypedDataErrorCodes,
|
|
@@ -825,6 +925,7 @@ export {
|
|
|
825
925
|
VerificationLevel2 as VerificationLevel,
|
|
826
926
|
WalletAuthErrorCodes,
|
|
827
927
|
WalletAuthErrorMessage,
|
|
928
|
+
getIsUserVerified,
|
|
828
929
|
parseSiweMessage,
|
|
829
930
|
tokenToDecimals,
|
|
830
931
|
verifyCloudProof,
|
package/index.ts
CHANGED