@worldcoin/minikit-js 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.cjs CHANGED
@@ -442,6 +442,21 @@ var validatePaymentPayload = (payload) => {
442
442
  return true;
443
443
  };
444
444
 
445
+ // helpers/usernames/index.ts
446
+ var getUserProfile = async (address) => {
447
+ const res = await fetch("https://usernames.worldcoin.org/api/v1/query", {
448
+ method: "POST",
449
+ headers: {
450
+ "Content-Type": "application/json"
451
+ },
452
+ body: JSON.stringify({
453
+ addresses: [address]
454
+ })
455
+ });
456
+ const data = await res.json();
457
+ return data.usernames[0] ?? { username: null, profilePictureUrl: null };
458
+ };
459
+
445
460
  // minikit.ts
446
461
  var sendMiniKitEvent = (payload) => {
447
462
  sendWebviewEvent(payload);
@@ -459,6 +474,13 @@ var _MiniKit = class _MiniKit {
459
474
  const wrappedHandler = (payload) => {
460
475
  if (payload.status === "success") {
461
476
  _MiniKit.walletAddress = payload.address;
477
+ getUserProfile(payload.address).then((queryResponse) => {
478
+ _MiniKit.user = {
479
+ username: queryResponse.username,
480
+ profilePictureUrl: queryResponse.profilePictureUrl,
481
+ walletAddress: payload.address
482
+ };
483
+ });
462
484
  }
463
485
  originalHandler(payload);
464
486
  };
@@ -477,6 +499,17 @@ var _MiniKit = class _MiniKit {
477
499
  }
478
500
  this.listeners[event](payload);
479
501
  }
502
+ static async awaitCommand(event, command, executor) {
503
+ return new Promise((resolve) => {
504
+ let commandPayload = null;
505
+ const handleAndUnsubscribe = (payload) => {
506
+ this.unsubscribe(event);
507
+ resolve({ commandPayload, finalPayload: payload });
508
+ };
509
+ this.subscribe(event, handleAndUnsubscribe);
510
+ commandPayload = executor();
511
+ });
512
+ }
480
513
  static commandsValid(input) {
481
514
  return Object.entries(this.commandVersion).every(
482
515
  ([commandName, version]) => {
@@ -580,6 +613,7 @@ _MiniKit.listeners = {
580
613
  };
581
614
  _MiniKit.appId = null;
582
615
  _MiniKit.walletAddress = null;
616
+ _MiniKit.user = null;
583
617
  _MiniKit.commands = {
584
618
  verify: (payload) => {
585
619
  if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["verify" /* Verify */]) {
@@ -711,6 +745,102 @@ _MiniKit.commands = {
711
745
  return payload;
712
746
  }
713
747
  };
748
+ /**
749
+ * This object contains async versions of all the commands.
750
+ * Instead of using event listeners, you can just `await` these.
751
+ *
752
+ * They return a standardized object
753
+ *
754
+ * commandPayload - object returned by the command function
755
+ *
756
+ * finalPayload - object returned by the event listener, or in other words, WorldApp response
757
+ */
758
+ _MiniKit.commandsAsync = {
759
+ verify: async (payload) => {
760
+ return new Promise(async (resolve, reject) => {
761
+ try {
762
+ const response = await _MiniKit.awaitCommand(
763
+ "miniapp-verify-action" /* MiniAppVerifyAction */,
764
+ "verify" /* Verify */,
765
+ () => _MiniKit.commands.verify(payload)
766
+ );
767
+ resolve(response);
768
+ } catch (error) {
769
+ reject(error);
770
+ }
771
+ });
772
+ },
773
+ pay: async (payload) => {
774
+ return new Promise(async (resolve, reject) => {
775
+ try {
776
+ const response = await _MiniKit.awaitCommand(
777
+ "miniapp-payment" /* MiniAppPayment */,
778
+ "pay" /* Pay */,
779
+ () => _MiniKit.commands.pay(payload)
780
+ );
781
+ resolve(response);
782
+ } catch (error) {
783
+ reject(error);
784
+ }
785
+ });
786
+ },
787
+ walletAuth: async (payload) => {
788
+ return new Promise(async (resolve, reject) => {
789
+ try {
790
+ const response = await _MiniKit.awaitCommand(
791
+ "miniapp-wallet-auth" /* MiniAppWalletAuth */,
792
+ "wallet-auth" /* WalletAuth */,
793
+ () => _MiniKit.commands.walletAuth(payload)
794
+ );
795
+ return resolve(response);
796
+ } catch (error) {
797
+ reject(error);
798
+ }
799
+ });
800
+ },
801
+ sendTransaction: async (payload) => {
802
+ return new Promise(async (resolve, reject) => {
803
+ try {
804
+ const response = await _MiniKit.awaitCommand(
805
+ "miniapp-send-transaction" /* MiniAppSendTransaction */,
806
+ "send-transaction" /* SendTransaction */,
807
+ () => _MiniKit.commands.sendTransaction(payload)
808
+ );
809
+ return resolve(response);
810
+ } catch (error) {
811
+ reject(error);
812
+ }
813
+ });
814
+ },
815
+ signMessage: async (payload) => {
816
+ return new Promise(async (resolve, reject) => {
817
+ try {
818
+ const response = await _MiniKit.awaitCommand(
819
+ "miniapp-sign-message" /* MiniAppSignMessage */,
820
+ "sign-message" /* SignMessage */,
821
+ () => _MiniKit.commands.signMessage(payload)
822
+ );
823
+ return resolve(response);
824
+ } catch (error) {
825
+ reject(error);
826
+ }
827
+ });
828
+ },
829
+ signTypedData: async (payload) => {
830
+ return new Promise(async (resolve, reject) => {
831
+ try {
832
+ const response = await _MiniKit.awaitCommand(
833
+ "miniapp-sign-typed-data" /* MiniAppSignTypedData */,
834
+ "sign-typed-data" /* SignTypedData */,
835
+ () => _MiniKit.commands.signTypedData(payload)
836
+ );
837
+ return resolve(response);
838
+ } catch (error) {
839
+ reject(error);
840
+ }
841
+ });
842
+ }
843
+ };
714
844
  var MiniKit = _MiniKit;
715
845
 
716
846
  // index.ts
package/build/index.d.cts CHANGED
@@ -142,6 +142,10 @@ type WebViewBasePayload = {
142
142
  version: number;
143
143
  payload: Record<string, any>;
144
144
  };
145
+ type AsyncHandlerReturn<CommandPayload, FinalPayload> = Promise<{
146
+ commandPayload: CommandPayload;
147
+ finalPayload: FinalPayload;
148
+ }>;
145
149
  type VerifyCommandInput = {
146
150
  action: IDKitConfig["action"];
147
151
  signal?: IDKitConfig["signal"];
@@ -195,6 +199,15 @@ type SignTypedDataInput = {
195
199
  domain?: TypedDataDomain;
196
200
  };
197
201
  type SignTypedDataPayload = SignTypedDataInput;
202
+ type CommandReturnPayloadMap = {
203
+ [Command.Verify]: VerifyCommandPayload;
204
+ [Command.Pay]: PayCommandPayload;
205
+ [Command.WalletAuth]: WalletAuthPayload;
206
+ [Command.SendTransaction]: SendTransactionPayload;
207
+ [Command.SignMessage]: SignMessagePayload;
208
+ [Command.SignTypedData]: SignTypedDataPayload;
209
+ };
210
+ type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
198
211
 
199
212
  declare enum ResponseEvent {
200
213
  MiniAppVerifyAction = "miniapp-verify-action",
@@ -324,10 +337,16 @@ declare class MiniKit {
324
337
  private static listeners;
325
338
  static appId: string | null;
326
339
  static walletAddress: string | null;
340
+ static user: {
341
+ walletAddress: string | null;
342
+ username: string | null;
343
+ profilePictureUrl: string | null;
344
+ } | null;
327
345
  private static sendInit;
328
346
  static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
329
347
  static unsubscribe(event: ResponseEvent): void;
330
348
  static trigger(event: ResponseEvent, payload: EventPayload): void;
349
+ private static awaitCommand;
331
350
  private static commandsValid;
332
351
  static install(appId?: string): MiniKitInstallReturnType;
333
352
  static isInstalled(debug?: boolean): boolean;
@@ -339,6 +358,24 @@ declare class MiniKit {
339
358
  signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
340
359
  signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
341
360
  };
361
+ /**
362
+ * This object contains async versions of all the commands.
363
+ * Instead of using event listeners, you can just `await` these.
364
+ *
365
+ * They return a standardized object
366
+ *
367
+ * commandPayload - object returned by the command function
368
+ *
369
+ * finalPayload - object returned by the event listener, or in other words, WorldApp response
370
+ */
371
+ static commandsAsync: {
372
+ verify: (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
373
+ pay: (payload: PayCommandInput) => AsyncHandlerReturn<PayCommandPayload | null, MiniAppPaymentPayload>;
374
+ walletAuth: (payload: WalletAuthInput) => AsyncHandlerReturn<WalletAuthPayload | null, MiniAppWalletAuthPayload>;
375
+ sendTransaction: (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
376
+ signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
377
+ signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
378
+ };
342
379
  }
343
380
 
344
381
  declare const tokenToDecimals: (amount: number, token: Tokens) => number;
@@ -359,4 +396,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
359
396
  siweMessageData: SiweMessage;
360
397
  }>;
361
398
 
362
- export { Command, 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 };
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 };
package/build/index.d.ts CHANGED
@@ -142,6 +142,10 @@ type WebViewBasePayload = {
142
142
  version: number;
143
143
  payload: Record<string, any>;
144
144
  };
145
+ type AsyncHandlerReturn<CommandPayload, FinalPayload> = Promise<{
146
+ commandPayload: CommandPayload;
147
+ finalPayload: FinalPayload;
148
+ }>;
145
149
  type VerifyCommandInput = {
146
150
  action: IDKitConfig["action"];
147
151
  signal?: IDKitConfig["signal"];
@@ -195,6 +199,15 @@ type SignTypedDataInput = {
195
199
  domain?: TypedDataDomain;
196
200
  };
197
201
  type SignTypedDataPayload = SignTypedDataInput;
202
+ type CommandReturnPayloadMap = {
203
+ [Command.Verify]: VerifyCommandPayload;
204
+ [Command.Pay]: PayCommandPayload;
205
+ [Command.WalletAuth]: WalletAuthPayload;
206
+ [Command.SendTransaction]: SendTransactionPayload;
207
+ [Command.SignMessage]: SignMessagePayload;
208
+ [Command.SignTypedData]: SignTypedDataPayload;
209
+ };
210
+ type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
198
211
 
199
212
  declare enum ResponseEvent {
200
213
  MiniAppVerifyAction = "miniapp-verify-action",
@@ -324,10 +337,16 @@ declare class MiniKit {
324
337
  private static listeners;
325
338
  static appId: string | null;
326
339
  static walletAddress: string | null;
340
+ static user: {
341
+ walletAddress: string | null;
342
+ username: string | null;
343
+ profilePictureUrl: string | null;
344
+ } | null;
327
345
  private static sendInit;
328
346
  static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
329
347
  static unsubscribe(event: ResponseEvent): void;
330
348
  static trigger(event: ResponseEvent, payload: EventPayload): void;
349
+ private static awaitCommand;
331
350
  private static commandsValid;
332
351
  static install(appId?: string): MiniKitInstallReturnType;
333
352
  static isInstalled(debug?: boolean): boolean;
@@ -339,6 +358,24 @@ declare class MiniKit {
339
358
  signMessage: (payload: SignMessageInput) => SignMessagePayload | null;
340
359
  signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
341
360
  };
361
+ /**
362
+ * This object contains async versions of all the commands.
363
+ * Instead of using event listeners, you can just `await` these.
364
+ *
365
+ * They return a standardized object
366
+ *
367
+ * commandPayload - object returned by the command function
368
+ *
369
+ * finalPayload - object returned by the event listener, or in other words, WorldApp response
370
+ */
371
+ static commandsAsync: {
372
+ verify: (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
373
+ pay: (payload: PayCommandInput) => AsyncHandlerReturn<PayCommandPayload | null, MiniAppPaymentPayload>;
374
+ walletAuth: (payload: WalletAuthInput) => AsyncHandlerReturn<WalletAuthPayload | null, MiniAppWalletAuthPayload>;
375
+ sendTransaction: (payload: SendTransactionInput) => AsyncHandlerReturn<SendTransactionPayload | null, MiniAppSendTransactionPayload>;
376
+ signMessage: (payload: SignMessageInput) => AsyncHandlerReturn<SignMessagePayload | null, MiniAppSignMessagePayload>;
377
+ signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
378
+ };
342
379
  }
343
380
 
344
381
  declare const tokenToDecimals: (amount: number, token: Tokens) => number;
@@ -359,4 +396,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
359
396
  siweMessageData: SiweMessage;
360
397
  }>;
361
398
 
362
- export { Command, 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 };
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 };
package/build/index.js CHANGED
@@ -395,6 +395,21 @@ var validatePaymentPayload = (payload) => {
395
395
  return true;
396
396
  };
397
397
 
398
+ // helpers/usernames/index.ts
399
+ var getUserProfile = async (address) => {
400
+ const res = await fetch("https://usernames.worldcoin.org/api/v1/query", {
401
+ method: "POST",
402
+ headers: {
403
+ "Content-Type": "application/json"
404
+ },
405
+ body: JSON.stringify({
406
+ addresses: [address]
407
+ })
408
+ });
409
+ const data = await res.json();
410
+ return data.usernames[0] ?? { username: null, profilePictureUrl: null };
411
+ };
412
+
398
413
  // minikit.ts
399
414
  var sendMiniKitEvent = (payload) => {
400
415
  sendWebviewEvent(payload);
@@ -412,6 +427,13 @@ var _MiniKit = class _MiniKit {
412
427
  const wrappedHandler = (payload) => {
413
428
  if (payload.status === "success") {
414
429
  _MiniKit.walletAddress = payload.address;
430
+ getUserProfile(payload.address).then((queryResponse) => {
431
+ _MiniKit.user = {
432
+ username: queryResponse.username,
433
+ profilePictureUrl: queryResponse.profilePictureUrl,
434
+ walletAddress: payload.address
435
+ };
436
+ });
415
437
  }
416
438
  originalHandler(payload);
417
439
  };
@@ -430,6 +452,17 @@ var _MiniKit = class _MiniKit {
430
452
  }
431
453
  this.listeners[event](payload);
432
454
  }
455
+ static async awaitCommand(event, command, executor) {
456
+ return new Promise((resolve) => {
457
+ let commandPayload = null;
458
+ const handleAndUnsubscribe = (payload) => {
459
+ this.unsubscribe(event);
460
+ resolve({ commandPayload, finalPayload: payload });
461
+ };
462
+ this.subscribe(event, handleAndUnsubscribe);
463
+ commandPayload = executor();
464
+ });
465
+ }
433
466
  static commandsValid(input) {
434
467
  return Object.entries(this.commandVersion).every(
435
468
  ([commandName, version]) => {
@@ -533,6 +566,7 @@ _MiniKit.listeners = {
533
566
  };
534
567
  _MiniKit.appId = null;
535
568
  _MiniKit.walletAddress = null;
569
+ _MiniKit.user = null;
536
570
  _MiniKit.commands = {
537
571
  verify: (payload) => {
538
572
  if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["verify" /* Verify */]) {
@@ -664,6 +698,102 @@ _MiniKit.commands = {
664
698
  return payload;
665
699
  }
666
700
  };
701
+ /**
702
+ * This object contains async versions of all the commands.
703
+ * Instead of using event listeners, you can just `await` these.
704
+ *
705
+ * They return a standardized object
706
+ *
707
+ * commandPayload - object returned by the command function
708
+ *
709
+ * finalPayload - object returned by the event listener, or in other words, WorldApp response
710
+ */
711
+ _MiniKit.commandsAsync = {
712
+ verify: async (payload) => {
713
+ return new Promise(async (resolve, reject) => {
714
+ try {
715
+ const response = await _MiniKit.awaitCommand(
716
+ "miniapp-verify-action" /* MiniAppVerifyAction */,
717
+ "verify" /* Verify */,
718
+ () => _MiniKit.commands.verify(payload)
719
+ );
720
+ resolve(response);
721
+ } catch (error) {
722
+ reject(error);
723
+ }
724
+ });
725
+ },
726
+ pay: async (payload) => {
727
+ return new Promise(async (resolve, reject) => {
728
+ try {
729
+ const response = await _MiniKit.awaitCommand(
730
+ "miniapp-payment" /* MiniAppPayment */,
731
+ "pay" /* Pay */,
732
+ () => _MiniKit.commands.pay(payload)
733
+ );
734
+ resolve(response);
735
+ } catch (error) {
736
+ reject(error);
737
+ }
738
+ });
739
+ },
740
+ walletAuth: async (payload) => {
741
+ return new Promise(async (resolve, reject) => {
742
+ try {
743
+ const response = await _MiniKit.awaitCommand(
744
+ "miniapp-wallet-auth" /* MiniAppWalletAuth */,
745
+ "wallet-auth" /* WalletAuth */,
746
+ () => _MiniKit.commands.walletAuth(payload)
747
+ );
748
+ return resolve(response);
749
+ } catch (error) {
750
+ reject(error);
751
+ }
752
+ });
753
+ },
754
+ sendTransaction: async (payload) => {
755
+ return new Promise(async (resolve, reject) => {
756
+ try {
757
+ const response = await _MiniKit.awaitCommand(
758
+ "miniapp-send-transaction" /* MiniAppSendTransaction */,
759
+ "send-transaction" /* SendTransaction */,
760
+ () => _MiniKit.commands.sendTransaction(payload)
761
+ );
762
+ return resolve(response);
763
+ } catch (error) {
764
+ reject(error);
765
+ }
766
+ });
767
+ },
768
+ signMessage: async (payload) => {
769
+ return new Promise(async (resolve, reject) => {
770
+ try {
771
+ const response = await _MiniKit.awaitCommand(
772
+ "miniapp-sign-message" /* MiniAppSignMessage */,
773
+ "sign-message" /* SignMessage */,
774
+ () => _MiniKit.commands.signMessage(payload)
775
+ );
776
+ return resolve(response);
777
+ } catch (error) {
778
+ reject(error);
779
+ }
780
+ });
781
+ },
782
+ signTypedData: async (payload) => {
783
+ return new Promise(async (resolve, reject) => {
784
+ try {
785
+ const response = await _MiniKit.awaitCommand(
786
+ "miniapp-sign-typed-data" /* MiniAppSignTypedData */,
787
+ "sign-typed-data" /* SignTypedData */,
788
+ () => _MiniKit.commands.signTypedData(payload)
789
+ );
790
+ return resolve(response);
791
+ } catch (error) {
792
+ reject(error);
793
+ }
794
+ });
795
+ }
796
+ };
667
797
  var MiniKit = _MiniKit;
668
798
 
669
799
  // index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldcoin/minikit-js",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
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",