@worldcoin/minikit-js 1.9.5 → 1.9.6

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.
@@ -1,11 +1,224 @@
1
+ // types/errors.ts
2
+ import { AppErrorCodes } from "@worldcoin/idkit-core";
3
+ import { AppErrorCodes as AppErrorCodes2 } from "@worldcoin/idkit-core";
4
+ var VerificationErrorMessage = {
5
+ [AppErrorCodes.VerificationRejected]: "You've cancelled the request in World App.",
6
+ [AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
7
+ [AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
8
+ [AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
9
+ [AppErrorCodes.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
10
+ [AppErrorCodes.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
11
+ [AppErrorCodes.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
12
+ [AppErrorCodes.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
13
+ [AppErrorCodes.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
14
+ [AppErrorCodes.GenericError]: "Something unexpected went wrong. Please try again.",
15
+ [AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
16
+ };
17
+ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
18
+ PaymentErrorCodes2["InputError"] = "input_error";
19
+ PaymentErrorCodes2["UserRejected"] = "user_rejected";
20
+ PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
21
+ PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
22
+ PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
23
+ PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
24
+ PaymentErrorCodes2["GenericError"] = "generic_error";
25
+ PaymentErrorCodes2["UserBlocked"] = "user_blocked";
26
+ return PaymentErrorCodes2;
27
+ })(PaymentErrorCodes || {});
28
+ var PaymentErrorMessage = {
29
+ ["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
30
+ ["user_rejected" /* UserRejected */]: "You have cancelled the payment in World App.",
31
+ ["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
32
+ ["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
33
+ ["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
34
+ ["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
35
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
36
+ ["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
37
+ };
38
+ var PaymentValidationErrors = /* @__PURE__ */ ((PaymentValidationErrors2) => {
39
+ PaymentValidationErrors2["MalformedRequest"] = "There was a problem with this request. Please try again or contact the app owner.";
40
+ PaymentValidationErrors2["InvalidTokenAddress"] = "The token address is invalid. Please contact the app owner.";
41
+ PaymentValidationErrors2["InvalidAppId"] = "The app ID is invalid. Please contact the app owner.";
42
+ PaymentValidationErrors2["DuplicateReference"] = "This reference ID already exists please generate a new one and try again.";
43
+ return PaymentValidationErrors2;
44
+ })(PaymentValidationErrors || {});
45
+ var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
46
+ WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
47
+ WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
48
+ WalletAuthErrorCodes2["GenericError"] = "generic_error";
49
+ return WalletAuthErrorCodes2;
50
+ })(WalletAuthErrorCodes || {});
51
+ var WalletAuthErrorMessage = {
52
+ ["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
53
+ ["user_rejected" /* UserRejected */]: "User rejected the request.",
54
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong."
55
+ };
56
+ var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
57
+ SendTransactionErrorCodes2["InvalidOperation"] = "invalid_operation";
58
+ SendTransactionErrorCodes2["UserRejected"] = "user_rejected";
59
+ SendTransactionErrorCodes2["InputError"] = "input_error";
60
+ SendTransactionErrorCodes2["SimulationFailed"] = "simulation_failed";
61
+ SendTransactionErrorCodes2["TransactionFailed"] = "transaction_failed";
62
+ SendTransactionErrorCodes2["GenericError"] = "generic_error";
63
+ SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
64
+ SendTransactionErrorCodes2["ValidationError"] = "validation_error";
65
+ SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
66
+ SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
67
+ SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
68
+ SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
69
+ SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
70
+ return SendTransactionErrorCodes2;
71
+ })(SendTransactionErrorCodes || {});
72
+ var SendTransactionErrorMessage = {
73
+ ["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
74
+ ["user_rejected" /* UserRejected */]: "User rejected the request.",
75
+ ["input_error" /* InputError */]: "Invalid payload.",
76
+ ["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
77
+ ["validation_error" /* ValidationError */]: "The transaction validation failed. Please try again.",
78
+ ["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again later.",
79
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
80
+ ["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
81
+ ["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
82
+ ["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
83
+ ["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
84
+ ["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
85
+ ["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
86
+ };
87
+ var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
88
+ SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
89
+ SignMessageErrorCodes2["UserRejected"] = "user_rejected";
90
+ SignMessageErrorCodes2["GenericError"] = "generic_error";
91
+ return SignMessageErrorCodes2;
92
+ })(SignMessageErrorCodes || {});
93
+ var SignMessageErrorMessage = {
94
+ ["invalid_message" /* InvalidMessage */]: "Invalid message requested",
95
+ ["user_rejected" /* UserRejected */]: "User rejected the request.",
96
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong."
97
+ };
98
+ var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
99
+ SignTypedDataErrorCodes2["InvalidOperation"] = "invalid_operation";
100
+ SignTypedDataErrorCodes2["UserRejected"] = "user_rejected";
101
+ SignTypedDataErrorCodes2["InputError"] = "input_error";
102
+ SignTypedDataErrorCodes2["SimulationFailed"] = "simulation_failed";
103
+ SignTypedDataErrorCodes2["GenericError"] = "generic_error";
104
+ SignTypedDataErrorCodes2["DisallowedOperation"] = "disallowed_operation";
105
+ SignTypedDataErrorCodes2["InvalidContract"] = "invalid_contract";
106
+ SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
107
+ return SignTypedDataErrorCodes2;
108
+ })(SignTypedDataErrorCodes || {});
109
+ var SignTypedDataErrorMessage = {
110
+ ["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
111
+ ["user_rejected" /* UserRejected */]: "User rejected the request.",
112
+ ["input_error" /* InputError */]: "Invalid payload.",
113
+ ["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
114
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
115
+ ["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
116
+ ["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
117
+ ["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
118
+ };
119
+ var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
120
+ MiniKitInstallErrorCodes2["Unknown"] = "unknown";
121
+ MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
122
+ MiniKitInstallErrorCodes2["OutsideOfWorldApp"] = "outside_of_worldapp";
123
+ MiniKitInstallErrorCodes2["NotOnClient"] = "not_on_client";
124
+ MiniKitInstallErrorCodes2["AppOutOfDate"] = "app_out_of_date";
125
+ return MiniKitInstallErrorCodes2;
126
+ })(MiniKitInstallErrorCodes || {});
127
+ var MiniKitInstallErrorMessage = {
128
+ ["unknown" /* Unknown */]: "Failed to install MiniKit.",
129
+ ["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
130
+ ["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
131
+ ["not_on_client" /* NotOnClient */]: "Window object is not available.",
132
+ ["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
133
+ };
134
+ var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
135
+ ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
136
+ ShareContactsErrorCodes2["GenericError"] = "generic_error";
137
+ return ShareContactsErrorCodes2;
138
+ })(ShareContactsErrorCodes || {});
139
+ var ShareContactsErrorMessage = {
140
+ ["user_rejected" /* UserRejected */]: "User rejected the request.",
141
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong."
142
+ };
143
+ var RequestPermissionErrorCodes = /* @__PURE__ */ ((RequestPermissionErrorCodes2) => {
144
+ RequestPermissionErrorCodes2["UserRejected"] = "user_rejected";
145
+ RequestPermissionErrorCodes2["GenericError"] = "generic_error";
146
+ RequestPermissionErrorCodes2["AlreadyRequested"] = "already_requested";
147
+ RequestPermissionErrorCodes2["PermissionDisabled"] = "permission_disabled";
148
+ RequestPermissionErrorCodes2["AlreadyGranted"] = "already_granted";
149
+ RequestPermissionErrorCodes2["UnsupportedPermission"] = "unsupported_permission";
150
+ return RequestPermissionErrorCodes2;
151
+ })(RequestPermissionErrorCodes || {});
152
+ var RequestPermissionErrorMessage = {
153
+ ["user_rejected" /* UserRejected */]: "User declined sharing contacts",
154
+ ["generic_error" /* GenericError */]: "Request failed for unknown reason.",
155
+ ["already_requested" /* AlreadyRequested */]: "User has already declined turning on notifications once",
156
+ ["permission_disabled" /* PermissionDisabled */]: "User does not have this permission enabled in World App",
157
+ ["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
158
+ ["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
159
+ };
160
+ var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
161
+ GetPermissionsErrorCodes2["GenericError"] = "generic_error";
162
+ return GetPermissionsErrorCodes2;
163
+ })(GetPermissionsErrorCodes || {});
164
+ var GetPermissionsErrorMessage = {
165
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
166
+ };
167
+ var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
168
+ SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
169
+ SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
170
+ return SendHapticFeedbackErrorCodes2;
171
+ })(SendHapticFeedbackErrorCodes || {});
172
+ var SendHapticFeedbackErrorMessage = {
173
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong.",
174
+ ["user_rejected" /* UserRejected */]: "User rejected the request."
175
+ };
176
+ var ShareFilesErrorCodes = /* @__PURE__ */ ((ShareFilesErrorCodes2) => {
177
+ ShareFilesErrorCodes2["UserRejected"] = "user_rejected";
178
+ ShareFilesErrorCodes2["GenericError"] = "generic_error";
179
+ ShareFilesErrorCodes2["InvalidFileName"] = "invalid_file_name";
180
+ return ShareFilesErrorCodes2;
181
+ })(ShareFilesErrorCodes || {});
182
+ var ShareFilesErrorMessage = {
183
+ ["user_rejected" /* UserRejected */]: "User rejected the request.",
184
+ ["generic_error" /* GenericError */]: "Something unexpected went wrong.",
185
+ ["invalid_file_name" /* InvalidFileName */]: "Invalid file name. Make sure you include the extension"
186
+ };
187
+ var MicrophoneErrorCodes = /* @__PURE__ */ ((MicrophoneErrorCodes2) => {
188
+ MicrophoneErrorCodes2["MiniAppPermissionNotEnabled"] = "mini_app_permission_not_enabled";
189
+ MicrophoneErrorCodes2["WorldAppPermissionNotEnabled"] = "world_app_permission_not_enabled";
190
+ return MicrophoneErrorCodes2;
191
+ })(MicrophoneErrorCodes || {});
192
+ var MicrophoneErrorMessage = {
193
+ ["mini_app_permission_not_enabled" /* MiniAppPermissionNotEnabled */]: "Microphone permission not enabled for your Mini App",
194
+ ["world_app_permission_not_enabled" /* WorldAppPermissionNotEnabled */]: "Microphone permission not enabled in World App"
195
+ };
196
+
197
+ // types/responses.ts
198
+ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
199
+ ResponseEvent2["MiniAppVerifyAction"] = "miniapp-verify-action";
200
+ ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
201
+ ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
202
+ ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
203
+ ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
204
+ ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
205
+ ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
206
+ ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
207
+ ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
208
+ ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
209
+ ResponseEvent2["MiniAppShare"] = "miniapp-share";
210
+ ResponseEvent2["MiniAppMicrophone"] = "miniapp-microphone";
211
+ return ResponseEvent2;
212
+ })(ResponseEvent || {});
213
+
1
214
  // types/payment.ts
2
- var Tokens = /* @__PURE__ */ ((Tokens3) => {
3
- Tokens3["USDCE"] = "USDCE";
4
- Tokens3["WLD"] = "WLD";
5
- return Tokens3;
215
+ var Tokens = /* @__PURE__ */ ((Tokens2) => {
216
+ Tokens2["USDC"] = "USDCE";
217
+ Tokens2["WLD"] = "WLD";
218
+ return Tokens2;
6
219
  })(Tokens || {});
7
220
  var TokenDecimals = {
8
- ["USDCE" /* USDCE */]: 6,
221
+ ["USDCE" /* USDC */]: 6,
9
222
  ["WLD" /* WLD */]: 18
10
223
  };
11
224
  var Network = /* @__PURE__ */ ((Network2) => {
@@ -29,9 +242,9 @@ var tokenToDecimals = (amount, token) => {
29
242
  };
30
243
  var validatePaymentPayload = (payload) => {
31
244
  if (payload.tokens.some(
32
- (token) => token.symbol == "USDCE" && parseFloat(token.token_amount) < 0.1
245
+ (token) => token.symbol == "USDCE" /* USDC */ && parseFloat(token.token_amount) < 0.1
33
246
  )) {
34
- console.error("USDCE amount should be greater than $0.1");
247
+ console.error("USDC amount should be greater than $0.1");
35
248
  return false;
36
249
  }
37
250
  if (payload.reference.length > 36) {
@@ -331,214 +544,98 @@ var Command = /* @__PURE__ */ ((Command2) => {
331
544
  var Permission = /* @__PURE__ */ ((Permission2) => {
332
545
  Permission2["Notifications"] = "notifications";
333
546
  Permission2["Contacts"] = "contacts";
547
+ Permission2["Microphone"] = "microphone";
334
548
  return Permission2;
335
549
  })(Permission || {});
336
550
 
337
- // types/errors.ts
338
- import { AppErrorCodes } from "@worldcoin/idkit-core";
339
- import { AppErrorCodes as AppErrorCodes2 } from "@worldcoin/idkit-core";
340
- var VerificationErrorMessage = {
341
- [AppErrorCodes.VerificationRejected]: "You've cancelled the request in World App.",
342
- [AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
343
- [AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
344
- [AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
345
- [AppErrorCodes.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
346
- [AppErrorCodes.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
347
- [AppErrorCodes.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
348
- [AppErrorCodes.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
349
- [AppErrorCodes.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
350
- [AppErrorCodes.GenericError]: "Something unexpected went wrong. Please try again.",
351
- [AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
352
- };
353
- var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
354
- PaymentErrorCodes2["InputError"] = "input_error";
355
- PaymentErrorCodes2["UserRejected"] = "user_rejected";
356
- PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
357
- PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
358
- PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
359
- PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
360
- PaymentErrorCodes2["GenericError"] = "generic_error";
361
- PaymentErrorCodes2["UserBlocked"] = "user_blocked";
362
- return PaymentErrorCodes2;
363
- })(PaymentErrorCodes || {});
364
- var PaymentErrorMessage = {
365
- ["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
366
- ["user_rejected" /* UserRejected */]: "You have cancelled the payment in World App.",
367
- ["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
368
- ["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
369
- ["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
370
- ["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
371
- ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
372
- ["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
373
- };
374
- var PaymentValidationErrors = /* @__PURE__ */ ((PaymentValidationErrors2) => {
375
- PaymentValidationErrors2["MalformedRequest"] = "There was a problem with this request. Please try again or contact the app owner.";
376
- PaymentValidationErrors2["InvalidTokenAddress"] = "The token address is invalid. Please contact the app owner.";
377
- PaymentValidationErrors2["InvalidAppId"] = "The app ID is invalid. Please contact the app owner.";
378
- PaymentValidationErrors2["DuplicateReference"] = "This reference ID already exists please generate a new one and try again.";
379
- return PaymentValidationErrors2;
380
- })(PaymentValidationErrors || {});
381
- var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
382
- WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
383
- WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
384
- WalletAuthErrorCodes2["GenericError"] = "generic_error";
385
- return WalletAuthErrorCodes2;
386
- })(WalletAuthErrorCodes || {});
387
- var WalletAuthErrorMessage = {
388
- ["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
389
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
390
- ["generic_error" /* GenericError */]: "Something unexpected went wrong."
391
- };
392
- var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
393
- SendTransactionErrorCodes2["InvalidOperation"] = "invalid_operation";
394
- SendTransactionErrorCodes2["UserRejected"] = "user_rejected";
395
- SendTransactionErrorCodes2["InputError"] = "input_error";
396
- SendTransactionErrorCodes2["SimulationFailed"] = "simulation_failed";
397
- SendTransactionErrorCodes2["TransactionFailed"] = "transaction_failed";
398
- SendTransactionErrorCodes2["GenericError"] = "generic_error";
399
- SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
400
- SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
401
- SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
402
- SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
403
- SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
404
- SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
405
- return SendTransactionErrorCodes2;
406
- })(SendTransactionErrorCodes || {});
407
- var SendTransactionErrorMessage = {
408
- ["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
409
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
410
- ["input_error" /* InputError */]: "Invalid payload.",
411
- ["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
412
- ["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again later.",
413
- ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
414
- ["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
415
- ["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
416
- ["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
417
- ["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
418
- ["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
419
- ["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
420
- };
421
- var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
422
- SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
423
- SignMessageErrorCodes2["UserRejected"] = "user_rejected";
424
- SignMessageErrorCodes2["GenericError"] = "generic_error";
425
- return SignMessageErrorCodes2;
426
- })(SignMessageErrorCodes || {});
427
- var SignMessageErrorMessage = {
428
- ["invalid_message" /* InvalidMessage */]: "Invalid message requested",
429
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
430
- ["generic_error" /* GenericError */]: "Something unexpected went wrong."
431
- };
432
- var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
433
- SignTypedDataErrorCodes2["InvalidOperation"] = "invalid_operation";
434
- SignTypedDataErrorCodes2["UserRejected"] = "user_rejected";
435
- SignTypedDataErrorCodes2["InputError"] = "input_error";
436
- SignTypedDataErrorCodes2["SimulationFailed"] = "simulation_failed";
437
- SignTypedDataErrorCodes2["GenericError"] = "generic_error";
438
- SignTypedDataErrorCodes2["DisallowedOperation"] = "disallowed_operation";
439
- SignTypedDataErrorCodes2["InvalidContract"] = "invalid_contract";
440
- SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
441
- return SignTypedDataErrorCodes2;
442
- })(SignTypedDataErrorCodes || {});
443
- var SignTypedDataErrorMessage = {
444
- ["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
445
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
446
- ["input_error" /* InputError */]: "Invalid payload.",
447
- ["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
448
- ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
449
- ["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
450
- ["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
451
- ["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
452
- };
453
- var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
454
- MiniKitInstallErrorCodes2["Unknown"] = "unknown";
455
- MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
456
- MiniKitInstallErrorCodes2["OutsideOfWorldApp"] = "outside_of_worldapp";
457
- MiniKitInstallErrorCodes2["NotOnClient"] = "not_on_client";
458
- MiniKitInstallErrorCodes2["AppOutOfDate"] = "app_out_of_date";
459
- return MiniKitInstallErrorCodes2;
460
- })(MiniKitInstallErrorCodes || {});
461
- var MiniKitInstallErrorMessage = {
462
- ["unknown" /* Unknown */]: "Failed to install MiniKit.",
463
- ["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
464
- ["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
465
- ["not_on_client" /* NotOnClient */]: "Window object is not available.",
466
- ["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
467
- };
468
- var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
469
- ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
470
- ShareContactsErrorCodes2["GenericError"] = "generic_error";
471
- return ShareContactsErrorCodes2;
472
- })(ShareContactsErrorCodes || {});
473
- var ShareContactsErrorMessage = {
474
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
475
- ["generic_error" /* GenericError */]: "Something unexpected went wrong."
476
- };
477
- var RequestPermissionErrorCodes = /* @__PURE__ */ ((RequestPermissionErrorCodes2) => {
478
- RequestPermissionErrorCodes2["UserRejected"] = "user_rejected";
479
- RequestPermissionErrorCodes2["GenericError"] = "generic_error";
480
- RequestPermissionErrorCodes2["AlreadyRequested"] = "already_requested";
481
- RequestPermissionErrorCodes2["PermissionDisabled"] = "permission_disabled";
482
- RequestPermissionErrorCodes2["AlreadyGranted"] = "already_granted";
483
- RequestPermissionErrorCodes2["UnsupportedPermission"] = "unsupported_permission";
484
- return RequestPermissionErrorCodes2;
485
- })(RequestPermissionErrorCodes || {});
486
- var RequestPermissionErrorMessage = {
487
- ["user_rejected" /* UserRejected */]: "User declined sharing contacts",
488
- ["generic_error" /* GenericError */]: "Request failed for unknown reason.",
489
- ["already_requested" /* AlreadyRequested */]: "User has already declined turning on notifications once",
490
- ["permission_disabled" /* PermissionDisabled */]: "User does not have this permission enabled in World App",
491
- ["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
492
- ["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
493
- };
494
- var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
495
- GetPermissionsErrorCodes2["GenericError"] = "generic_error";
496
- return GetPermissionsErrorCodes2;
497
- })(GetPermissionsErrorCodes || {});
498
- var GetPermissionsErrorMessage = {
499
- ["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
500
- };
501
- var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
502
- SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
503
- SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
504
- return SendHapticFeedbackErrorCodes2;
505
- })(SendHapticFeedbackErrorCodes || {});
506
- var SendHapticFeedbackErrorMessage = {
507
- ["generic_error" /* GenericError */]: "Something unexpected went wrong.",
508
- ["user_rejected" /* UserRejected */]: "User rejected the request."
509
- };
510
- var ShareFilesErrorCodes = /* @__PURE__ */ ((ShareFilesErrorCodes2) => {
511
- ShareFilesErrorCodes2["UserRejected"] = "user_rejected";
512
- ShareFilesErrorCodes2["GenericError"] = "generic_error";
513
- ShareFilesErrorCodes2["InvalidFileName"] = "invalid_file_name";
514
- return ShareFilesErrorCodes2;
515
- })(ShareFilesErrorCodes || {});
516
- var ShareFilesErrorMessage = {
517
- ["user_rejected" /* UserRejected */]: "User rejected the request.",
518
- ["generic_error" /* GenericError */]: "Something unexpected went wrong.",
519
- ["invalid_file_name" /* InvalidFileName */]: "Invalid file name. Make sure you include the extension"
520
- };
521
-
522
- // types/responses.ts
523
- var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
524
- ResponseEvent2["MiniAppVerifyAction"] = "miniapp-verify-action";
525
- ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
526
- ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
527
- ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
528
- ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
529
- ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
530
- ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
531
- ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
532
- ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
533
- ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
534
- ResponseEvent2["MiniAppShare"] = "miniapp-share";
535
- return ResponseEvent2;
536
- })(ResponseEvent || {});
537
-
538
551
  // minikit.ts
539
552
  import { VerificationLevel } from "@worldcoin/idkit-core";
540
553
  import { encodeAction, generateSignal } from "@worldcoin/idkit-core/hashing";
541
554
 
555
+ // helpers/send-webview-event.ts
556
+ var sendWebviewEvent = (payload) => {
557
+ if (window.webkit) {
558
+ window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
559
+ } else if (window.Android) {
560
+ window.Android.postMessage?.(JSON.stringify(payload));
561
+ }
562
+ };
563
+
564
+ // helpers/microphone/index.ts
565
+ var microphoneSetupDone = false;
566
+ var setupMicrophone = () => {
567
+ if (microphoneSetupDone) {
568
+ return;
569
+ }
570
+ if (typeof navigator !== "undefined" && !navigator.mediaDevices?.getUserMedia)
571
+ return;
572
+ const originalStop = MediaStreamTrack.prototype.stop;
573
+ MediaStreamTrack.prototype.stop = function() {
574
+ originalStop.call(this);
575
+ if (this.readyState === "ended") {
576
+ setTimeout(() => this.dispatchEvent(new Event("ended")), 0);
577
+ }
578
+ };
579
+ const realGUM = navigator.mediaDevices.getUserMedia.bind(
580
+ navigator.mediaDevices
581
+ );
582
+ const live = /* @__PURE__ */ new Set();
583
+ async function wrapped(constraints) {
584
+ const stream = await realGUM(constraints);
585
+ sendWebviewEvent({
586
+ command: "microphone-stream-started",
587
+ version: 1,
588
+ payload: {
589
+ streamId: stream.id
590
+ }
591
+ });
592
+ live.add(stream);
593
+ stream.getTracks().forEach((t) => {
594
+ t.addEventListener("ended", () => {
595
+ sendWebviewEvent({
596
+ command: "microphone-stream-ended",
597
+ version: 1,
598
+ payload: {
599
+ streamId: stream.id
600
+ }
601
+ });
602
+ live.delete(stream);
603
+ });
604
+ });
605
+ return stream;
606
+ }
607
+ Object.defineProperty(navigator.mediaDevices, "getUserMedia", {
608
+ value: wrapped,
609
+ writable: false,
610
+ configurable: false,
611
+ enumerable: true
612
+ });
613
+ Object.freeze(navigator.mediaDevices);
614
+ const stopAllMiniAppMicrophoneStreams = () => {
615
+ live.forEach((s) => {
616
+ s.getTracks().forEach((t) => {
617
+ t.stop();
618
+ sendWebviewEvent({
619
+ command: "microphone-stream-ended",
620
+ version: 1,
621
+ payload: {
622
+ streamId: s.id
623
+ }
624
+ });
625
+ });
626
+ });
627
+ live.clear();
628
+ };
629
+ MiniKit.subscribe("miniapp-microphone" /* MiniAppMicrophone */, (payload) => {
630
+ if (payload.status === "error" && (payload.error_code === "mini_app_permission_not_enabled" /* MiniAppPermissionNotEnabled */ || payload.error_code === "world_app_permission_not_enabled" /* WorldAppPermissionNotEnabled */)) {
631
+ console.log("stopping all microphone streams", payload);
632
+ stopAllMiniAppMicrophoneStreams();
633
+ }
634
+ });
635
+ window.__stopAllMiniAppMicrophoneStreams = stopAllMiniAppMicrophoneStreams;
636
+ microphoneSetupDone = true;
637
+ };
638
+
542
639
  // helpers/proof/index.ts
543
640
  import {
544
641
  createPublicClient as createPublicClient2,
@@ -762,15 +859,6 @@ var getUserProfile = async (address) => {
762
859
  return usernames?.[0] ?? { username: null, profile_picture_url: null };
763
860
  };
764
861
 
765
- // helpers/send-webview-event.ts
766
- var sendWebviewEvent = (payload) => {
767
- if (window.webkit) {
768
- window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
769
- } else if (window.Android) {
770
- window.Android.postMessage?.(JSON.stringify(payload));
771
- }
772
- };
773
-
774
862
  // minikit.ts
775
863
  var sendMiniKitEvent = (payload) => {
776
864
  sendWebviewEvent(payload);
@@ -779,7 +867,10 @@ var _MiniKit = class _MiniKit {
779
867
  static sendInit() {
780
868
  sendWebviewEvent({
781
869
  command: "init",
782
- payload: { version: this.MINIKIT_VERSION }
870
+ payload: {
871
+ version: this.MINIKIT_VERSION,
872
+ minorVersion: this.MINIKIT_MINOR_VERSION
873
+ }
783
874
  });
784
875
  }
785
876
  static subscribe(event, handler) {
@@ -895,6 +986,8 @@ var _MiniKit = class _MiniKit {
895
986
  _MiniKit.user.deviceOS = window.WorldApp.device_os;
896
987
  _MiniKit.user.worldAppVersion = window.WorldApp.world_app_version;
897
988
  _MiniKit.deviceProperties.safeAreaInsets = window.WorldApp.safe_area_insets;
989
+ _MiniKit.deviceProperties.deviceOS = window.WorldApp.device_os;
990
+ _MiniKit.deviceProperties.worldAppVersion = window.WorldApp.world_app_version;
898
991
  try {
899
992
  window.MiniKit = _MiniKit;
900
993
  this.sendInit();
@@ -910,6 +1003,7 @@ var _MiniKit = class _MiniKit {
910
1003
  };
911
1004
  }
912
1005
  _MiniKit.isReady = true;
1006
+ setupMicrophone();
913
1007
  if (!this.commandsValid(window.WorldApp.supported_commands)) {
914
1008
  return {
915
1009
  success: false,
@@ -930,6 +1024,7 @@ var _MiniKit = class _MiniKit {
930
1024
  }
931
1025
  };
932
1026
  _MiniKit.MINIKIT_VERSION = 1;
1027
+ _MiniKit.MINIKIT_MINOR_VERSION = 96;
933
1028
  _MiniKit.miniKitCommandVersion = {
934
1029
  ["verify" /* Verify */]: 1,
935
1030
  ["pay" /* Pay */]: 1,
@@ -978,6 +1073,8 @@ _MiniKit.listeners = {
978
1073
  ["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
979
1074
  },
980
1075
  ["miniapp-share" /* MiniAppShare */]: () => {
1076
+ },
1077
+ ["miniapp-microphone" /* MiniAppMicrophone */]: () => {
981
1078
  }
982
1079
  };
983
1080
  _MiniKit.appId = null;
@@ -1214,7 +1311,12 @@ _MiniKit.commands = {
1214
1311
  );
1215
1312
  return null;
1216
1313
  }
1217
- if (_MiniKit.user.deviceOS === "ios") {
1314
+ if (_MiniKit.deviceProperties.deviceOS === "ios" && typeof navigator !== "undefined") {
1315
+ sendMiniKitEvent({
1316
+ command: "share" /* Share */,
1317
+ version: _MiniKit.miniKitCommandVersion["share" /* Share */],
1318
+ payload
1319
+ });
1218
1320
  navigator.share(payload);
1219
1321
  } else {
1220
1322
  formatShareInput(payload).then((formattedResult) => {
@@ -1410,14 +1512,6 @@ _MiniKit.commandsAsync = {
1410
1512
  var MiniKit = _MiniKit;
1411
1513
 
1412
1514
  export {
1413
- Tokens,
1414
- TokenDecimals,
1415
- Network,
1416
- tokenToDecimals,
1417
- parseSiweMessage,
1418
- verifySiweMessage,
1419
- Command,
1420
- Permission,
1421
1515
  VerificationErrorMessage,
1422
1516
  PaymentErrorCodes,
1423
1517
  PaymentErrorMessage,
@@ -1442,7 +1536,17 @@ export {
1442
1536
  SendHapticFeedbackErrorMessage,
1443
1537
  ShareFilesErrorCodes,
1444
1538
  ShareFilesErrorMessage,
1539
+ MicrophoneErrorCodes,
1540
+ MicrophoneErrorMessage,
1445
1541
  AppErrorCodes2 as AppErrorCodes,
1446
1542
  ResponseEvent,
1543
+ Tokens,
1544
+ TokenDecimals,
1545
+ Network,
1546
+ tokenToDecimals,
1547
+ parseSiweMessage,
1548
+ verifySiweMessage,
1549
+ Command,
1550
+ Permission,
1447
1551
  MiniKit
1448
1552
  };