@worldcoin/minikit-js 1.2.0 → 1.3.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
@@ -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,
@@ -67,6 +69,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
67
69
  Command2["SendTransaction"] = "send-transaction";
68
70
  Command2["SignMessage"] = "sign-message";
69
71
  Command2["SignTypedData"] = "sign-typed-data";
72
+ Command2["ShareContacts"] = "share-contacts";
70
73
  return Command2;
71
74
  })(Command || {});
72
75
 
@@ -78,6 +81,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
78
81
  ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
79
82
  ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
80
83
  ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
84
+ ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
81
85
  return ResponseEvent2;
82
86
  })(ResponseEvent || {});
83
87
 
@@ -211,6 +215,15 @@ var MiniKitInstallErrorMessage = {
211
215
  ["not_on_client" /* NotOnClient */]: "Window object is not available.",
212
216
  ["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
213
217
  };
218
+ var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
219
+ ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
220
+ ShareContactsErrorCodes2["GenericError"] = "generic_error";
221
+ return ShareContactsErrorCodes2;
222
+ })(ShareContactsErrorCodes || {});
223
+ var ShareContactsErrorMessage = {
224
+ ["user_rejected" /* UserRejected */]: "User rejected the request.",
225
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong."
226
+ };
214
227
 
215
228
  // minikit.ts
216
229
  var import_idkit_core3 = require("@worldcoin/idkit-core");
@@ -587,7 +600,8 @@ _MiniKit.commandVersion = {
587
600
  ["wallet-auth" /* WalletAuth */]: 1,
588
601
  ["send-transaction" /* SendTransaction */]: 1,
589
602
  ["sign-message" /* SignMessage */]: 1,
590
- ["sign-typed-data" /* SignTypedData */]: 1
603
+ ["sign-typed-data" /* SignTypedData */]: 1,
604
+ ["share-contacts" /* ShareContacts */]: 1
591
605
  };
592
606
  _MiniKit.isCommandAvailable = {
593
607
  ["verify" /* Verify */]: false,
@@ -595,7 +609,8 @@ _MiniKit.isCommandAvailable = {
595
609
  ["wallet-auth" /* WalletAuth */]: false,
596
610
  ["send-transaction" /* SendTransaction */]: false,
597
611
  ["sign-message" /* SignMessage */]: false,
598
- ["sign-typed-data" /* SignTypedData */]: false
612
+ ["sign-typed-data" /* SignTypedData */]: false,
613
+ ["share-contacts" /* ShareContacts */]: false
599
614
  };
600
615
  _MiniKit.listeners = {
601
616
  ["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
@@ -609,6 +624,8 @@ _MiniKit.listeners = {
609
624
  ["miniapp-sign-message" /* MiniAppSignMessage */]: () => {
610
625
  },
611
626
  ["miniapp-sign-typed-data" /* MiniAppSignTypedData */]: () => {
627
+ },
628
+ ["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
612
629
  }
613
630
  };
614
631
  _MiniKit.appId = null;
@@ -743,6 +760,20 @@ _MiniKit.commands = {
743
760
  payload
744
761
  });
745
762
  return payload;
763
+ },
764
+ shareContacts: (payload) => {
765
+ if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-typed-data" /* SignTypedData */]) {
766
+ console.error(
767
+ "'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
768
+ );
769
+ return null;
770
+ }
771
+ sendMiniKitEvent({
772
+ command: "share-contacts" /* ShareContacts */,
773
+ version: 1,
774
+ payload
775
+ });
776
+ return payload;
746
777
  }
747
778
  };
748
779
  /**
@@ -839,6 +870,20 @@ _MiniKit.commandsAsync = {
839
870
  reject(error);
840
871
  }
841
872
  });
873
+ },
874
+ shareContacts: async (payload) => {
875
+ return new Promise(async (resolve, reject) => {
876
+ try {
877
+ const response = await _MiniKit.awaitCommand(
878
+ "miniapp-share-contacts" /* MiniAppShareContacts */,
879
+ "share-contacts" /* ShareContacts */,
880
+ () => _MiniKit.commands.shareContacts(payload)
881
+ );
882
+ return resolve(response);
883
+ } catch (error) {
884
+ reject(error);
885
+ }
886
+ });
842
887
  }
843
888
  };
844
889
  var MiniKit = _MiniKit;
@@ -860,6 +905,8 @@ var import_backend = require("@worldcoin/idkit-core/backend");
860
905
  SAFE_CONTRACT_ABI,
861
906
  SendTransactionErrorCodes,
862
907
  SendTransactionErrorMessage,
908
+ ShareContactsErrorCodes,
909
+ ShareContactsErrorMessage,
863
910
  SignMessageErrorCodes,
864
911
  SignMessageErrorMessage,
865
912
  SignTypedDataErrorCodes,
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;
@@ -357,6 +390,7 @@ declare class MiniKit {
357
390
  sendTransaction: (payload: SendTransactionInput) => SendTransactionPayload | null;
358
391
  signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
359
392
  signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
393
+ shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
360
394
  };
361
395
  /**
362
396
  * This object contains async versions of all the commands.
@@ -375,6 +409,7 @@ declare class MiniKit {
375
409
  sendTransaction: (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
376
410
  signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
377
411
  signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
412
+ shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
378
413
  };
379
414
  }
380
415
 
@@ -396,4 +431,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
396
431
  siweMessageData: SiweMessage;
397
432
  }>;
398
433
 
399
- export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, 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, 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 };
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 };
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;
@@ -357,6 +390,7 @@ declare class MiniKit {
357
390
  sendTransaction: (payload: SendTransactionInput) => SendTransactionPayload | null;
358
391
  signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
359
392
  signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
393
+ shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
360
394
  };
361
395
  /**
362
396
  * This object contains async versions of all the commands.
@@ -375,6 +409,7 @@ declare class MiniKit {
375
409
  sendTransaction: (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
376
410
  signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
377
411
  signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
412
+ shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
378
413
  };
379
414
  }
380
415
 
@@ -396,4 +431,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
396
431
  siweMessageData: SiweMessage;
397
432
  }>;
398
433
 
399
- export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, 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, 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 };
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 };
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,6 +575,8 @@ _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;
@@ -696,6 +711,20 @@ _MiniKit.commands = {
696
711
  payload
697
712
  });
698
713
  return payload;
714
+ },
715
+ shareContacts: (payload) => {
716
+ if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-typed-data" /* SignTypedData */]) {
717
+ console.error(
718
+ "'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
719
+ );
720
+ return null;
721
+ }
722
+ sendMiniKitEvent({
723
+ command: "share-contacts" /* ShareContacts */,
724
+ version: 1,
725
+ payload
726
+ });
727
+ return payload;
699
728
  }
700
729
  };
701
730
  /**
@@ -792,6 +821,20 @@ _MiniKit.commandsAsync = {
792
821
  reject(error);
793
822
  }
794
823
  });
824
+ },
825
+ shareContacts: async (payload) => {
826
+ return new Promise(async (resolve, reject) => {
827
+ try {
828
+ const response = await _MiniKit.awaitCommand(
829
+ "miniapp-share-contacts" /* MiniAppShareContacts */,
830
+ "share-contacts" /* ShareContacts */,
831
+ () => _MiniKit.commands.shareContacts(payload)
832
+ );
833
+ return resolve(response);
834
+ } catch (error) {
835
+ reject(error);
836
+ }
837
+ });
795
838
  }
796
839
  };
797
840
  var MiniKit = _MiniKit;
@@ -814,6 +857,8 @@ export {
814
857
  SAFE_CONTRACT_ABI,
815
858
  SendTransactionErrorCodes,
816
859
  SendTransactionErrorMessage,
860
+ ShareContactsErrorCodes,
861
+ ShareContactsErrorMessage,
817
862
  SignMessageErrorCodes,
818
863
  SignMessageErrorMessage,
819
864
  SignTypedDataErrorCodes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldcoin/minikit-js",
3
- "version": "1.2.0",
3
+ "version": "1.3.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",