@worldcoin/minikit-js 1.7.1 → 1.8.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 -29
- package/build/index.d.cts +4 -2
- package/build/index.d.ts +4 -2
- package/build/index.js +110 -28
- package/package.json +3 -3
package/build/index.cjs
CHANGED
|
@@ -110,9 +110,63 @@ var validatePaymentPayload = (payload) => {
|
|
|
110
110
|
return true;
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
// helpers/
|
|
113
|
+
// helpers/proof/index.ts
|
|
114
114
|
var import_viem = require("viem");
|
|
115
115
|
var import_chains = require("viem/chains");
|
|
116
|
+
var semaphoreVerifierAddress = "0x79f46b94d134109EbcbbddBAeD0E88790409A0e4";
|
|
117
|
+
var semaphoreVerifierAbi = [
|
|
118
|
+
{
|
|
119
|
+
inputs: [
|
|
120
|
+
{
|
|
121
|
+
internalType: "uint256[8]",
|
|
122
|
+
name: "proof",
|
|
123
|
+
type: "uint256[8]"
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
name: "compressProof",
|
|
127
|
+
outputs: [
|
|
128
|
+
{
|
|
129
|
+
internalType: "uint256[4]",
|
|
130
|
+
name: "compressed",
|
|
131
|
+
type: "uint256[4]"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
stateMutability: "view",
|
|
135
|
+
type: "function"
|
|
136
|
+
}
|
|
137
|
+
];
|
|
138
|
+
var compressAndPadProof = async (proof, rpcUrl) => {
|
|
139
|
+
try {
|
|
140
|
+
const publicClient = (0, import_viem.createPublicClient)({
|
|
141
|
+
chain: import_chains.worldchain,
|
|
142
|
+
transport: (0, import_viem.http)(
|
|
143
|
+
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
144
|
+
)
|
|
145
|
+
});
|
|
146
|
+
const decodedProof = (0, import_viem.decodeAbiParameters)(
|
|
147
|
+
[{ type: "uint256[8]" }],
|
|
148
|
+
proof
|
|
149
|
+
)[0];
|
|
150
|
+
const compressedProof = await publicClient.readContract({
|
|
151
|
+
address: semaphoreVerifierAddress,
|
|
152
|
+
abi: semaphoreVerifierAbi,
|
|
153
|
+
functionName: "compressProof",
|
|
154
|
+
args: [decodedProof]
|
|
155
|
+
});
|
|
156
|
+
const paddedProof = [...compressedProof, 0n, 0n, 0n, 0n];
|
|
157
|
+
return (0, import_viem.encodeAbiParameters)([{ type: "uint256[8]" }], [paddedProof]);
|
|
158
|
+
} catch (e) {
|
|
159
|
+
console.log("Failed to compress proof", {
|
|
160
|
+
e,
|
|
161
|
+
proof
|
|
162
|
+
});
|
|
163
|
+
return proof;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// helpers/siwe/siwe.ts
|
|
168
|
+
var import_viem2 = require("viem");
|
|
169
|
+
var import_chains2 = require("viem/chains");
|
|
116
170
|
var PREAMBLE = " wants you to sign in with your Ethereum account:";
|
|
117
171
|
var URI_TAG = "URI: ";
|
|
118
172
|
var VERSION_TAG = "Version: ";
|
|
@@ -273,16 +327,16 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
|
|
|
273
327
|
`Request ID mismatch. Got: ${siweMessageData.request_id}, Expected: ${requestId}`
|
|
274
328
|
);
|
|
275
329
|
}
|
|
276
|
-
let provider = userProvider || (0,
|
|
330
|
+
let provider = userProvider || (0, import_viem2.createPublicClient)({ chain: import_chains2.worldchain, transport: (0, import_viem2.http)() });
|
|
277
331
|
const signedMessage = `${ERC_191_PREFIX}${message.length}${message}`;
|
|
278
|
-
const hashedMessage = (0,
|
|
279
|
-
const contract = (0,
|
|
332
|
+
const hashedMessage = (0, import_viem2.hashMessage)(signedMessage);
|
|
333
|
+
const contract = (0, import_viem2.getContract)({
|
|
280
334
|
address,
|
|
281
335
|
abi: SAFE_CONTRACT_ABI,
|
|
282
336
|
client: provider
|
|
283
337
|
});
|
|
284
338
|
try {
|
|
285
|
-
const recoveredAddress = await (0,
|
|
339
|
+
const recoveredAddress = await (0, import_viem2.recoverAddress)({
|
|
286
340
|
hash: hashedMessage,
|
|
287
341
|
signature: `0x${signature}`
|
|
288
342
|
});
|
|
@@ -327,7 +381,7 @@ var processPayload = (payload) => {
|
|
|
327
381
|
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
328
382
|
return payload;
|
|
329
383
|
}
|
|
330
|
-
if (typeof payload === "number") {
|
|
384
|
+
if (typeof payload === "number" || typeof payload === "bigint") {
|
|
331
385
|
return String(payload);
|
|
332
386
|
}
|
|
333
387
|
if (Array.isArray(payload)) {
|
|
@@ -393,6 +447,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
393
447
|
})(Command || {});
|
|
394
448
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
395
449
|
Permission2["Notifications"] = "notifications";
|
|
450
|
+
Permission2["Contacts"] = "contacts";
|
|
396
451
|
return Permission2;
|
|
397
452
|
})(Permission || {});
|
|
398
453
|
|
|
@@ -414,6 +469,7 @@ var VerificationErrorMessage = {
|
|
|
414
469
|
};
|
|
415
470
|
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
416
471
|
PaymentErrorCodes2["InputError"] = "input_error";
|
|
472
|
+
PaymentErrorCodes2["UserRejected"] = "user_rejected";
|
|
417
473
|
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
418
474
|
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
419
475
|
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
@@ -424,6 +480,7 @@ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
|
424
480
|
})(PaymentErrorCodes || {});
|
|
425
481
|
var PaymentErrorMessage = {
|
|
426
482
|
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
483
|
+
["user_rejected" /* UserRejected */]: "You have cancelled the payment in World App.",
|
|
427
484
|
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
428
485
|
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
429
486
|
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
@@ -616,6 +673,21 @@ var _MiniKit = class _MiniKit {
|
|
|
616
673
|
originalHandler(payload);
|
|
617
674
|
};
|
|
618
675
|
this.listeners[event] = wrappedHandler;
|
|
676
|
+
} else if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
677
|
+
const originalHandler = handler;
|
|
678
|
+
const wrappedHandler = (payload) => {
|
|
679
|
+
if (payload.status === "success" && payload.verification_level === import_idkit_core3.VerificationLevel.Orb) {
|
|
680
|
+
compressAndPadProof(payload.proof).then(
|
|
681
|
+
(compressedProof) => {
|
|
682
|
+
payload.proof = compressedProof;
|
|
683
|
+
originalHandler(payload);
|
|
684
|
+
}
|
|
685
|
+
);
|
|
686
|
+
} else {
|
|
687
|
+
originalHandler(payload);
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
this.listeners[event] = wrappedHandler;
|
|
619
691
|
} else {
|
|
620
692
|
this.listeners[event] = handler;
|
|
621
693
|
}
|
|
@@ -641,18 +713,18 @@ var _MiniKit = class _MiniKit {
|
|
|
641
713
|
commandPayload = executor();
|
|
642
714
|
});
|
|
643
715
|
}
|
|
644
|
-
static commandsValid(
|
|
645
|
-
return Object.entries(this.
|
|
646
|
-
([
|
|
647
|
-
const commandInput =
|
|
648
|
-
(command) => command.name ===
|
|
716
|
+
static commandsValid(worldAppSupportedCommands) {
|
|
717
|
+
return Object.entries(this.miniKitCommandVersion).every(
|
|
718
|
+
([minikitCommandName, version]) => {
|
|
719
|
+
const commandInput = worldAppSupportedCommands.find(
|
|
720
|
+
(command) => command.name === minikitCommandName
|
|
649
721
|
);
|
|
650
722
|
if (!commandInput) {
|
|
651
723
|
console.error(
|
|
652
|
-
`Command ${
|
|
724
|
+
`Command ${minikitCommandName} is not supported by the app. Try updating the app version`
|
|
653
725
|
);
|
|
654
726
|
} else {
|
|
655
|
-
_MiniKit.isCommandAvailable[
|
|
727
|
+
_MiniKit.isCommandAvailable[minikitCommandName] = true;
|
|
656
728
|
}
|
|
657
729
|
return commandInput ? commandInput.supported_versions.includes(version) : false;
|
|
658
730
|
}
|
|
@@ -712,7 +784,7 @@ var _MiniKit = class _MiniKit {
|
|
|
712
784
|
}
|
|
713
785
|
};
|
|
714
786
|
_MiniKit.MINIKIT_VERSION = 1;
|
|
715
|
-
_MiniKit.
|
|
787
|
+
_MiniKit.miniKitCommandVersion = {
|
|
716
788
|
["verify" /* Verify */]: 1,
|
|
717
789
|
["pay" /* Pay */]: 1,
|
|
718
790
|
["wallet-auth" /* WalletAuth */]: 1,
|
|
@@ -789,7 +861,7 @@ _MiniKit.commands = {
|
|
|
789
861
|
};
|
|
790
862
|
sendMiniKitEvent({
|
|
791
863
|
command: "verify" /* Verify */,
|
|
792
|
-
version: _MiniKit.
|
|
864
|
+
version: _MiniKit.miniKitCommandVersion["verify" /* Verify */],
|
|
793
865
|
payload: eventPayload
|
|
794
866
|
});
|
|
795
867
|
return eventPayload;
|
|
@@ -811,7 +883,7 @@ _MiniKit.commands = {
|
|
|
811
883
|
};
|
|
812
884
|
sendMiniKitEvent({
|
|
813
885
|
command: "pay" /* Pay */,
|
|
814
|
-
version: _MiniKit.
|
|
886
|
+
version: _MiniKit.miniKitCommandVersion["pay" /* Pay */],
|
|
815
887
|
payload: eventPayload
|
|
816
888
|
});
|
|
817
889
|
return eventPayload;
|
|
@@ -855,7 +927,7 @@ _MiniKit.commands = {
|
|
|
855
927
|
const walletAuthPayload = { siweMessage };
|
|
856
928
|
sendMiniKitEvent({
|
|
857
929
|
command: "wallet-auth" /* WalletAuth */,
|
|
858
|
-
version: _MiniKit.
|
|
930
|
+
version: _MiniKit.miniKitCommandVersion["wallet-auth" /* WalletAuth */],
|
|
859
931
|
payload: walletAuthPayload
|
|
860
932
|
});
|
|
861
933
|
return walletAuthPayload;
|
|
@@ -870,7 +942,7 @@ _MiniKit.commands = {
|
|
|
870
942
|
const validatedPayload = validateSendTransactionPayload(payload);
|
|
871
943
|
sendMiniKitEvent({
|
|
872
944
|
command: "send-transaction" /* SendTransaction */,
|
|
873
|
-
version:
|
|
945
|
+
version: _MiniKit.miniKitCommandVersion["send-transaction" /* SendTransaction */],
|
|
874
946
|
payload: validatedPayload
|
|
875
947
|
});
|
|
876
948
|
return validatedPayload;
|
|
@@ -884,7 +956,7 @@ _MiniKit.commands = {
|
|
|
884
956
|
}
|
|
885
957
|
sendMiniKitEvent({
|
|
886
958
|
command: "sign-message" /* SignMessage */,
|
|
887
|
-
version:
|
|
959
|
+
version: _MiniKit.miniKitCommandVersion["sign-message" /* SignMessage */],
|
|
888
960
|
payload
|
|
889
961
|
});
|
|
890
962
|
return payload;
|
|
@@ -898,7 +970,7 @@ _MiniKit.commands = {
|
|
|
898
970
|
}
|
|
899
971
|
sendMiniKitEvent({
|
|
900
972
|
command: "sign-typed-data" /* SignTypedData */,
|
|
901
|
-
version:
|
|
973
|
+
version: _MiniKit.miniKitCommandVersion["sign-typed-data" /* SignTypedData */],
|
|
902
974
|
payload
|
|
903
975
|
});
|
|
904
976
|
return payload;
|
|
@@ -912,7 +984,7 @@ _MiniKit.commands = {
|
|
|
912
984
|
}
|
|
913
985
|
sendMiniKitEvent({
|
|
914
986
|
command: "share-contacts" /* ShareContacts */,
|
|
915
|
-
version:
|
|
987
|
+
version: _MiniKit.miniKitCommandVersion["share-contacts" /* ShareContacts */],
|
|
916
988
|
payload
|
|
917
989
|
});
|
|
918
990
|
return payload;
|
|
@@ -926,7 +998,7 @@ _MiniKit.commands = {
|
|
|
926
998
|
}
|
|
927
999
|
sendMiniKitEvent({
|
|
928
1000
|
command: "request-permission" /* RequestPermission */,
|
|
929
|
-
version:
|
|
1001
|
+
version: _MiniKit.miniKitCommandVersion["request-permission" /* RequestPermission */],
|
|
930
1002
|
payload
|
|
931
1003
|
});
|
|
932
1004
|
return payload;
|
|
@@ -940,7 +1012,7 @@ _MiniKit.commands = {
|
|
|
940
1012
|
}
|
|
941
1013
|
sendMiniKitEvent({
|
|
942
1014
|
command: "get-permissions" /* GetPermissions */,
|
|
943
|
-
version:
|
|
1015
|
+
version: _MiniKit.miniKitCommandVersion["get-permissions" /* GetPermissions */],
|
|
944
1016
|
payload: {}
|
|
945
1017
|
});
|
|
946
1018
|
return {
|
|
@@ -956,7 +1028,7 @@ _MiniKit.commands = {
|
|
|
956
1028
|
}
|
|
957
1029
|
sendMiniKitEvent({
|
|
958
1030
|
command: "send-haptic-feedback" /* SendHapticFeedback */,
|
|
959
|
-
version:
|
|
1031
|
+
version: _MiniKit.miniKitCommandVersion["send-haptic-feedback" /* SendHapticFeedback */],
|
|
960
1032
|
payload
|
|
961
1033
|
});
|
|
962
1034
|
return payload;
|
|
@@ -981,6 +1053,11 @@ _MiniKit.commandsAsync = {
|
|
|
981
1053
|
"verify" /* Verify */,
|
|
982
1054
|
() => _MiniKit.commands.verify(payload)
|
|
983
1055
|
);
|
|
1056
|
+
if (response.finalPayload.status === "success" && response.finalPayload.verification_level === import_idkit_core3.VerificationLevel.Orb) {
|
|
1057
|
+
response.finalPayload.proof = await compressAndPadProof(
|
|
1058
|
+
response.finalPayload.proof
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
984
1061
|
resolve(response);
|
|
985
1062
|
} catch (error) {
|
|
986
1063
|
reject(error);
|
|
@@ -1121,8 +1198,8 @@ var import_idkit_core4 = require("@worldcoin/idkit-core");
|
|
|
1121
1198
|
var import_backend = require("@worldcoin/idkit-core/backend");
|
|
1122
1199
|
|
|
1123
1200
|
// helpers/address-book/index.ts
|
|
1124
|
-
var
|
|
1125
|
-
var
|
|
1201
|
+
var import_viem3 = require("viem");
|
|
1202
|
+
var import_chains3 = require("viem/chains");
|
|
1126
1203
|
var worldIdAddressBookContractAddress = "0x57b930D551e677CC36e2fA036Ae2fe8FdaE0330D";
|
|
1127
1204
|
var addressVerifiedUntilAbi = [
|
|
1128
1205
|
{
|
|
@@ -1146,9 +1223,9 @@ var addressVerifiedUntilAbi = [
|
|
|
1146
1223
|
}
|
|
1147
1224
|
];
|
|
1148
1225
|
var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
1149
|
-
const publicClient = (0,
|
|
1150
|
-
chain:
|
|
1151
|
-
transport: (0,
|
|
1226
|
+
const publicClient = (0, import_viem3.createPublicClient)({
|
|
1227
|
+
chain: import_chains3.worldchain,
|
|
1228
|
+
transport: (0, import_viem3.http)(
|
|
1152
1229
|
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
1153
1230
|
)
|
|
1154
1231
|
});
|
package/build/index.d.cts
CHANGED
|
@@ -7,6 +7,7 @@ import { Client } from 'viem';
|
|
|
7
7
|
declare const VerificationErrorMessage: Record<AppErrorCodes, string>;
|
|
8
8
|
declare enum PaymentErrorCodes {
|
|
9
9
|
InputError = "input_error",
|
|
10
|
+
UserRejected = "user_rejected",
|
|
10
11
|
PaymentRejected = "payment_rejected",
|
|
11
12
|
InvalidReceiver = "invalid_receiver",
|
|
12
13
|
InsufficientBalance = "insufficient_balance",
|
|
@@ -240,7 +241,8 @@ type ShareContactsInput = {
|
|
|
240
241
|
};
|
|
241
242
|
type ShareContactsPayload = ShareContactsInput;
|
|
242
243
|
declare enum Permission {
|
|
243
|
-
Notifications = "notifications"
|
|
244
|
+
Notifications = "notifications",
|
|
245
|
+
Contacts = "contacts"
|
|
244
246
|
}
|
|
245
247
|
type RequestPermissionInput = {
|
|
246
248
|
permission: Permission;
|
|
@@ -454,7 +456,7 @@ type User = {
|
|
|
454
456
|
|
|
455
457
|
declare class MiniKit {
|
|
456
458
|
private static readonly MINIKIT_VERSION;
|
|
457
|
-
private static readonly
|
|
459
|
+
private static readonly miniKitCommandVersion;
|
|
458
460
|
private static isCommandAvailable;
|
|
459
461
|
private static listeners;
|
|
460
462
|
static appId: string | null;
|
package/build/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Client } from 'viem';
|
|
|
7
7
|
declare const VerificationErrorMessage: Record<AppErrorCodes, string>;
|
|
8
8
|
declare enum PaymentErrorCodes {
|
|
9
9
|
InputError = "input_error",
|
|
10
|
+
UserRejected = "user_rejected",
|
|
10
11
|
PaymentRejected = "payment_rejected",
|
|
11
12
|
InvalidReceiver = "invalid_receiver",
|
|
12
13
|
InsufficientBalance = "insufficient_balance",
|
|
@@ -240,7 +241,8 @@ type ShareContactsInput = {
|
|
|
240
241
|
};
|
|
241
242
|
type ShareContactsPayload = ShareContactsInput;
|
|
242
243
|
declare enum Permission {
|
|
243
|
-
Notifications = "notifications"
|
|
244
|
+
Notifications = "notifications",
|
|
245
|
+
Contacts = "contacts"
|
|
244
246
|
}
|
|
245
247
|
type RequestPermissionInput = {
|
|
246
248
|
permission: Permission;
|
|
@@ -454,7 +456,7 @@ type User = {
|
|
|
454
456
|
|
|
455
457
|
declare class MiniKit {
|
|
456
458
|
private static readonly MINIKIT_VERSION;
|
|
457
|
-
private static readonly
|
|
459
|
+
private static readonly miniKitCommandVersion;
|
|
458
460
|
private static isCommandAvailable;
|
|
459
461
|
private static listeners;
|
|
460
462
|
static appId: string | null;
|
package/build/index.js
CHANGED
|
@@ -48,15 +48,74 @@ var validatePaymentPayload = (payload) => {
|
|
|
48
48
|
return true;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
// helpers/
|
|
51
|
+
// helpers/proof/index.ts
|
|
52
52
|
import {
|
|
53
53
|
createPublicClient,
|
|
54
|
+
decodeAbiParameters,
|
|
55
|
+
encodeAbiParameters,
|
|
56
|
+
http
|
|
57
|
+
} from "viem";
|
|
58
|
+
import { worldchain } from "viem/chains";
|
|
59
|
+
var semaphoreVerifierAddress = "0x79f46b94d134109EbcbbddBAeD0E88790409A0e4";
|
|
60
|
+
var semaphoreVerifierAbi = [
|
|
61
|
+
{
|
|
62
|
+
inputs: [
|
|
63
|
+
{
|
|
64
|
+
internalType: "uint256[8]",
|
|
65
|
+
name: "proof",
|
|
66
|
+
type: "uint256[8]"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
name: "compressProof",
|
|
70
|
+
outputs: [
|
|
71
|
+
{
|
|
72
|
+
internalType: "uint256[4]",
|
|
73
|
+
name: "compressed",
|
|
74
|
+
type: "uint256[4]"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
stateMutability: "view",
|
|
78
|
+
type: "function"
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
var compressAndPadProof = async (proof, rpcUrl) => {
|
|
82
|
+
try {
|
|
83
|
+
const publicClient = createPublicClient({
|
|
84
|
+
chain: worldchain,
|
|
85
|
+
transport: http(
|
|
86
|
+
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
87
|
+
)
|
|
88
|
+
});
|
|
89
|
+
const decodedProof = decodeAbiParameters(
|
|
90
|
+
[{ type: "uint256[8]" }],
|
|
91
|
+
proof
|
|
92
|
+
)[0];
|
|
93
|
+
const compressedProof = await publicClient.readContract({
|
|
94
|
+
address: semaphoreVerifierAddress,
|
|
95
|
+
abi: semaphoreVerifierAbi,
|
|
96
|
+
functionName: "compressProof",
|
|
97
|
+
args: [decodedProof]
|
|
98
|
+
});
|
|
99
|
+
const paddedProof = [...compressedProof, 0n, 0n, 0n, 0n];
|
|
100
|
+
return encodeAbiParameters([{ type: "uint256[8]" }], [paddedProof]);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.log("Failed to compress proof", {
|
|
103
|
+
e,
|
|
104
|
+
proof
|
|
105
|
+
});
|
|
106
|
+
return proof;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// helpers/siwe/siwe.ts
|
|
111
|
+
import {
|
|
112
|
+
createPublicClient as createPublicClient2,
|
|
54
113
|
getContract,
|
|
55
114
|
hashMessage,
|
|
56
|
-
http,
|
|
115
|
+
http as http2,
|
|
57
116
|
recoverAddress
|
|
58
117
|
} from "viem";
|
|
59
|
-
import { worldchain } from "viem/chains";
|
|
118
|
+
import { worldchain as worldchain2 } from "viem/chains";
|
|
60
119
|
var PREAMBLE = " wants you to sign in with your Ethereum account:";
|
|
61
120
|
var URI_TAG = "URI: ";
|
|
62
121
|
var VERSION_TAG = "Version: ";
|
|
@@ -217,7 +276,7 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
|
|
|
217
276
|
`Request ID mismatch. Got: ${siweMessageData.request_id}, Expected: ${requestId}`
|
|
218
277
|
);
|
|
219
278
|
}
|
|
220
|
-
let provider = userProvider ||
|
|
279
|
+
let provider = userProvider || createPublicClient2({ chain: worldchain2, transport: http2() });
|
|
221
280
|
const signedMessage = `${ERC_191_PREFIX}${message.length}${message}`;
|
|
222
281
|
const hashedMessage = hashMessage(signedMessage);
|
|
223
282
|
const contract = getContract({
|
|
@@ -271,7 +330,7 @@ var processPayload = (payload) => {
|
|
|
271
330
|
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
272
331
|
return payload;
|
|
273
332
|
}
|
|
274
|
-
if (typeof payload === "number") {
|
|
333
|
+
if (typeof payload === "number" || typeof payload === "bigint") {
|
|
275
334
|
return String(payload);
|
|
276
335
|
}
|
|
277
336
|
if (Array.isArray(payload)) {
|
|
@@ -337,6 +396,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
337
396
|
})(Command || {});
|
|
338
397
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
339
398
|
Permission2["Notifications"] = "notifications";
|
|
399
|
+
Permission2["Contacts"] = "contacts";
|
|
340
400
|
return Permission2;
|
|
341
401
|
})(Permission || {});
|
|
342
402
|
|
|
@@ -358,6 +418,7 @@ var VerificationErrorMessage = {
|
|
|
358
418
|
};
|
|
359
419
|
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
360
420
|
PaymentErrorCodes2["InputError"] = "input_error";
|
|
421
|
+
PaymentErrorCodes2["UserRejected"] = "user_rejected";
|
|
361
422
|
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
362
423
|
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
363
424
|
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
@@ -368,6 +429,7 @@ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
|
368
429
|
})(PaymentErrorCodes || {});
|
|
369
430
|
var PaymentErrorMessage = {
|
|
370
431
|
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
432
|
+
["user_rejected" /* UserRejected */]: "You have cancelled the payment in World App.",
|
|
371
433
|
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
372
434
|
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
373
435
|
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
@@ -560,6 +622,21 @@ var _MiniKit = class _MiniKit {
|
|
|
560
622
|
originalHandler(payload);
|
|
561
623
|
};
|
|
562
624
|
this.listeners[event] = wrappedHandler;
|
|
625
|
+
} else if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
626
|
+
const originalHandler = handler;
|
|
627
|
+
const wrappedHandler = (payload) => {
|
|
628
|
+
if (payload.status === "success" && payload.verification_level === VerificationLevel.Orb) {
|
|
629
|
+
compressAndPadProof(payload.proof).then(
|
|
630
|
+
(compressedProof) => {
|
|
631
|
+
payload.proof = compressedProof;
|
|
632
|
+
originalHandler(payload);
|
|
633
|
+
}
|
|
634
|
+
);
|
|
635
|
+
} else {
|
|
636
|
+
originalHandler(payload);
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
this.listeners[event] = wrappedHandler;
|
|
563
640
|
} else {
|
|
564
641
|
this.listeners[event] = handler;
|
|
565
642
|
}
|
|
@@ -585,18 +662,18 @@ var _MiniKit = class _MiniKit {
|
|
|
585
662
|
commandPayload = executor();
|
|
586
663
|
});
|
|
587
664
|
}
|
|
588
|
-
static commandsValid(
|
|
589
|
-
return Object.entries(this.
|
|
590
|
-
([
|
|
591
|
-
const commandInput =
|
|
592
|
-
(command) => command.name ===
|
|
665
|
+
static commandsValid(worldAppSupportedCommands) {
|
|
666
|
+
return Object.entries(this.miniKitCommandVersion).every(
|
|
667
|
+
([minikitCommandName, version]) => {
|
|
668
|
+
const commandInput = worldAppSupportedCommands.find(
|
|
669
|
+
(command) => command.name === minikitCommandName
|
|
593
670
|
);
|
|
594
671
|
if (!commandInput) {
|
|
595
672
|
console.error(
|
|
596
|
-
`Command ${
|
|
673
|
+
`Command ${minikitCommandName} is not supported by the app. Try updating the app version`
|
|
597
674
|
);
|
|
598
675
|
} else {
|
|
599
|
-
_MiniKit.isCommandAvailable[
|
|
676
|
+
_MiniKit.isCommandAvailable[minikitCommandName] = true;
|
|
600
677
|
}
|
|
601
678
|
return commandInput ? commandInput.supported_versions.includes(version) : false;
|
|
602
679
|
}
|
|
@@ -656,7 +733,7 @@ var _MiniKit = class _MiniKit {
|
|
|
656
733
|
}
|
|
657
734
|
};
|
|
658
735
|
_MiniKit.MINIKIT_VERSION = 1;
|
|
659
|
-
_MiniKit.
|
|
736
|
+
_MiniKit.miniKitCommandVersion = {
|
|
660
737
|
["verify" /* Verify */]: 1,
|
|
661
738
|
["pay" /* Pay */]: 1,
|
|
662
739
|
["wallet-auth" /* WalletAuth */]: 1,
|
|
@@ -733,7 +810,7 @@ _MiniKit.commands = {
|
|
|
733
810
|
};
|
|
734
811
|
sendMiniKitEvent({
|
|
735
812
|
command: "verify" /* Verify */,
|
|
736
|
-
version: _MiniKit.
|
|
813
|
+
version: _MiniKit.miniKitCommandVersion["verify" /* Verify */],
|
|
737
814
|
payload: eventPayload
|
|
738
815
|
});
|
|
739
816
|
return eventPayload;
|
|
@@ -755,7 +832,7 @@ _MiniKit.commands = {
|
|
|
755
832
|
};
|
|
756
833
|
sendMiniKitEvent({
|
|
757
834
|
command: "pay" /* Pay */,
|
|
758
|
-
version: _MiniKit.
|
|
835
|
+
version: _MiniKit.miniKitCommandVersion["pay" /* Pay */],
|
|
759
836
|
payload: eventPayload
|
|
760
837
|
});
|
|
761
838
|
return eventPayload;
|
|
@@ -799,7 +876,7 @@ _MiniKit.commands = {
|
|
|
799
876
|
const walletAuthPayload = { siweMessage };
|
|
800
877
|
sendMiniKitEvent({
|
|
801
878
|
command: "wallet-auth" /* WalletAuth */,
|
|
802
|
-
version: _MiniKit.
|
|
879
|
+
version: _MiniKit.miniKitCommandVersion["wallet-auth" /* WalletAuth */],
|
|
803
880
|
payload: walletAuthPayload
|
|
804
881
|
});
|
|
805
882
|
return walletAuthPayload;
|
|
@@ -814,7 +891,7 @@ _MiniKit.commands = {
|
|
|
814
891
|
const validatedPayload = validateSendTransactionPayload(payload);
|
|
815
892
|
sendMiniKitEvent({
|
|
816
893
|
command: "send-transaction" /* SendTransaction */,
|
|
817
|
-
version:
|
|
894
|
+
version: _MiniKit.miniKitCommandVersion["send-transaction" /* SendTransaction */],
|
|
818
895
|
payload: validatedPayload
|
|
819
896
|
});
|
|
820
897
|
return validatedPayload;
|
|
@@ -828,7 +905,7 @@ _MiniKit.commands = {
|
|
|
828
905
|
}
|
|
829
906
|
sendMiniKitEvent({
|
|
830
907
|
command: "sign-message" /* SignMessage */,
|
|
831
|
-
version:
|
|
908
|
+
version: _MiniKit.miniKitCommandVersion["sign-message" /* SignMessage */],
|
|
832
909
|
payload
|
|
833
910
|
});
|
|
834
911
|
return payload;
|
|
@@ -842,7 +919,7 @@ _MiniKit.commands = {
|
|
|
842
919
|
}
|
|
843
920
|
sendMiniKitEvent({
|
|
844
921
|
command: "sign-typed-data" /* SignTypedData */,
|
|
845
|
-
version:
|
|
922
|
+
version: _MiniKit.miniKitCommandVersion["sign-typed-data" /* SignTypedData */],
|
|
846
923
|
payload
|
|
847
924
|
});
|
|
848
925
|
return payload;
|
|
@@ -856,7 +933,7 @@ _MiniKit.commands = {
|
|
|
856
933
|
}
|
|
857
934
|
sendMiniKitEvent({
|
|
858
935
|
command: "share-contacts" /* ShareContacts */,
|
|
859
|
-
version:
|
|
936
|
+
version: _MiniKit.miniKitCommandVersion["share-contacts" /* ShareContacts */],
|
|
860
937
|
payload
|
|
861
938
|
});
|
|
862
939
|
return payload;
|
|
@@ -870,7 +947,7 @@ _MiniKit.commands = {
|
|
|
870
947
|
}
|
|
871
948
|
sendMiniKitEvent({
|
|
872
949
|
command: "request-permission" /* RequestPermission */,
|
|
873
|
-
version:
|
|
950
|
+
version: _MiniKit.miniKitCommandVersion["request-permission" /* RequestPermission */],
|
|
874
951
|
payload
|
|
875
952
|
});
|
|
876
953
|
return payload;
|
|
@@ -884,7 +961,7 @@ _MiniKit.commands = {
|
|
|
884
961
|
}
|
|
885
962
|
sendMiniKitEvent({
|
|
886
963
|
command: "get-permissions" /* GetPermissions */,
|
|
887
|
-
version:
|
|
964
|
+
version: _MiniKit.miniKitCommandVersion["get-permissions" /* GetPermissions */],
|
|
888
965
|
payload: {}
|
|
889
966
|
});
|
|
890
967
|
return {
|
|
@@ -900,7 +977,7 @@ _MiniKit.commands = {
|
|
|
900
977
|
}
|
|
901
978
|
sendMiniKitEvent({
|
|
902
979
|
command: "send-haptic-feedback" /* SendHapticFeedback */,
|
|
903
|
-
version:
|
|
980
|
+
version: _MiniKit.miniKitCommandVersion["send-haptic-feedback" /* SendHapticFeedback */],
|
|
904
981
|
payload
|
|
905
982
|
});
|
|
906
983
|
return payload;
|
|
@@ -925,6 +1002,11 @@ _MiniKit.commandsAsync = {
|
|
|
925
1002
|
"verify" /* Verify */,
|
|
926
1003
|
() => _MiniKit.commands.verify(payload)
|
|
927
1004
|
);
|
|
1005
|
+
if (response.finalPayload.status === "success" && response.finalPayload.verification_level === VerificationLevel.Orb) {
|
|
1006
|
+
response.finalPayload.proof = await compressAndPadProof(
|
|
1007
|
+
response.finalPayload.proof
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
928
1010
|
resolve(response);
|
|
929
1011
|
} catch (error) {
|
|
930
1012
|
reject(error);
|
|
@@ -1067,8 +1149,8 @@ import {
|
|
|
1067
1149
|
} from "@worldcoin/idkit-core/backend";
|
|
1068
1150
|
|
|
1069
1151
|
// helpers/address-book/index.ts
|
|
1070
|
-
import { createPublicClient as
|
|
1071
|
-
import { worldchain as
|
|
1152
|
+
import { createPublicClient as createPublicClient3, http as http3 } from "viem";
|
|
1153
|
+
import { worldchain as worldchain3 } from "viem/chains";
|
|
1072
1154
|
var worldIdAddressBookContractAddress = "0x57b930D551e677CC36e2fA036Ae2fe8FdaE0330D";
|
|
1073
1155
|
var addressVerifiedUntilAbi = [
|
|
1074
1156
|
{
|
|
@@ -1092,9 +1174,9 @@ var addressVerifiedUntilAbi = [
|
|
|
1092
1174
|
}
|
|
1093
1175
|
];
|
|
1094
1176
|
var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
1095
|
-
const publicClient =
|
|
1096
|
-
chain:
|
|
1097
|
-
transport:
|
|
1177
|
+
const publicClient = createPublicClient3({
|
|
1178
|
+
chain: worldchain3,
|
|
1179
|
+
transport: http3(
|
|
1098
1180
|
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
1099
1181
|
)
|
|
1100
1182
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@worldcoin/idkit-core": "^
|
|
3
|
+
"@worldcoin/idkit-core": "^2.0.2",
|
|
4
4
|
"abitype": "^1.0.6"
|
|
5
5
|
},
|
|
6
6
|
"description": "minikit-js is our SDK for building mini-apps.",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"main": "index.ts",
|
|
47
47
|
"name": "@worldcoin/minikit-js",
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"viem": "2.23.5"
|
|
49
|
+
"viem": "^2.23.5"
|
|
50
50
|
},
|
|
51
51
|
"private": false,
|
|
52
52
|
"type": "module",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
]
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
"version": "1.
|
|
62
|
+
"version": "1.8.0",
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "tsup",
|
|
65
65
|
"dev": "tsup --watch",
|