@worldcoin/minikit-js 1.9.10 → 1.9.11

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.
@@ -848,7 +848,7 @@ function createSignTypedDataAsyncCommand(ctx, syncCommand) {
848
848
  import { VerificationLevel } from "@worldcoin/idkit-core";
849
849
  import { encodeAction, generateSignal } from "@worldcoin/idkit-core/hashing";
850
850
  import { AppErrorCodes } from "@worldcoin/idkit-core";
851
- function createVerifyCommand(_ctx) {
851
+ function createVerifyCommand(ctx) {
852
852
  return (payload) => {
853
853
  if (typeof window === "undefined" || !isCommandAvailable("verify" /* Verify */)) {
854
854
  console.error(
@@ -867,6 +867,9 @@ function createVerifyCommand(_ctx) {
867
867
  verification_level: payload.verification_level || VerificationLevel.Orb,
868
868
  timestamp
869
869
  };
870
+ ctx.events.setVerifyActionProcessingOptions({
871
+ skip_proof_compression: payload.skip_proof_compression
872
+ });
870
873
  sendMiniKitEvent({
871
874
  command: "verify" /* Verify */,
872
875
  version: COMMAND_VERSIONS["verify" /* Verify */],
@@ -876,12 +879,22 @@ function createVerifyCommand(_ctx) {
876
879
  };
877
880
  }
878
881
  function createVerifyAsyncCommand(ctx, syncCommand) {
882
+ let hasInFlightVerifyRequest = false;
879
883
  return async (payload) => {
884
+ if (hasInFlightVerifyRequest) {
885
+ return Promise.reject(
886
+ new Error(
887
+ "A verify request is already in flight. Wait for the current request to complete before sending another."
888
+ )
889
+ );
890
+ }
880
891
  return new Promise((resolve, reject) => {
881
892
  try {
893
+ hasInFlightVerifyRequest = true;
882
894
  let commandPayload = null;
883
895
  const handleResponse = (response) => {
884
896
  ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
897
+ hasInFlightVerifyRequest = false;
885
898
  resolve({ commandPayload, finalPayload: response });
886
899
  };
887
900
  ctx.events.subscribe(
@@ -889,7 +902,17 @@ function createVerifyAsyncCommand(ctx, syncCommand) {
889
902
  handleResponse
890
903
  );
891
904
  commandPayload = syncCommand(payload);
905
+ if (commandPayload === null) {
906
+ ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
907
+ hasInFlightVerifyRequest = false;
908
+ reject(
909
+ new Error(
910
+ "Failed to send verify command. Ensure MiniKit is installed and the verify command is available."
911
+ )
912
+ );
913
+ }
892
914
  } catch (error) {
915
+ hasInFlightVerifyRequest = false;
893
916
  reject(error);
894
917
  }
895
918
  });
@@ -1464,6 +1487,7 @@ var EventManager = class {
1464
1487
  ["miniapp-chat" /* MiniAppChat */]: () => {
1465
1488
  }
1466
1489
  };
1490
+ this.verifyActionProcessingOptionsQueue = [];
1467
1491
  }
1468
1492
  subscribe(event, handler) {
1469
1493
  this.listeners[event] = handler;
@@ -1471,6 +1495,11 @@ var EventManager = class {
1471
1495
  unsubscribe(event) {
1472
1496
  delete this.listeners[event];
1473
1497
  }
1498
+ setVerifyActionProcessingOptions(options) {
1499
+ this.verifyActionProcessingOptionsQueue.push({
1500
+ skip_proof_compression: Boolean(options?.skip_proof_compression ?? false)
1501
+ });
1502
+ }
1474
1503
  trigger(event, payload) {
1475
1504
  if (!this.listeners[event]) {
1476
1505
  console.error(
@@ -1480,20 +1509,23 @@ var EventManager = class {
1480
1509
  }
1481
1510
  if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
1482
1511
  const handler = this.listeners[event];
1483
- this.unsubscribe(event);
1512
+ const processingOptions = this.verifyActionProcessingOptionsQueue.shift() ?? {
1513
+ skip_proof_compression: false
1514
+ };
1484
1515
  this.processVerifyActionPayload(
1485
1516
  payload,
1486
- handler
1517
+ handler,
1518
+ processingOptions
1487
1519
  );
1488
1520
  return;
1489
1521
  }
1490
1522
  this.listeners[event](payload);
1491
1523
  }
1492
- async processVerifyActionPayload(payload, handler) {
1524
+ async processVerifyActionPayload(payload, handler, processingOptions) {
1493
1525
  if (payload.status === "error" && payload.error_code === "user_rejected") {
1494
1526
  payload.error_code = AppErrorCodes4.VerificationRejected;
1495
1527
  }
1496
- if (payload.status === "success") {
1528
+ if (payload.status === "success" && !processingOptions.skip_proof_compression) {
1497
1529
  if ("verifications" in payload) {
1498
1530
  const orbVerification = payload.verifications.find(
1499
1531
  (v) => v.verification_level === VerificationLevel2.Orb
package/build/index.cjs CHANGED
@@ -944,7 +944,7 @@ function createSignTypedDataAsyncCommand(ctx, syncCommand) {
944
944
  var import_idkit_core = require("@worldcoin/idkit-core");
945
945
  var import_hashing = require("@worldcoin/idkit-core/hashing");
946
946
  var import_idkit_core2 = require("@worldcoin/idkit-core");
947
- function createVerifyCommand(_ctx) {
947
+ function createVerifyCommand(ctx) {
948
948
  return (payload) => {
949
949
  if (typeof window === "undefined" || !isCommandAvailable("verify" /* Verify */)) {
950
950
  console.error(
@@ -963,6 +963,9 @@ function createVerifyCommand(_ctx) {
963
963
  verification_level: payload.verification_level || import_idkit_core.VerificationLevel.Orb,
964
964
  timestamp
965
965
  };
966
+ ctx.events.setVerifyActionProcessingOptions({
967
+ skip_proof_compression: payload.skip_proof_compression
968
+ });
966
969
  sendMiniKitEvent({
967
970
  command: "verify" /* Verify */,
968
971
  version: COMMAND_VERSIONS["verify" /* Verify */],
@@ -972,12 +975,22 @@ function createVerifyCommand(_ctx) {
972
975
  };
973
976
  }
974
977
  function createVerifyAsyncCommand(ctx, syncCommand) {
978
+ let hasInFlightVerifyRequest = false;
975
979
  return async (payload) => {
980
+ if (hasInFlightVerifyRequest) {
981
+ return Promise.reject(
982
+ new Error(
983
+ "A verify request is already in flight. Wait for the current request to complete before sending another."
984
+ )
985
+ );
986
+ }
976
987
  return new Promise((resolve, reject) => {
977
988
  try {
989
+ hasInFlightVerifyRequest = true;
978
990
  let commandPayload = null;
979
991
  const handleResponse = (response) => {
980
992
  ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
993
+ hasInFlightVerifyRequest = false;
981
994
  resolve({ commandPayload, finalPayload: response });
982
995
  };
983
996
  ctx.events.subscribe(
@@ -985,7 +998,17 @@ function createVerifyAsyncCommand(ctx, syncCommand) {
985
998
  handleResponse
986
999
  );
987
1000
  commandPayload = syncCommand(payload);
1001
+ if (commandPayload === null) {
1002
+ ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
1003
+ hasInFlightVerifyRequest = false;
1004
+ reject(
1005
+ new Error(
1006
+ "Failed to send verify command. Ensure MiniKit is installed and the verify command is available."
1007
+ )
1008
+ );
1009
+ }
988
1010
  } catch (error) {
1011
+ hasInFlightVerifyRequest = false;
989
1012
  reject(error);
990
1013
  }
991
1014
  });
@@ -1491,6 +1514,7 @@ var EventManager = class {
1491
1514
  ["miniapp-chat" /* MiniAppChat */]: () => {
1492
1515
  }
1493
1516
  };
1517
+ this.verifyActionProcessingOptionsQueue = [];
1494
1518
  }
1495
1519
  subscribe(event, handler) {
1496
1520
  this.listeners[event] = handler;
@@ -1498,6 +1522,11 @@ var EventManager = class {
1498
1522
  unsubscribe(event) {
1499
1523
  delete this.listeners[event];
1500
1524
  }
1525
+ setVerifyActionProcessingOptions(options) {
1526
+ this.verifyActionProcessingOptionsQueue.push({
1527
+ skip_proof_compression: Boolean(options?.skip_proof_compression ?? false)
1528
+ });
1529
+ }
1501
1530
  trigger(event, payload) {
1502
1531
  if (!this.listeners[event]) {
1503
1532
  console.error(
@@ -1507,20 +1536,23 @@ var EventManager = class {
1507
1536
  }
1508
1537
  if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
1509
1538
  const handler = this.listeners[event];
1510
- this.unsubscribe(event);
1539
+ const processingOptions = this.verifyActionProcessingOptionsQueue.shift() ?? {
1540
+ skip_proof_compression: false
1541
+ };
1511
1542
  this.processVerifyActionPayload(
1512
1543
  payload,
1513
- handler
1544
+ handler,
1545
+ processingOptions
1514
1546
  );
1515
1547
  return;
1516
1548
  }
1517
1549
  this.listeners[event](payload);
1518
1550
  }
1519
- async processVerifyActionPayload(payload, handler) {
1551
+ async processVerifyActionPayload(payload, handler, processingOptions) {
1520
1552
  if (payload.status === "error" && payload.error_code === "user_rejected") {
1521
1553
  payload.error_code = import_idkit_core3.AppErrorCodes.VerificationRejected;
1522
1554
  }
1523
- if (payload.status === "success") {
1555
+ if (payload.status === "success" && !processingOptions.skip_proof_compression) {
1524
1556
  if ("verifications" in payload) {
1525
1557
  const orbVerification = payload.verifications.find(
1526
1558
  (v) => v.verification_level === import_idkit_core3.VerificationLevel.Orb
package/build/index.d.cts CHANGED
@@ -50,8 +50,12 @@ type EventPayload<T extends ResponseEvent = ResponseEvent> = any;
50
50
  type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
51
51
  declare class EventManager {
52
52
  private listeners;
53
+ private verifyActionProcessingOptionsQueue;
53
54
  subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
54
55
  unsubscribe(event: ResponseEvent): void;
56
+ setVerifyActionProcessingOptions(options?: {
57
+ skip_proof_compression?: boolean;
58
+ }): void;
55
59
  trigger(event: ResponseEvent, payload: EventPayload): void;
56
60
  private processVerifyActionPayload;
57
61
  private compressProofSafely;
@@ -527,8 +531,9 @@ type VerifyCommandInput = {
527
531
  action: IDKitConfig['action'];
528
532
  signal?: IDKitConfig['signal'];
529
533
  verification_level?: VerificationLevel | [VerificationLevel, ...VerificationLevel[]];
534
+ skip_proof_compression?: boolean;
530
535
  };
531
- type VerifyCommandPayload = VerifyCommandInput & {
536
+ type VerifyCommandPayload = Omit<VerifyCommandInput, 'skip_proof_compression'> & {
532
537
  timestamp: string;
533
538
  };
534
539
 
@@ -544,7 +549,7 @@ type MiniAppVerifyActionMultiSuccessPayload = MiniAppBaseSuccessPayload & {
544
549
  };
545
550
  type MiniAppVerifyActionErrorPayload = MiniAppBaseErrorPayload<string>;
546
551
  type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionMultiSuccessPayload | MiniAppVerifyActionErrorPayload;
547
- declare function createVerifyCommand(_ctx: CommandContext): (payload: VerifyCommandInput) => VerifyCommandPayload | null;
552
+ declare function createVerifyCommand(ctx: CommandContext): (payload: VerifyCommandInput) => VerifyCommandPayload | null;
548
553
  declare function createVerifyAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createVerifyCommand>): (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
549
554
 
550
555
  declare function createCommands(ctx: CommandContext): {
package/build/index.d.ts CHANGED
@@ -50,8 +50,12 @@ type EventPayload<T extends ResponseEvent = ResponseEvent> = any;
50
50
  type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
51
51
  declare class EventManager {
52
52
  private listeners;
53
+ private verifyActionProcessingOptionsQueue;
53
54
  subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
54
55
  unsubscribe(event: ResponseEvent): void;
56
+ setVerifyActionProcessingOptions(options?: {
57
+ skip_proof_compression?: boolean;
58
+ }): void;
55
59
  trigger(event: ResponseEvent, payload: EventPayload): void;
56
60
  private processVerifyActionPayload;
57
61
  private compressProofSafely;
@@ -527,8 +531,9 @@ type VerifyCommandInput = {
527
531
  action: IDKitConfig['action'];
528
532
  signal?: IDKitConfig['signal'];
529
533
  verification_level?: VerificationLevel | [VerificationLevel, ...VerificationLevel[]];
534
+ skip_proof_compression?: boolean;
530
535
  };
531
- type VerifyCommandPayload = VerifyCommandInput & {
536
+ type VerifyCommandPayload = Omit<VerifyCommandInput, 'skip_proof_compression'> & {
532
537
  timestamp: string;
533
538
  };
534
539
 
@@ -544,7 +549,7 @@ type MiniAppVerifyActionMultiSuccessPayload = MiniAppBaseSuccessPayload & {
544
549
  };
545
550
  type MiniAppVerifyActionErrorPayload = MiniAppBaseErrorPayload<string>;
546
551
  type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionMultiSuccessPayload | MiniAppVerifyActionErrorPayload;
547
- declare function createVerifyCommand(_ctx: CommandContext): (payload: VerifyCommandInput) => VerifyCommandPayload | null;
552
+ declare function createVerifyCommand(ctx: CommandContext): (payload: VerifyCommandInput) => VerifyCommandPayload | null;
548
553
  declare function createVerifyAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createVerifyCommand>): (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
549
554
 
550
555
  declare function createCommands(ctx: CommandContext): {
package/build/index.js CHANGED
@@ -67,7 +67,7 @@ import {
67
67
  tokenToDecimals,
68
68
  validateCommands,
69
69
  verifySiweMessage
70
- } from "./chunk-XFGJKKI2.js";
70
+ } from "./chunk-YDNDO45D.js";
71
71
 
72
72
  // index.ts
73
73
  import { VerificationLevel } from "@worldcoin/idkit-core";
@@ -664,7 +664,7 @@ function createSignTypedDataAsyncCommand(ctx, syncCommand) {
664
664
  var import_idkit_core = require("@worldcoin/idkit-core");
665
665
  var import_hashing = require("@worldcoin/idkit-core/hashing");
666
666
  var import_idkit_core2 = require("@worldcoin/idkit-core");
667
- function createVerifyCommand(_ctx) {
667
+ function createVerifyCommand(ctx) {
668
668
  return (payload) => {
669
669
  if (typeof window === "undefined" || !isCommandAvailable("verify" /* Verify */)) {
670
670
  console.error(
@@ -683,6 +683,9 @@ function createVerifyCommand(_ctx) {
683
683
  verification_level: payload.verification_level || import_idkit_core.VerificationLevel.Orb,
684
684
  timestamp
685
685
  };
686
+ ctx.events.setVerifyActionProcessingOptions({
687
+ skip_proof_compression: payload.skip_proof_compression
688
+ });
686
689
  sendMiniKitEvent({
687
690
  command: "verify" /* Verify */,
688
691
  version: COMMAND_VERSIONS["verify" /* Verify */],
@@ -692,12 +695,22 @@ function createVerifyCommand(_ctx) {
692
695
  };
693
696
  }
694
697
  function createVerifyAsyncCommand(ctx, syncCommand) {
698
+ let hasInFlightVerifyRequest = false;
695
699
  return async (payload) => {
700
+ if (hasInFlightVerifyRequest) {
701
+ return Promise.reject(
702
+ new Error(
703
+ "A verify request is already in flight. Wait for the current request to complete before sending another."
704
+ )
705
+ );
706
+ }
696
707
  return new Promise((resolve, reject) => {
697
708
  try {
709
+ hasInFlightVerifyRequest = true;
698
710
  let commandPayload = null;
699
711
  const handleResponse = (response) => {
700
712
  ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
713
+ hasInFlightVerifyRequest = false;
701
714
  resolve({ commandPayload, finalPayload: response });
702
715
  };
703
716
  ctx.events.subscribe(
@@ -705,7 +718,17 @@ function createVerifyAsyncCommand(ctx, syncCommand) {
705
718
  handleResponse
706
719
  );
707
720
  commandPayload = syncCommand(payload);
721
+ if (commandPayload === null) {
722
+ ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
723
+ hasInFlightVerifyRequest = false;
724
+ reject(
725
+ new Error(
726
+ "Failed to send verify command. Ensure MiniKit is installed and the verify command is available."
727
+ )
728
+ );
729
+ }
708
730
  } catch (error) {
731
+ hasInFlightVerifyRequest = false;
709
732
  reject(error);
710
733
  }
711
734
  });
@@ -986,6 +1009,7 @@ var EventManager = class {
986
1009
  ["miniapp-chat" /* MiniAppChat */]: () => {
987
1010
  }
988
1011
  };
1012
+ this.verifyActionProcessingOptionsQueue = [];
989
1013
  }
990
1014
  subscribe(event, handler) {
991
1015
  this.listeners[event] = handler;
@@ -993,6 +1017,11 @@ var EventManager = class {
993
1017
  unsubscribe(event) {
994
1018
  delete this.listeners[event];
995
1019
  }
1020
+ setVerifyActionProcessingOptions(options) {
1021
+ this.verifyActionProcessingOptionsQueue.push({
1022
+ skip_proof_compression: Boolean(options?.skip_proof_compression ?? false)
1023
+ });
1024
+ }
996
1025
  trigger(event, payload) {
997
1026
  if (!this.listeners[event]) {
998
1027
  console.error(
@@ -1002,20 +1031,23 @@ var EventManager = class {
1002
1031
  }
1003
1032
  if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
1004
1033
  const handler = this.listeners[event];
1005
- this.unsubscribe(event);
1034
+ const processingOptions = this.verifyActionProcessingOptionsQueue.shift() ?? {
1035
+ skip_proof_compression: false
1036
+ };
1006
1037
  this.processVerifyActionPayload(
1007
1038
  payload,
1008
- handler
1039
+ handler,
1040
+ processingOptions
1009
1041
  );
1010
1042
  return;
1011
1043
  }
1012
1044
  this.listeners[event](payload);
1013
1045
  }
1014
- async processVerifyActionPayload(payload, handler) {
1046
+ async processVerifyActionPayload(payload, handler, processingOptions) {
1015
1047
  if (payload.status === "error" && payload.error_code === "user_rejected") {
1016
1048
  payload.error_code = import_idkit_core3.AppErrorCodes.VerificationRejected;
1017
1049
  }
1018
- if (payload.status === "success") {
1050
+ if (payload.status === "success" && !processingOptions.skip_proof_compression) {
1019
1051
  if ("verifications" in payload) {
1020
1052
  const orbVerification = payload.verifications.find(
1021
1053
  (v) => v.verification_level === import_idkit_core3.VerificationLevel.Orb
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  MiniKit
4
- } from "./chunk-XFGJKKI2.js";
4
+ } from "./chunk-YDNDO45D.js";
5
5
 
6
6
  // minikit-provider.tsx
7
7
  import {
package/package.json CHANGED
@@ -78,7 +78,7 @@
78
78
  ]
79
79
  }
80
80
  },
81
- "version": "1.9.10",
81
+ "version": "1.9.11",
82
82
  "scripts": {
83
83
  "build": "tsup",
84
84
  "dev": "tsup --watch",