@worldcoin/minikit-js 1.8.0 → 1.9.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.js CHANGED
@@ -1,1156 +1,50 @@
1
- // minikit.ts
2
- import { VerificationLevel } from "@worldcoin/idkit-core";
3
- import { encodeAction, generateSignal } from "@worldcoin/idkit-core/hashing";
4
-
5
- // types/payment.ts
6
- var Tokens = /* @__PURE__ */ ((Tokens3) => {
7
- Tokens3["USDCE"] = "USDCE";
8
- Tokens3["WLD"] = "WLD";
9
- return Tokens3;
10
- })(Tokens || {});
11
- var TokenDecimals = {
12
- ["USDCE" /* USDCE */]: 6,
13
- ["WLD" /* WLD */]: 18
14
- };
15
- var Network = /* @__PURE__ */ ((Network2) => {
16
- Network2["Optimism"] = "optimism";
17
- Network2["WorldChain"] = "worldchain";
18
- return Network2;
19
- })(Network || {});
20
-
21
- // helpers/payment/client.ts
22
- var tokenToDecimals = (amount, token) => {
23
- const decimals = TokenDecimals[token];
24
- if (decimals === void 0) {
25
- throw new Error(`Invalid token: ${token}`);
26
- }
27
- const factor = 10 ** decimals;
28
- const result = amount * factor;
29
- if (!Number.isInteger(result)) {
30
- throw new Error(`The resulting amount is not a whole number: ${result}`);
31
- }
32
- return result;
33
- };
34
- var validatePaymentPayload = (payload) => {
35
- if (payload.tokens.some(
36
- (token) => token.symbol == "USDCE" && parseFloat(token.token_amount) < 0.1
37
- )) {
38
- console.error("USDCE amount should be greater than $0.1");
39
- return false;
40
- }
41
- if (payload.reference.length > 36) {
42
- console.error("Reference must not exceed 36 characters");
43
- return false;
44
- }
45
- if (typeof payload.reference !== "string") {
46
- throw new Error("Reference must be a string");
47
- }
48
- return true;
49
- };
50
-
51
- // helpers/proof/index.ts
52
- import {
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
1
  import {
112
- createPublicClient as createPublicClient2,
113
- getContract,
114
- hashMessage,
115
- http as http2,
116
- recoverAddress
117
- } from "viem";
118
- import { worldchain as worldchain2 } from "viem/chains";
119
- var PREAMBLE = " wants you to sign in with your Ethereum account:";
120
- var URI_TAG = "URI: ";
121
- var VERSION_TAG = "Version: ";
122
- var CHAIN_TAG = "Chain ID: ";
123
- var NONCE_TAG = "Nonce: ";
124
- var IAT_TAG = "Issued At: ";
125
- var EXP_TAG = "Expiration Time: ";
126
- var NBF_TAG = "Not Before: ";
127
- var RID_TAG = "Request ID: ";
128
- var ERC_191_PREFIX = "Ethereum Signed Message:\n";
129
- var tagged = (line, tag) => {
130
- if (line && line.includes(tag)) {
131
- return line.replace(tag, "");
132
- } else {
133
- throw new Error(`Missing '${tag}'`);
134
- }
135
- };
136
- var parseSiweMessage = (inputString) => {
137
- const lines = inputString.split("\n")[Symbol.iterator]();
138
- const domain = tagged(lines.next()?.value, PREAMBLE);
139
- const address = lines.next()?.value;
140
- lines.next();
141
- const nextValue = lines.next()?.value;
142
- let statement;
143
- if (nextValue) {
144
- statement = nextValue;
145
- lines.next();
146
- }
147
- const uri = tagged(lines.next()?.value, URI_TAG);
148
- const version = tagged(lines.next()?.value, VERSION_TAG);
149
- const chain_id = tagged(lines.next()?.value, CHAIN_TAG);
150
- const nonce = tagged(lines.next()?.value, NONCE_TAG);
151
- const issued_at = tagged(lines.next()?.value, IAT_TAG);
152
- let expiration_time, not_before, request_id;
153
- for (let line of lines) {
154
- if (line.startsWith(EXP_TAG)) {
155
- expiration_time = tagged(line, EXP_TAG);
156
- } else if (line.startsWith(NBF_TAG)) {
157
- not_before = tagged(line, NBF_TAG);
158
- } else if (line.startsWith(RID_TAG)) {
159
- request_id = tagged(line, RID_TAG);
160
- }
161
- }
162
- if (lines.next().done === false) {
163
- throw new Error("Extra lines in the input");
164
- }
165
- const siweMessageData = {
166
- domain,
167
- address,
168
- statement,
169
- uri,
170
- version,
171
- chain_id,
172
- nonce,
173
- issued_at,
174
- expiration_time,
175
- not_before,
176
- request_id
177
- };
178
- return siweMessageData;
179
- };
180
- var generateSiweMessage = (siweMessageData) => {
181
- let siweMessage = "";
182
- if (siweMessageData.scheme) {
183
- siweMessage += `${siweMessageData.scheme}://${siweMessageData.domain} wants you to sign in with your Ethereum account:
184
- `;
185
- } else {
186
- siweMessage += `${siweMessageData.domain} wants you to sign in with your Ethereum account:
187
- `;
188
- }
189
- if (siweMessageData.address) {
190
- siweMessage += `${siweMessageData.address}
191
- `;
192
- } else {
193
- siweMessage += "{address}\n";
194
- }
195
- siweMessage += "\n";
196
- if (siweMessageData.statement) {
197
- siweMessage += `${siweMessageData.statement}
198
- `;
199
- }
200
- siweMessage += "\n";
201
- siweMessage += `URI: ${siweMessageData.uri}
202
- `;
203
- siweMessage += `Version: ${siweMessageData.version}
204
- `;
205
- siweMessage += `Chain ID: ${siweMessageData.chain_id}
206
- `;
207
- siweMessage += `Nonce: ${siweMessageData.nonce}
208
- `;
209
- siweMessage += `Issued At: ${siweMessageData.issued_at}
210
- `;
211
- if (siweMessageData.expiration_time) {
212
- siweMessage += `Expiration Time: ${siweMessageData.expiration_time}
213
- `;
214
- }
215
- if (siweMessageData.not_before) {
216
- siweMessage += `Not Before: ${siweMessageData.not_before}
217
- `;
218
- }
219
- if (siweMessageData.request_id) {
220
- siweMessage += `Request ID: ${siweMessageData.request_id}
221
- `;
222
- }
223
- return siweMessage;
224
- };
225
- var SAFE_CONTRACT_ABI = [
226
- {
227
- inputs: [
228
- {
229
- internalType: "address",
230
- name: "owner",
231
- type: "address"
232
- }
233
- ],
234
- name: "isOwner",
235
- outputs: [
236
- {
237
- internalType: "bool",
238
- name: "",
239
- type: "bool"
240
- }
241
- ],
242
- stateMutability: "view",
243
- type: "function"
244
- }
245
- ];
246
- var verifySiweMessage = async (payload, nonce, statement, requestId, userProvider) => {
247
- if (typeof window !== "undefined") {
248
- throw new Error("Verify can only be called in the backend");
249
- }
250
- const { message, signature, address } = payload;
251
- const siweMessageData = parseSiweMessage(message);
252
- if (siweMessageData.expiration_time) {
253
- const expirationTime = new Date(siweMessageData.expiration_time);
254
- if (expirationTime < /* @__PURE__ */ new Date()) {
255
- throw new Error("Expired message");
256
- }
257
- }
258
- if (siweMessageData.not_before) {
259
- const notBefore = new Date(siweMessageData.not_before);
260
- if (notBefore > /* @__PURE__ */ new Date()) {
261
- throw new Error("Not Before time has not passed");
262
- }
263
- }
264
- if (nonce && siweMessageData.nonce !== nonce) {
265
- throw new Error(
266
- `Nonce mismatch. Got: ${siweMessageData.nonce}, Expected: ${nonce}`
267
- );
268
- }
269
- if (statement && siweMessageData.statement !== statement) {
270
- throw new Error(
271
- `Statement mismatch. Got: ${siweMessageData.statement}, Expected: ${statement}`
272
- );
273
- }
274
- if (requestId && siweMessageData.request_id !== requestId) {
275
- throw new Error(
276
- `Request ID mismatch. Got: ${siweMessageData.request_id}, Expected: ${requestId}`
277
- );
278
- }
279
- let provider = userProvider || createPublicClient2({ chain: worldchain2, transport: http2() });
280
- const signedMessage = `${ERC_191_PREFIX}${message.length}${message}`;
281
- const hashedMessage = hashMessage(signedMessage);
282
- const contract = getContract({
283
- address,
284
- abi: SAFE_CONTRACT_ABI,
285
- client: provider
286
- });
287
- try {
288
- const recoveredAddress = await recoverAddress({
289
- hash: hashedMessage,
290
- signature: `0x${signature}`
291
- });
292
- const isOwner = await contract.read.isOwner([recoveredAddress]);
293
- if (!isOwner) {
294
- throw new Error("Signature verification failed, invalid owner");
295
- }
296
- } catch (error) {
297
- throw new Error("Signature verification failed");
298
- }
299
- return { isValid: true, siweMessageData };
300
- };
301
-
302
- // helpers/siwe/validate-wallet-auth-command-input.ts
303
- var validateWalletAuthCommandInput = (params) => {
304
- if (!params.nonce) {
305
- return { valid: false, message: "'nonce' is required" };
306
- }
307
- if (params.nonce.length < 8) {
308
- return { valid: false, message: "'nonce' must be at least 8 characters" };
309
- }
310
- if (params.statement && params.statement.includes("\n")) {
311
- return { valid: false, message: "'statement' must not contain newlines" };
312
- }
313
- if (params.expirationTime && new Date(params.expirationTime) < /* @__PURE__ */ new Date()) {
314
- return { valid: false, message: "'expirationTime' must be in the future" };
315
- }
316
- if (params.expirationTime && new Date(params.expirationTime) > new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3)) {
317
- return { valid: false, message: "'expirationTime' must be within 7 days" };
318
- }
319
- if (params.notBefore && new Date(params.notBefore) > new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3)) {
320
- return { valid: false, message: "'notBefore' must be within 7 days" };
321
- }
322
- return { valid: true };
323
- };
324
-
325
- // helpers/transaction/validate-payload.ts
326
- var isValidHex = (str) => {
327
- return /^0x[0-9A-Fa-f]+$/.test(str);
328
- };
329
- var processPayload = (payload) => {
330
- if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
331
- return payload;
332
- }
333
- if (typeof payload === "number" || typeof payload === "bigint") {
334
- return String(payload);
335
- }
336
- if (Array.isArray(payload)) {
337
- return payload.map((value) => processPayload(value));
338
- }
339
- if (typeof payload === "object") {
340
- const result = { ...payload };
341
- if ("value" in result && result.value !== void 0) {
342
- if (typeof result.value !== "string") {
343
- result.value = String(result.value);
344
- }
345
- if (!isValidHex(result.value)) {
346
- console.error(
347
- "Transaction value must be a valid hex string",
348
- result.value
349
- );
350
- throw new Error(
351
- `Transaction value must be a valid hex string: ${result.value}`
352
- );
353
- }
354
- }
355
- for (const key in result) {
356
- if (Object.prototype.hasOwnProperty.call(result, key)) {
357
- result[key] = processPayload(result[key]);
358
- }
359
- }
360
- return result;
361
- }
362
- return payload;
363
- };
364
- var validateSendTransactionPayload = (payload) => {
365
- return processPayload(payload);
366
- };
367
-
368
- // helpers/usernames/index.ts
369
- var getUserProfile = async (address) => {
370
- const res = await fetch("https://usernames.worldcoin.org/api/v1/query", {
371
- method: "POST",
372
- headers: {
373
- "Content-Type": "application/json"
374
- },
375
- body: JSON.stringify({
376
- addresses: [address]
377
- })
378
- });
379
- const usernames = await res.json();
380
- return usernames?.[0] ?? { username: null, profilePictureUrl: null };
381
- };
382
-
383
- // types/commands.ts
384
- var Command = /* @__PURE__ */ ((Command2) => {
385
- Command2["Verify"] = "verify";
386
- Command2["Pay"] = "pay";
387
- Command2["WalletAuth"] = "wallet-auth";
388
- Command2["SendTransaction"] = "send-transaction";
389
- Command2["SignMessage"] = "sign-message";
390
- Command2["SignTypedData"] = "sign-typed-data";
391
- Command2["ShareContacts"] = "share-contacts";
392
- Command2["RequestPermission"] = "request-permission";
393
- Command2["GetPermissions"] = "get-permissions";
394
- Command2["SendHapticFeedback"] = "send-haptic-feedback";
395
- return Command2;
396
- })(Command || {});
397
- var Permission = /* @__PURE__ */ ((Permission2) => {
398
- Permission2["Notifications"] = "notifications";
399
- Permission2["Contacts"] = "contacts";
400
- return Permission2;
401
- })(Permission || {});
402
-
403
- // types/errors.ts
404
- import { AppErrorCodes } from "@worldcoin/idkit-core";
405
- import { AppErrorCodes as AppErrorCodes2 } from "@worldcoin/idkit-core";
406
- var VerificationErrorMessage = {
407
- [AppErrorCodes.VerificationRejected]: "You've cancelled the request in World App.",
408
- [AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
409
- [AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
410
- [AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
411
- [AppErrorCodes.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
412
- [AppErrorCodes.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
413
- [AppErrorCodes.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
414
- [AppErrorCodes.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
415
- [AppErrorCodes.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
416
- [AppErrorCodes.GenericError]: "Something unexpected went wrong. Please try again.",
417
- [AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
418
- };
419
- var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
420
- PaymentErrorCodes2["InputError"] = "input_error";
421
- PaymentErrorCodes2["UserRejected"] = "user_rejected";
422
- PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
423
- PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
424
- PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
425
- PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
426
- PaymentErrorCodes2["GenericError"] = "generic_error";
427
- PaymentErrorCodes2["UserBlocked"] = "user_blocked";
428
- return PaymentErrorCodes2;
429
- })(PaymentErrorCodes || {});
430
- var PaymentErrorMessage = {
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.",
433
- ["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
434
- ["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
435
- ["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
436
- ["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
437
- ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
438
- ["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
439
- };
440
- var PaymentValidationErrors = /* @__PURE__ */ ((PaymentValidationErrors2) => {
441
- PaymentValidationErrors2["MalformedRequest"] = "There was a problem with this request. Please try again or contact the app owner.";
442
- PaymentValidationErrors2["InvalidTokenAddress"] = "The token address is invalid. Please contact the app owner.";
443
- PaymentValidationErrors2["InvalidAppId"] = "The app ID is invalid. Please contact the app owner.";
444
- PaymentValidationErrors2["DuplicateReference"] = "This reference ID already exists please generate a new one and try again.";
445
- return PaymentValidationErrors2;
446
- })(PaymentValidationErrors || {});
447
- var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
448
- WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
449
- WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
450
- WalletAuthErrorCodes2["GenericError"] = "generic_error";
451
- return WalletAuthErrorCodes2;
452
- })(WalletAuthErrorCodes || {});
453
- var WalletAuthErrorMessage = {
454
- ["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
455
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
456
- ["generic_error" /* GenericError */]: "Something unexpected went wrong."
457
- };
458
- var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
459
- SendTransactionErrorCodes2["InvalidOperation"] = "invalid_operation";
460
- SendTransactionErrorCodes2["UserRejected"] = "user_rejected";
461
- SendTransactionErrorCodes2["InputError"] = "input_error";
462
- SendTransactionErrorCodes2["SimulationFailed"] = "simulation_failed";
463
- SendTransactionErrorCodes2["TransactionFailed"] = "transaction_failed";
464
- SendTransactionErrorCodes2["GenericError"] = "generic_error";
465
- SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
466
- SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
467
- SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
468
- SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
469
- SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
470
- SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
471
- return SendTransactionErrorCodes2;
472
- })(SendTransactionErrorCodes || {});
473
- var SendTransactionErrorMessage = {
474
- ["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
475
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
476
- ["input_error" /* InputError */]: "Invalid payload.",
477
- ["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
478
- ["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again later.",
479
- ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
480
- ["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
481
- ["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
482
- ["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
483
- ["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
484
- ["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
485
- ["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
486
- };
487
- var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
488
- SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
489
- SignMessageErrorCodes2["UserRejected"] = "user_rejected";
490
- SignMessageErrorCodes2["GenericError"] = "generic_error";
491
- return SignMessageErrorCodes2;
492
- })(SignMessageErrorCodes || {});
493
- var SignMessageErrorMessage = {
494
- ["invalid_message" /* InvalidMessage */]: "Invalid message requested",
495
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
496
- ["generic_error" /* GenericError */]: "Something unexpected went wrong."
497
- };
498
- var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
499
- SignTypedDataErrorCodes2["InvalidOperation"] = "invalid_operation";
500
- SignTypedDataErrorCodes2["UserRejected"] = "user_rejected";
501
- SignTypedDataErrorCodes2["InputError"] = "input_error";
502
- SignTypedDataErrorCodes2["SimulationFailed"] = "simulation_failed";
503
- SignTypedDataErrorCodes2["GenericError"] = "generic_error";
504
- SignTypedDataErrorCodes2["DisallowedOperation"] = "disallowed_operation";
505
- SignTypedDataErrorCodes2["InvalidContract"] = "invalid_contract";
506
- SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
507
- return SignTypedDataErrorCodes2;
508
- })(SignTypedDataErrorCodes || {});
509
- var SignTypedDataErrorMessage = {
510
- ["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
511
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
512
- ["input_error" /* InputError */]: "Invalid payload.",
513
- ["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
514
- ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
515
- ["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
516
- ["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
517
- ["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
518
- };
519
- var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
520
- MiniKitInstallErrorCodes2["Unknown"] = "unknown";
521
- MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
522
- MiniKitInstallErrorCodes2["OutsideOfWorldApp"] = "outside_of_worldapp";
523
- MiniKitInstallErrorCodes2["NotOnClient"] = "not_on_client";
524
- MiniKitInstallErrorCodes2["AppOutOfDate"] = "app_out_of_date";
525
- return MiniKitInstallErrorCodes2;
526
- })(MiniKitInstallErrorCodes || {});
527
- var MiniKitInstallErrorMessage = {
528
- ["unknown" /* Unknown */]: "Failed to install MiniKit.",
529
- ["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
530
- ["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
531
- ["not_on_client" /* NotOnClient */]: "Window object is not available.",
532
- ["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
533
- };
534
- var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
535
- ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
536
- ShareContactsErrorCodes2["GenericError"] = "generic_error";
537
- return ShareContactsErrorCodes2;
538
- })(ShareContactsErrorCodes || {});
539
- var ShareContactsErrorMessage = {
540
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
541
- ["generic_error" /* GenericError */]: "Something unexpected went wrong."
542
- };
543
- var RequestPermissionErrorCodes = /* @__PURE__ */ ((RequestPermissionErrorCodes2) => {
544
- RequestPermissionErrorCodes2["UserRejected"] = "user_rejected";
545
- RequestPermissionErrorCodes2["GenericError"] = "generic_error";
546
- RequestPermissionErrorCodes2["AlreadyRequested"] = "already_requested";
547
- RequestPermissionErrorCodes2["PermissionDisabled"] = "permission_disabled";
548
- RequestPermissionErrorCodes2["AlreadyGranted"] = "already_granted";
549
- RequestPermissionErrorCodes2["UnsupportedPermission"] = "unsupported_permission";
550
- return RequestPermissionErrorCodes2;
551
- })(RequestPermissionErrorCodes || {});
552
- var RequestPermissionErrorMessage = {
553
- ["user_rejected" /* UserRejected */]: "User declined sharing contacts",
554
- ["generic_error" /* GenericError */]: "Request failed for unknown reason.",
555
- ["already_requested" /* AlreadyRequested */]: "User has already declined turning on notifications once",
556
- ["permission_disabled" /* PermissionDisabled */]: "User does not have this permission enabled in World App",
557
- ["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
558
- ["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
559
- };
560
- var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
561
- GetPermissionsErrorCodes2["GenericError"] = "generic_error";
562
- return GetPermissionsErrorCodes2;
563
- })(GetPermissionsErrorCodes || {});
564
- var GetPermissionsErrorMessage = {
565
- ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
566
- };
567
- var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
568
- SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
569
- SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
570
- return SendHapticFeedbackErrorCodes2;
571
- })(SendHapticFeedbackErrorCodes || {});
572
- var SendHapticFeedbackErrorMessage = {
573
- ["generic_error" /* GenericError */]: "Something unexpected went wrong.",
574
- ["user_rejected" /* UserRejected */]: "User rejected the request."
575
- };
576
-
577
- // helpers/send-webview-event.ts
578
- var sendWebviewEvent = (payload) => {
579
- if (window.webkit) {
580
- window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
581
- } else if (window.Android) {
582
- window.Android.postMessage?.(JSON.stringify(payload));
583
- }
584
- };
585
-
586
- // types/responses.ts
587
- var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
588
- ResponseEvent2["MiniAppVerifyAction"] = "miniapp-verify-action";
589
- ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
590
- ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
591
- ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
592
- ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
593
- ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
594
- ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
595
- ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
596
- ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
597
- ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
598
- return ResponseEvent2;
599
- })(ResponseEvent || {});
600
-
601
- // minikit.ts
602
- var sendMiniKitEvent = (payload) => {
603
- sendWebviewEvent(payload);
604
- };
605
- var _MiniKit = class _MiniKit {
606
- static sendInit() {
607
- sendWebviewEvent({
608
- command: "init",
609
- payload: { version: this.MINIKIT_VERSION }
610
- });
611
- }
612
- static subscribe(event, handler) {
613
- if (event === "miniapp-wallet-auth" /* MiniAppWalletAuth */) {
614
- const originalHandler = handler;
615
- const wrappedHandler = (payload) => {
616
- if (payload.status === "success") {
617
- _MiniKit.walletAddress = payload.address;
618
- _MiniKit.getUserByAddress(payload.address).then((user) => {
619
- _MiniKit.user = user;
620
- });
621
- }
622
- originalHandler(payload);
623
- };
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;
640
- } else {
641
- this.listeners[event] = handler;
642
- }
643
- }
644
- static unsubscribe(event) {
645
- delete this.listeners[event];
646
- }
647
- static trigger(event, payload) {
648
- if (!this.listeners[event]) {
649
- console.error(`No handler for event ${event}`);
650
- return;
651
- }
652
- this.listeners[event](payload);
653
- }
654
- static async awaitCommand(event, command, executor) {
655
- return new Promise((resolve) => {
656
- let commandPayload = null;
657
- const handleAndUnsubscribe = (payload) => {
658
- this.unsubscribe(event);
659
- resolve({ commandPayload, finalPayload: payload });
660
- };
661
- this.subscribe(event, handleAndUnsubscribe);
662
- commandPayload = executor();
663
- });
664
- }
665
- static commandsValid(worldAppSupportedCommands) {
666
- return Object.entries(this.miniKitCommandVersion).every(
667
- ([minikitCommandName, version]) => {
668
- const commandInput = worldAppSupportedCommands.find(
669
- (command) => command.name === minikitCommandName
670
- );
671
- if (!commandInput) {
672
- console.error(
673
- `Command ${minikitCommandName} is not supported by the app. Try updating the app version`
674
- );
675
- } else {
676
- _MiniKit.isCommandAvailable[minikitCommandName] = true;
677
- }
678
- return commandInput ? commandInput.supported_versions.includes(version) : false;
679
- }
680
- );
681
- }
682
- static install(appId) {
683
- if (typeof window === "undefined" || Boolean(window.MiniKit)) {
684
- return {
685
- success: false,
686
- errorCode: "already_installed" /* AlreadyInstalled */,
687
- errorMessage: MiniKitInstallErrorMessage["already_installed" /* AlreadyInstalled */]
688
- };
689
- }
690
- if (!appId) {
691
- console.warn("App ID not provided during install");
692
- } else {
693
- _MiniKit.appId = appId;
694
- }
695
- if (!window.WorldApp) {
696
- return {
697
- success: false,
698
- errorCode: "outside_of_worldapp" /* OutsideOfWorldApp */,
699
- errorMessage: MiniKitInstallErrorMessage["outside_of_worldapp" /* OutsideOfWorldApp */]
700
- };
701
- }
702
- try {
703
- window.MiniKit = _MiniKit;
704
- this.sendInit();
705
- } catch (error) {
706
- console.error(
707
- MiniKitInstallErrorMessage["unknown" /* Unknown */],
708
- error
709
- );
710
- return {
711
- success: false,
712
- errorCode: "unknown" /* Unknown */,
713
- errorMessage: MiniKitInstallErrorMessage["unknown" /* Unknown */]
714
- };
715
- }
716
- if (!this.commandsValid(window.WorldApp.supported_commands)) {
717
- return {
718
- success: false,
719
- errorCode: "app_out_of_date" /* AppOutOfDate */,
720
- errorMessage: MiniKitInstallErrorMessage["app_out_of_date" /* AppOutOfDate */]
721
- };
722
- }
723
- return { success: true };
724
- }
725
- static isInstalled(debug) {
726
- if (debug) console.log("MiniKit is alive!");
727
- const isInstalled = Boolean(window.MiniKit);
728
- if (!isInstalled)
729
- console.error(
730
- "MiniKit is not installed. Make sure you're running the application inside of World App"
731
- );
732
- return isInstalled;
733
- }
734
- };
735
- _MiniKit.MINIKIT_VERSION = 1;
736
- _MiniKit.miniKitCommandVersion = {
737
- ["verify" /* Verify */]: 1,
738
- ["pay" /* Pay */]: 1,
739
- ["wallet-auth" /* WalletAuth */]: 1,
740
- ["send-transaction" /* SendTransaction */]: 1,
741
- ["sign-message" /* SignMessage */]: 1,
742
- ["sign-typed-data" /* SignTypedData */]: 1,
743
- ["share-contacts" /* ShareContacts */]: 1,
744
- ["request-permission" /* RequestPermission */]: 1,
745
- ["get-permissions" /* GetPermissions */]: 1,
746
- ["send-haptic-feedback" /* SendHapticFeedback */]: 1
747
- };
748
- _MiniKit.isCommandAvailable = {
749
- ["verify" /* Verify */]: false,
750
- ["pay" /* Pay */]: false,
751
- ["wallet-auth" /* WalletAuth */]: false,
752
- ["send-transaction" /* SendTransaction */]: false,
753
- ["sign-message" /* SignMessage */]: false,
754
- ["sign-typed-data" /* SignTypedData */]: false,
755
- ["share-contacts" /* ShareContacts */]: false,
756
- ["request-permission" /* RequestPermission */]: false,
757
- ["get-permissions" /* GetPermissions */]: false,
758
- ["send-haptic-feedback" /* SendHapticFeedback */]: false
759
- };
760
- _MiniKit.listeners = {
761
- ["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
762
- },
763
- ["miniapp-payment" /* MiniAppPayment */]: () => {
764
- },
765
- ["miniapp-wallet-auth" /* MiniAppWalletAuth */]: () => {
766
- },
767
- ["miniapp-send-transaction" /* MiniAppSendTransaction */]: () => {
768
- },
769
- ["miniapp-sign-message" /* MiniAppSignMessage */]: () => {
770
- },
771
- ["miniapp-sign-typed-data" /* MiniAppSignTypedData */]: () => {
772
- },
773
- ["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
774
- },
775
- ["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
776
- },
777
- ["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
778
- },
779
- ["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
780
- }
781
- };
782
- _MiniKit.appId = null;
783
- /**
784
- * @deprecated you should use MiniKit.user.walletAddress instead
785
- */
786
- _MiniKit.walletAddress = null;
787
- _MiniKit.user = null;
788
- _MiniKit.getUserByAddress = async (address) => {
789
- const userProfile = await getUserProfile(address);
790
- return {
791
- walletAddress: address,
792
- username: userProfile.username,
793
- profilePictureUrl: userProfile.profilePictureUrl
794
- };
795
- };
796
- _MiniKit.commands = {
797
- verify: (payload) => {
798
- if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["verify" /* Verify */]) {
799
- console.error(
800
- "'verify' command is unavailable. Check MiniKit.install() or update the app version"
801
- );
802
- return null;
803
- }
804
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
805
- const eventPayload = {
806
- action: encodeAction(payload.action),
807
- signal: generateSignal(payload.signal).digest,
808
- verification_level: payload.verification_level || VerificationLevel.Orb,
809
- timestamp
810
- };
811
- sendMiniKitEvent({
812
- command: "verify" /* Verify */,
813
- version: _MiniKit.miniKitCommandVersion["verify" /* Verify */],
814
- payload: eventPayload
815
- });
816
- return eventPayload;
817
- },
818
- pay: (payload) => {
819
- if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["pay" /* Pay */]) {
820
- console.error(
821
- "'pay' command is unavailable. Check MiniKit.install() or update the app version"
822
- );
823
- return null;
824
- }
825
- if (!validatePaymentPayload(payload)) {
826
- return null;
827
- }
828
- const network = "worldchain" /* WorldChain */;
829
- const eventPayload = {
830
- ...payload,
831
- network
832
- };
833
- sendMiniKitEvent({
834
- command: "pay" /* Pay */,
835
- version: _MiniKit.miniKitCommandVersion["pay" /* Pay */],
836
- payload: eventPayload
837
- });
838
- return eventPayload;
839
- },
840
- walletAuth: (payload) => {
841
- if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["wallet-auth" /* WalletAuth */]) {
842
- console.error(
843
- "'walletAuth' command is unavailable. Check MiniKit.install() or update the app version"
844
- );
845
- return null;
846
- }
847
- const validationResult = validateWalletAuthCommandInput(payload);
848
- if (!validationResult.valid) {
849
- console.error(
850
- "Failed to validate wallet auth input:\n\n -->",
851
- validationResult.message
852
- );
853
- return null;
854
- }
855
- let protocol = null;
856
- try {
857
- const currentUrl = new URL(window.location.href);
858
- protocol = currentUrl.protocol.split(":")[0];
859
- } catch (error) {
860
- console.error("Failed to get current URL", error);
861
- return null;
862
- }
863
- const siweMessage = generateSiweMessage({
864
- scheme: protocol,
865
- domain: window.location.host,
866
- statement: payload.statement ?? void 0,
867
- uri: window.location.href,
868
- version: 1,
869
- chain_id: 480,
870
- nonce: payload.nonce,
871
- issued_at: (/* @__PURE__ */ new Date()).toISOString(),
872
- expiration_time: payload.expirationTime?.toISOString() ?? void 0,
873
- not_before: payload.notBefore?.toISOString() ?? void 0,
874
- request_id: payload.requestId ?? void 0
875
- });
876
- const walletAuthPayload = { siweMessage };
877
- sendMiniKitEvent({
878
- command: "wallet-auth" /* WalletAuth */,
879
- version: _MiniKit.miniKitCommandVersion["wallet-auth" /* WalletAuth */],
880
- payload: walletAuthPayload
881
- });
882
- return walletAuthPayload;
883
- },
884
- sendTransaction: (payload) => {
885
- if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-transaction" /* SendTransaction */]) {
886
- console.error(
887
- "'sendTransaction' command is unavailable. Check MiniKit.install() or update the app version"
888
- );
889
- return null;
890
- }
891
- const validatedPayload = validateSendTransactionPayload(payload);
892
- sendMiniKitEvent({
893
- command: "send-transaction" /* SendTransaction */,
894
- version: _MiniKit.miniKitCommandVersion["send-transaction" /* SendTransaction */],
895
- payload: validatedPayload
896
- });
897
- return validatedPayload;
898
- },
899
- signMessage: (payload) => {
900
- if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-message" /* SignMessage */]) {
901
- console.error(
902
- "'signMessage' command is unavailable. Check MiniKit.install() or update the app version"
903
- );
904
- return null;
905
- }
906
- sendMiniKitEvent({
907
- command: "sign-message" /* SignMessage */,
908
- version: _MiniKit.miniKitCommandVersion["sign-message" /* SignMessage */],
909
- payload
910
- });
911
- return payload;
912
- },
913
- signTypedData: (payload) => {
914
- if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-typed-data" /* SignTypedData */]) {
915
- console.error(
916
- "'signTypedData' command is unavailable. Check MiniKit.install() or update the app version"
917
- );
918
- return null;
919
- }
920
- sendMiniKitEvent({
921
- command: "sign-typed-data" /* SignTypedData */,
922
- version: _MiniKit.miniKitCommandVersion["sign-typed-data" /* SignTypedData */],
923
- payload
924
- });
925
- return payload;
926
- },
927
- shareContacts: (payload) => {
928
- if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-typed-data" /* SignTypedData */]) {
929
- console.error(
930
- "'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
931
- );
932
- return null;
933
- }
934
- sendMiniKitEvent({
935
- command: "share-contacts" /* ShareContacts */,
936
- version: _MiniKit.miniKitCommandVersion["share-contacts" /* ShareContacts */],
937
- payload
938
- });
939
- return payload;
940
- },
941
- requestPermission: (payload) => {
942
- if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["request-permission" /* RequestPermission */]) {
943
- console.error(
944
- "'requestPermission' command is unavailable. Check MiniKit.install() or update the app version"
945
- );
946
- return null;
947
- }
948
- sendMiniKitEvent({
949
- command: "request-permission" /* RequestPermission */,
950
- version: _MiniKit.miniKitCommandVersion["request-permission" /* RequestPermission */],
951
- payload
952
- });
953
- return payload;
954
- },
955
- getPermissions: () => {
956
- if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["get-permissions" /* GetPermissions */]) {
957
- console.error(
958
- "'getPermissions' command is unavailable. Check MiniKit.install() or update the app version"
959
- );
960
- return null;
961
- }
962
- sendMiniKitEvent({
963
- command: "get-permissions" /* GetPermissions */,
964
- version: _MiniKit.miniKitCommandVersion["get-permissions" /* GetPermissions */],
965
- payload: {}
966
- });
967
- return {
968
- status: "sent"
969
- };
970
- },
971
- sendHapticFeedback: (payload) => {
972
- if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-haptic-feedback" /* SendHapticFeedback */]) {
973
- console.error(
974
- "'sendHapticFeedback' command is unavailable. Check MiniKit.install() or update the app version"
975
- );
976
- return null;
977
- }
978
- sendMiniKitEvent({
979
- command: "send-haptic-feedback" /* SendHapticFeedback */,
980
- version: _MiniKit.miniKitCommandVersion["send-haptic-feedback" /* SendHapticFeedback */],
981
- payload
982
- });
983
- return payload;
984
- }
985
- };
986
- /**
987
- * This object contains async versions of all the commands.
988
- * Instead of using event listeners, you can just `await` these.
989
- *
990
- * They return a standardized object
991
- *
992
- * commandPayload - object returned by the command function
993
- *
994
- * finalPayload - object returned by the event listener, or in other words, WorldApp response
995
- */
996
- _MiniKit.commandsAsync = {
997
- verify: async (payload) => {
998
- return new Promise(async (resolve, reject) => {
999
- try {
1000
- const response = await _MiniKit.awaitCommand(
1001
- "miniapp-verify-action" /* MiniAppVerifyAction */,
1002
- "verify" /* Verify */,
1003
- () => _MiniKit.commands.verify(payload)
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
- }
1010
- resolve(response);
1011
- } catch (error) {
1012
- reject(error);
1013
- }
1014
- });
1015
- },
1016
- pay: async (payload) => {
1017
- return new Promise(async (resolve, reject) => {
1018
- try {
1019
- const response = await _MiniKit.awaitCommand(
1020
- "miniapp-payment" /* MiniAppPayment */,
1021
- "pay" /* Pay */,
1022
- () => _MiniKit.commands.pay(payload)
1023
- );
1024
- resolve(response);
1025
- } catch (error) {
1026
- reject(error);
1027
- }
1028
- });
1029
- },
1030
- walletAuth: async (payload) => {
1031
- return new Promise(async (resolve, reject) => {
1032
- try {
1033
- const response = await _MiniKit.awaitCommand(
1034
- "miniapp-wallet-auth" /* MiniAppWalletAuth */,
1035
- "wallet-auth" /* WalletAuth */,
1036
- () => _MiniKit.commands.walletAuth(payload)
1037
- );
1038
- return resolve(response);
1039
- } catch (error) {
1040
- reject(error);
1041
- }
1042
- });
1043
- },
1044
- sendTransaction: async (payload) => {
1045
- return new Promise(async (resolve, reject) => {
1046
- try {
1047
- const response = await _MiniKit.awaitCommand(
1048
- "miniapp-send-transaction" /* MiniAppSendTransaction */,
1049
- "send-transaction" /* SendTransaction */,
1050
- () => _MiniKit.commands.sendTransaction(payload)
1051
- );
1052
- return resolve(response);
1053
- } catch (error) {
1054
- reject(error);
1055
- }
1056
- });
1057
- },
1058
- signMessage: async (payload) => {
1059
- return new Promise(async (resolve, reject) => {
1060
- try {
1061
- const response = await _MiniKit.awaitCommand(
1062
- "miniapp-sign-message" /* MiniAppSignMessage */,
1063
- "sign-message" /* SignMessage */,
1064
- () => _MiniKit.commands.signMessage(payload)
1065
- );
1066
- return resolve(response);
1067
- } catch (error) {
1068
- reject(error);
1069
- }
1070
- });
1071
- },
1072
- signTypedData: async (payload) => {
1073
- return new Promise(async (resolve, reject) => {
1074
- try {
1075
- const response = await _MiniKit.awaitCommand(
1076
- "miniapp-sign-typed-data" /* MiniAppSignTypedData */,
1077
- "sign-typed-data" /* SignTypedData */,
1078
- () => _MiniKit.commands.signTypedData(payload)
1079
- );
1080
- return resolve(response);
1081
- } catch (error) {
1082
- reject(error);
1083
- }
1084
- });
1085
- },
1086
- shareContacts: async (payload) => {
1087
- return new Promise(async (resolve, reject) => {
1088
- try {
1089
- const response = await _MiniKit.awaitCommand(
1090
- "miniapp-share-contacts" /* MiniAppShareContacts */,
1091
- "share-contacts" /* ShareContacts */,
1092
- () => _MiniKit.commands.shareContacts(payload)
1093
- );
1094
- return resolve(response);
1095
- } catch (error) {
1096
- reject(error);
1097
- }
1098
- });
1099
- },
1100
- requestPermission: async (payload) => {
1101
- return new Promise(async (resolve, reject) => {
1102
- try {
1103
- const response = await _MiniKit.awaitCommand(
1104
- "miniapp-request-permission" /* MiniAppRequestPermission */,
1105
- "request-permission" /* RequestPermission */,
1106
- () => _MiniKit.commands.requestPermission(payload)
1107
- );
1108
- resolve(response);
1109
- } catch (error) {
1110
- reject(error);
1111
- }
1112
- });
1113
- },
1114
- getPermissions: async () => {
1115
- return new Promise(async (resolve, reject) => {
1116
- try {
1117
- const response = await _MiniKit.awaitCommand(
1118
- "miniapp-get-permissions" /* MiniAppGetPermissions */,
1119
- "get-permissions" /* GetPermissions */,
1120
- () => _MiniKit.commands.getPermissions()
1121
- );
1122
- resolve(response);
1123
- } catch (error) {
1124
- reject(error);
1125
- }
1126
- });
1127
- },
1128
- sendHapticFeedback: async (payload) => {
1129
- return new Promise(async (resolve, reject) => {
1130
- try {
1131
- const response = await _MiniKit.awaitCommand(
1132
- "miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
1133
- "send-haptic-feedback" /* SendHapticFeedback */,
1134
- () => _MiniKit.commands.sendHapticFeedback(payload)
1135
- );
1136
- resolve(response);
1137
- } catch (error) {
1138
- reject(error);
1139
- }
1140
- });
1141
- }
1142
- };
1143
- var MiniKit = _MiniKit;
2
+ AppErrorCodes,
3
+ Command,
4
+ GetPermissionsErrorCodes,
5
+ GetPermissionsErrorMessage,
6
+ MiniKit,
7
+ MiniKitInstallErrorCodes,
8
+ MiniKitInstallErrorMessage,
9
+ Network,
10
+ PaymentErrorCodes,
11
+ PaymentErrorMessage,
12
+ PaymentValidationErrors,
13
+ Permission,
14
+ RequestPermissionErrorCodes,
15
+ RequestPermissionErrorMessage,
16
+ ResponseEvent,
17
+ SendHapticFeedbackErrorCodes,
18
+ SendHapticFeedbackErrorMessage,
19
+ SendTransactionErrorCodes,
20
+ SendTransactionErrorMessage,
21
+ ShareContactsErrorCodes,
22
+ ShareContactsErrorMessage,
23
+ ShareFilesErrorCodes,
24
+ ShareFilesErrorMessage,
25
+ SignMessageErrorCodes,
26
+ SignMessageErrorMessage,
27
+ SignTypedDataErrorCodes,
28
+ SignTypedDataErrorMessage,
29
+ TokenDecimals,
30
+ Tokens,
31
+ VerificationErrorMessage,
32
+ WalletAuthErrorCodes,
33
+ WalletAuthErrorMessage,
34
+ parseSiweMessage,
35
+ tokenToDecimals,
36
+ verifySiweMessage
37
+ } from "./chunk-7FYGA6HX.js";
1144
38
 
1145
39
  // index.ts
1146
- import { VerificationLevel as VerificationLevel2 } from "@worldcoin/idkit-core";
40
+ import { VerificationLevel } from "@worldcoin/idkit-core";
1147
41
  import {
1148
42
  verifyCloudProof
1149
43
  } from "@worldcoin/idkit-core/backend";
1150
44
 
1151
45
  // helpers/address-book/index.ts
1152
- import { createPublicClient as createPublicClient3, http as http3 } from "viem";
1153
- import { worldchain as worldchain3 } from "viem/chains";
46
+ import { createPublicClient, http } from "viem";
47
+ import { worldchain } from "viem/chains";
1154
48
  var worldIdAddressBookContractAddress = "0x57b930D551e677CC36e2fA036Ae2fe8FdaE0330D";
1155
49
  var addressVerifiedUntilAbi = [
1156
50
  {
@@ -1174,9 +68,9 @@ var addressVerifiedUntilAbi = [
1174
68
  }
1175
69
  ];
1176
70
  var getIsUserVerified = async (walletAddress, rpcUrl) => {
1177
- const publicClient = createPublicClient3({
1178
- chain: worldchain3,
1179
- transport: http3(
71
+ const publicClient = createPublicClient({
72
+ chain: worldchain,
73
+ transport: http(
1180
74
  rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
1181
75
  )
1182
76
  });
@@ -1214,22 +108,23 @@ export {
1214
108
  RequestPermissionErrorCodes,
1215
109
  RequestPermissionErrorMessage,
1216
110
  ResponseEvent,
1217
- SAFE_CONTRACT_ABI,
1218
111
  SendHapticFeedbackErrorCodes,
1219
112
  SendHapticFeedbackErrorMessage,
1220
113
  SendTransactionErrorCodes,
1221
114
  SendTransactionErrorMessage,
1222
115
  ShareContactsErrorCodes,
1223
116
  ShareContactsErrorMessage,
117
+ ShareFilesErrorCodes,
118
+ ShareFilesErrorMessage,
1224
119
  SignMessageErrorCodes,
1225
120
  SignMessageErrorMessage,
1226
121
  SignTypedDataErrorCodes,
1227
122
  SignTypedDataErrorMessage,
1228
123
  TokenDecimals,
1229
124
  Tokens,
1230
- AppErrorCodes2 as VerificationErrorCodes,
125
+ AppErrorCodes as VerificationErrorCodes,
1231
126
  VerificationErrorMessage,
1232
- VerificationLevel2 as VerificationLevel,
127
+ VerificationLevel,
1233
128
  WalletAuthErrorCodes,
1234
129
  WalletAuthErrorMessage,
1235
130
  getIsUserVerified,