@worldcoin/minikit-js 1.9.4 → 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.
- package/build/{chunk-VOZXVH3R.js → chunk-DKXMTG56.js} +448 -268
- package/build/index.cjs +442 -260
- package/build/index.d.cts +83 -35
- package/build/index.d.ts +83 -35
- package/build/index.js +5 -1
- package/build/minikit-provider.cjs +249 -82
- package/build/minikit-provider.d.cts +1 -1
- package/build/minikit-provider.d.ts +1 -1
- package/build/minikit-provider.js +8 -5
- package/index.ts +1 -1
- package/package.json +1 -1
|
@@ -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__ */ ((
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return
|
|
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" /*
|
|
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("
|
|
247
|
+
console.error("USDC amount should be greater than $0.1");
|
|
35
248
|
return false;
|
|
36
249
|
}
|
|
37
250
|
if (payload.reference.length > 36) {
|
|
@@ -325,219 +538,104 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
325
538
|
Command2["RequestPermission"] = "request-permission";
|
|
326
539
|
Command2["GetPermissions"] = "get-permissions";
|
|
327
540
|
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
541
|
+
Command2["Share"] = "share";
|
|
328
542
|
return Command2;
|
|
329
543
|
})(Command || {});
|
|
330
544
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
331
545
|
Permission2["Notifications"] = "notifications";
|
|
332
546
|
Permission2["Contacts"] = "contacts";
|
|
547
|
+
Permission2["Microphone"] = "microphone";
|
|
333
548
|
return Permission2;
|
|
334
549
|
})(Permission || {});
|
|
335
550
|
|
|
336
|
-
// types/errors.ts
|
|
337
|
-
import { AppErrorCodes } from "@worldcoin/idkit-core";
|
|
338
|
-
import { AppErrorCodes as AppErrorCodes2 } from "@worldcoin/idkit-core";
|
|
339
|
-
var VerificationErrorMessage = {
|
|
340
|
-
[AppErrorCodes.VerificationRejected]: "You've cancelled the request in World App.",
|
|
341
|
-
[AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
342
|
-
[AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
343
|
-
[AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
344
|
-
[AppErrorCodes.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
|
|
345
|
-
[AppErrorCodes.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
|
|
346
|
-
[AppErrorCodes.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
|
|
347
|
-
[AppErrorCodes.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
|
|
348
|
-
[AppErrorCodes.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
|
|
349
|
-
[AppErrorCodes.GenericError]: "Something unexpected went wrong. Please try again.",
|
|
350
|
-
[AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
|
|
351
|
-
};
|
|
352
|
-
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
353
|
-
PaymentErrorCodes2["InputError"] = "input_error";
|
|
354
|
-
PaymentErrorCodes2["UserRejected"] = "user_rejected";
|
|
355
|
-
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
356
|
-
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
357
|
-
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
358
|
-
PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
359
|
-
PaymentErrorCodes2["GenericError"] = "generic_error";
|
|
360
|
-
PaymentErrorCodes2["UserBlocked"] = "user_blocked";
|
|
361
|
-
return PaymentErrorCodes2;
|
|
362
|
-
})(PaymentErrorCodes || {});
|
|
363
|
-
var PaymentErrorMessage = {
|
|
364
|
-
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
365
|
-
["user_rejected" /* UserRejected */]: "You have cancelled the payment in World App.",
|
|
366
|
-
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
367
|
-
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
368
|
-
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
369
|
-
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
370
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
371
|
-
["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
|
|
372
|
-
};
|
|
373
|
-
var PaymentValidationErrors = /* @__PURE__ */ ((PaymentValidationErrors2) => {
|
|
374
|
-
PaymentValidationErrors2["MalformedRequest"] = "There was a problem with this request. Please try again or contact the app owner.";
|
|
375
|
-
PaymentValidationErrors2["InvalidTokenAddress"] = "The token address is invalid. Please contact the app owner.";
|
|
376
|
-
PaymentValidationErrors2["InvalidAppId"] = "The app ID is invalid. Please contact the app owner.";
|
|
377
|
-
PaymentValidationErrors2["DuplicateReference"] = "This reference ID already exists please generate a new one and try again.";
|
|
378
|
-
return PaymentValidationErrors2;
|
|
379
|
-
})(PaymentValidationErrors || {});
|
|
380
|
-
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
381
|
-
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
382
|
-
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
383
|
-
WalletAuthErrorCodes2["GenericError"] = "generic_error";
|
|
384
|
-
return WalletAuthErrorCodes2;
|
|
385
|
-
})(WalletAuthErrorCodes || {});
|
|
386
|
-
var WalletAuthErrorMessage = {
|
|
387
|
-
["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
|
|
388
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
389
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
390
|
-
};
|
|
391
|
-
var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
|
|
392
|
-
SendTransactionErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
393
|
-
SendTransactionErrorCodes2["UserRejected"] = "user_rejected";
|
|
394
|
-
SendTransactionErrorCodes2["InputError"] = "input_error";
|
|
395
|
-
SendTransactionErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
396
|
-
SendTransactionErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
397
|
-
SendTransactionErrorCodes2["GenericError"] = "generic_error";
|
|
398
|
-
SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
399
|
-
SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
400
|
-
SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
401
|
-
SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
|
|
402
|
-
SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
|
|
403
|
-
SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
|
|
404
|
-
return SendTransactionErrorCodes2;
|
|
405
|
-
})(SendTransactionErrorCodes || {});
|
|
406
|
-
var SendTransactionErrorMessage = {
|
|
407
|
-
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
408
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
409
|
-
["input_error" /* InputError */]: "Invalid payload.",
|
|
410
|
-
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
411
|
-
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again later.",
|
|
412
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
413
|
-
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
414
|
-
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
415
|
-
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
|
|
416
|
-
["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
|
|
417
|
-
["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
|
|
418
|
-
["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
|
|
419
|
-
};
|
|
420
|
-
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
421
|
-
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
422
|
-
SignMessageErrorCodes2["UserRejected"] = "user_rejected";
|
|
423
|
-
SignMessageErrorCodes2["GenericError"] = "generic_error";
|
|
424
|
-
return SignMessageErrorCodes2;
|
|
425
|
-
})(SignMessageErrorCodes || {});
|
|
426
|
-
var SignMessageErrorMessage = {
|
|
427
|
-
["invalid_message" /* InvalidMessage */]: "Invalid message requested",
|
|
428
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
429
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
430
|
-
};
|
|
431
|
-
var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
432
|
-
SignTypedDataErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
433
|
-
SignTypedDataErrorCodes2["UserRejected"] = "user_rejected";
|
|
434
|
-
SignTypedDataErrorCodes2["InputError"] = "input_error";
|
|
435
|
-
SignTypedDataErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
436
|
-
SignTypedDataErrorCodes2["GenericError"] = "generic_error";
|
|
437
|
-
SignTypedDataErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
438
|
-
SignTypedDataErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
439
|
-
SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
440
|
-
return SignTypedDataErrorCodes2;
|
|
441
|
-
})(SignTypedDataErrorCodes || {});
|
|
442
|
-
var SignTypedDataErrorMessage = {
|
|
443
|
-
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
444
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
445
|
-
["input_error" /* InputError */]: "Invalid payload.",
|
|
446
|
-
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
447
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
448
|
-
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
449
|
-
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
450
|
-
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
451
|
-
};
|
|
452
|
-
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
453
|
-
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
454
|
-
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
455
|
-
MiniKitInstallErrorCodes2["OutsideOfWorldApp"] = "outside_of_worldapp";
|
|
456
|
-
MiniKitInstallErrorCodes2["NotOnClient"] = "not_on_client";
|
|
457
|
-
MiniKitInstallErrorCodes2["AppOutOfDate"] = "app_out_of_date";
|
|
458
|
-
return MiniKitInstallErrorCodes2;
|
|
459
|
-
})(MiniKitInstallErrorCodes || {});
|
|
460
|
-
var MiniKitInstallErrorMessage = {
|
|
461
|
-
["unknown" /* Unknown */]: "Failed to install MiniKit.",
|
|
462
|
-
["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
|
|
463
|
-
["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
|
|
464
|
-
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
465
|
-
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
466
|
-
};
|
|
467
|
-
var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
|
|
468
|
-
ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
|
|
469
|
-
ShareContactsErrorCodes2["GenericError"] = "generic_error";
|
|
470
|
-
return ShareContactsErrorCodes2;
|
|
471
|
-
})(ShareContactsErrorCodes || {});
|
|
472
|
-
var ShareContactsErrorMessage = {
|
|
473
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
474
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
475
|
-
};
|
|
476
|
-
var RequestPermissionErrorCodes = /* @__PURE__ */ ((RequestPermissionErrorCodes2) => {
|
|
477
|
-
RequestPermissionErrorCodes2["UserRejected"] = "user_rejected";
|
|
478
|
-
RequestPermissionErrorCodes2["GenericError"] = "generic_error";
|
|
479
|
-
RequestPermissionErrorCodes2["AlreadyRequested"] = "already_requested";
|
|
480
|
-
RequestPermissionErrorCodes2["PermissionDisabled"] = "permission_disabled";
|
|
481
|
-
RequestPermissionErrorCodes2["AlreadyGranted"] = "already_granted";
|
|
482
|
-
RequestPermissionErrorCodes2["UnsupportedPermission"] = "unsupported_permission";
|
|
483
|
-
return RequestPermissionErrorCodes2;
|
|
484
|
-
})(RequestPermissionErrorCodes || {});
|
|
485
|
-
var RequestPermissionErrorMessage = {
|
|
486
|
-
["user_rejected" /* UserRejected */]: "User declined sharing contacts",
|
|
487
|
-
["generic_error" /* GenericError */]: "Request failed for unknown reason.",
|
|
488
|
-
["already_requested" /* AlreadyRequested */]: "User has already declined turning on notifications once",
|
|
489
|
-
["permission_disabled" /* PermissionDisabled */]: "User does not have this permission enabled in World App",
|
|
490
|
-
["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
|
|
491
|
-
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
492
|
-
};
|
|
493
|
-
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
494
|
-
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
495
|
-
return GetPermissionsErrorCodes2;
|
|
496
|
-
})(GetPermissionsErrorCodes || {});
|
|
497
|
-
var GetPermissionsErrorMessage = {
|
|
498
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
499
|
-
};
|
|
500
|
-
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
501
|
-
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
502
|
-
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
503
|
-
return SendHapticFeedbackErrorCodes2;
|
|
504
|
-
})(SendHapticFeedbackErrorCodes || {});
|
|
505
|
-
var SendHapticFeedbackErrorMessage = {
|
|
506
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
507
|
-
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
508
|
-
};
|
|
509
|
-
var ShareFilesErrorCodes = /* @__PURE__ */ ((ShareFilesErrorCodes2) => {
|
|
510
|
-
ShareFilesErrorCodes2["UserRejected"] = "user_rejected";
|
|
511
|
-
ShareFilesErrorCodes2["GenericError"] = "generic_error";
|
|
512
|
-
ShareFilesErrorCodes2["InvalidFileName"] = "invalid_file_name";
|
|
513
|
-
return ShareFilesErrorCodes2;
|
|
514
|
-
})(ShareFilesErrorCodes || {});
|
|
515
|
-
var ShareFilesErrorMessage = {
|
|
516
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
517
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
518
|
-
["invalid_file_name" /* InvalidFileName */]: "Invalid file name. Make sure you include the extension"
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
// types/responses.ts
|
|
522
|
-
var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
523
|
-
ResponseEvent2["MiniAppVerifyAction"] = "miniapp-verify-action";
|
|
524
|
-
ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
|
|
525
|
-
ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
|
|
526
|
-
ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
|
|
527
|
-
ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
|
|
528
|
-
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
529
|
-
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
530
|
-
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
531
|
-
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
532
|
-
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
533
|
-
ResponseEvent2["MiniAppShareFiles"] = "miniapp-share-files";
|
|
534
|
-
return ResponseEvent2;
|
|
535
|
-
})(ResponseEvent || {});
|
|
536
|
-
|
|
537
551
|
// minikit.ts
|
|
538
552
|
import { VerificationLevel } from "@worldcoin/idkit-core";
|
|
539
553
|
import { encodeAction, generateSignal } from "@worldcoin/idkit-core/hashing";
|
|
540
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
|
+
|
|
541
639
|
// helpers/proof/index.ts
|
|
542
640
|
import {
|
|
543
641
|
createPublicClient as createPublicClient2,
|
|
@@ -593,6 +691,72 @@ var compressAndPadProof = async (proof, rpcUrl) => {
|
|
|
593
691
|
}
|
|
594
692
|
};
|
|
595
693
|
|
|
694
|
+
// helpers/share/index.ts
|
|
695
|
+
var MAX_FILES = 10;
|
|
696
|
+
var MAX_TOTAL_SIZE_MB = 50;
|
|
697
|
+
var MAX_TOTAL_SIZE_BYTES = MAX_TOTAL_SIZE_MB * 1024 * 1024;
|
|
698
|
+
var processFile = async (file) => {
|
|
699
|
+
const buffer = await file.arrayBuffer();
|
|
700
|
+
const uint8Array = new Uint8Array(buffer);
|
|
701
|
+
let binaryString = "";
|
|
702
|
+
const K_CHUNK_SIZE = 32768;
|
|
703
|
+
for (let i = 0; i < uint8Array.length; i += K_CHUNK_SIZE) {
|
|
704
|
+
const chunk = uint8Array.subarray(
|
|
705
|
+
i,
|
|
706
|
+
Math.min(i + K_CHUNK_SIZE, uint8Array.length)
|
|
707
|
+
);
|
|
708
|
+
binaryString += String.fromCharCode.apply(
|
|
709
|
+
null,
|
|
710
|
+
Array.from(chunk)
|
|
711
|
+
// Convert Uint8Array chunk to number[]
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
const base64Data = btoa(binaryString);
|
|
715
|
+
return {
|
|
716
|
+
name: file.name,
|
|
717
|
+
type: file.type,
|
|
718
|
+
data: base64Data
|
|
719
|
+
};
|
|
720
|
+
};
|
|
721
|
+
var formatShareInput = async (input) => {
|
|
722
|
+
if (!input.files) {
|
|
723
|
+
return {
|
|
724
|
+
title: input.title,
|
|
725
|
+
text: input.text,
|
|
726
|
+
url: input.url
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
if (!Array.isArray(input.files)) {
|
|
730
|
+
throw new Error('The "files" property must be an array.');
|
|
731
|
+
}
|
|
732
|
+
if (input.files.length === 0) {
|
|
733
|
+
} else {
|
|
734
|
+
if (input.files.length > MAX_FILES) {
|
|
735
|
+
throw new Error(`Cannot share more than ${MAX_FILES} files.`);
|
|
736
|
+
}
|
|
737
|
+
let totalSize = 0;
|
|
738
|
+
for (const file of input.files) {
|
|
739
|
+
if (!(file instanceof File)) {
|
|
740
|
+
throw new Error(
|
|
741
|
+
`Each item in the 'files' array must be a File object. Received: ${typeof file}`
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
totalSize += file.size;
|
|
745
|
+
}
|
|
746
|
+
if (totalSize > MAX_TOTAL_SIZE_BYTES) {
|
|
747
|
+
throw new Error(`Total file size cannot exceed ${MAX_TOTAL_SIZE_MB}MB.`);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
const fileProcessingPromises = input.files.map((file) => processFile(file));
|
|
751
|
+
const processedFiles = await Promise.all(fileProcessingPromises);
|
|
752
|
+
return {
|
|
753
|
+
files: processedFiles,
|
|
754
|
+
title: input.title,
|
|
755
|
+
text: input.text,
|
|
756
|
+
url: input.url
|
|
757
|
+
};
|
|
758
|
+
};
|
|
759
|
+
|
|
596
760
|
// helpers/siwe/validate-wallet-auth-command-input.ts
|
|
597
761
|
var validateWalletAuthCommandInput = (params) => {
|
|
598
762
|
if (!params.nonce) {
|
|
@@ -695,15 +859,6 @@ var getUserProfile = async (address) => {
|
|
|
695
859
|
return usernames?.[0] ?? { username: null, profile_picture_url: null };
|
|
696
860
|
};
|
|
697
861
|
|
|
698
|
-
// helpers/send-webview-event.ts
|
|
699
|
-
var sendWebviewEvent = (payload) => {
|
|
700
|
-
if (window.webkit) {
|
|
701
|
-
window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
|
|
702
|
-
} else if (window.Android) {
|
|
703
|
-
window.Android.postMessage?.(JSON.stringify(payload));
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
|
|
707
862
|
// minikit.ts
|
|
708
863
|
var sendMiniKitEvent = (payload) => {
|
|
709
864
|
sendWebviewEvent(payload);
|
|
@@ -712,7 +867,10 @@ var _MiniKit = class _MiniKit {
|
|
|
712
867
|
static sendInit() {
|
|
713
868
|
sendWebviewEvent({
|
|
714
869
|
command: "init",
|
|
715
|
-
payload: {
|
|
870
|
+
payload: {
|
|
871
|
+
version: this.MINIKIT_VERSION,
|
|
872
|
+
minorVersion: this.MINIKIT_MINOR_VERSION
|
|
873
|
+
}
|
|
716
874
|
});
|
|
717
875
|
}
|
|
718
876
|
static subscribe(event, handler) {
|
|
@@ -827,6 +985,9 @@ var _MiniKit = class _MiniKit {
|
|
|
827
985
|
_MiniKit.user.optedIntoOptionalAnalytics = window.WorldApp.is_optional_analytics;
|
|
828
986
|
_MiniKit.user.deviceOS = window.WorldApp.device_os;
|
|
829
987
|
_MiniKit.user.worldAppVersion = window.WorldApp.world_app_version;
|
|
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;
|
|
830
991
|
try {
|
|
831
992
|
window.MiniKit = _MiniKit;
|
|
832
993
|
this.sendInit();
|
|
@@ -842,6 +1003,7 @@ var _MiniKit = class _MiniKit {
|
|
|
842
1003
|
};
|
|
843
1004
|
}
|
|
844
1005
|
_MiniKit.isReady = true;
|
|
1006
|
+
setupMicrophone();
|
|
845
1007
|
if (!this.commandsValid(window.WorldApp.supported_commands)) {
|
|
846
1008
|
return {
|
|
847
1009
|
success: false,
|
|
@@ -862,6 +1024,7 @@ var _MiniKit = class _MiniKit {
|
|
|
862
1024
|
}
|
|
863
1025
|
};
|
|
864
1026
|
_MiniKit.MINIKIT_VERSION = 1;
|
|
1027
|
+
_MiniKit.MINIKIT_MINOR_VERSION = 96;
|
|
865
1028
|
_MiniKit.miniKitCommandVersion = {
|
|
866
1029
|
["verify" /* Verify */]: 1,
|
|
867
1030
|
["pay" /* Pay */]: 1,
|
|
@@ -872,8 +1035,8 @@ _MiniKit.miniKitCommandVersion = {
|
|
|
872
1035
|
["share-contacts" /* ShareContacts */]: 1,
|
|
873
1036
|
["request-permission" /* RequestPermission */]: 1,
|
|
874
1037
|
["get-permissions" /* GetPermissions */]: 1,
|
|
875
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
876
|
-
|
|
1038
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
1039
|
+
["share" /* Share */]: 1
|
|
877
1040
|
};
|
|
878
1041
|
_MiniKit.isCommandAvailable = {
|
|
879
1042
|
["verify" /* Verify */]: false,
|
|
@@ -885,8 +1048,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
885
1048
|
["share-contacts" /* ShareContacts */]: false,
|
|
886
1049
|
["request-permission" /* RequestPermission */]: false,
|
|
887
1050
|
["get-permissions" /* GetPermissions */]: false,
|
|
888
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
889
|
-
|
|
1051
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
1052
|
+
["share" /* Share */]: false
|
|
890
1053
|
};
|
|
891
1054
|
_MiniKit.listeners = {
|
|
892
1055
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -909,12 +1072,15 @@ _MiniKit.listeners = {
|
|
|
909
1072
|
},
|
|
910
1073
|
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
911
1074
|
},
|
|
912
|
-
["miniapp-share
|
|
1075
|
+
["miniapp-share" /* MiniAppShare */]: () => {
|
|
1076
|
+
},
|
|
1077
|
+
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
913
1078
|
}
|
|
914
1079
|
};
|
|
915
1080
|
_MiniKit.appId = null;
|
|
916
1081
|
_MiniKit.user = {};
|
|
917
1082
|
_MiniKit.isReady = false;
|
|
1083
|
+
_MiniKit.deviceProperties = {};
|
|
918
1084
|
_MiniKit.getUserByAddress = async (address) => {
|
|
919
1085
|
const userProfile = await getUserProfile(
|
|
920
1086
|
address ?? _MiniKit.user.walletAddress
|
|
@@ -1080,7 +1246,7 @@ _MiniKit.commands = {
|
|
|
1080
1246
|
return payload;
|
|
1081
1247
|
},
|
|
1082
1248
|
shareContacts: (payload) => {
|
|
1083
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["
|
|
1249
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share-contacts" /* ShareContacts */]) {
|
|
1084
1250
|
console.error(
|
|
1085
1251
|
"'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1086
1252
|
);
|
|
@@ -1136,24 +1302,38 @@ _MiniKit.commands = {
|
|
|
1136
1302
|
payload
|
|
1137
1303
|
});
|
|
1138
1304
|
return payload;
|
|
1305
|
+
},
|
|
1306
|
+
// We return share input here because the payload is formatted asynchronously
|
|
1307
|
+
share: (payload) => {
|
|
1308
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share" /* Share */]) {
|
|
1309
|
+
console.error(
|
|
1310
|
+
"'share' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1311
|
+
);
|
|
1312
|
+
return null;
|
|
1313
|
+
}
|
|
1314
|
+
if (_MiniKit.deviceProperties.deviceOS === "ios" && typeof navigator !== "undefined") {
|
|
1315
|
+
sendMiniKitEvent({
|
|
1316
|
+
command: "share" /* Share */,
|
|
1317
|
+
version: _MiniKit.miniKitCommandVersion["share" /* Share */],
|
|
1318
|
+
payload
|
|
1319
|
+
});
|
|
1320
|
+
navigator.share(payload);
|
|
1321
|
+
} else {
|
|
1322
|
+
formatShareInput(payload).then((formattedResult) => {
|
|
1323
|
+
sendMiniKitEvent({
|
|
1324
|
+
command: "share" /* Share */,
|
|
1325
|
+
version: _MiniKit.miniKitCommandVersion["share" /* Share */],
|
|
1326
|
+
payload: formattedResult
|
|
1327
|
+
});
|
|
1328
|
+
}).catch((error) => {
|
|
1329
|
+
console.error("Failed to format share input", error);
|
|
1330
|
+
});
|
|
1331
|
+
_MiniKit.subscribe("miniapp-share" /* MiniAppShare */, (payload2) => {
|
|
1332
|
+
console.log("Share Response", payload2);
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
return payload;
|
|
1139
1336
|
}
|
|
1140
|
-
// shareFiles: (payload: ShareFilesInput): ShareFilesPayload | null => {
|
|
1141
|
-
// if (
|
|
1142
|
-
// typeof window === 'undefined' ||
|
|
1143
|
-
// !this.isCommandAvailable[Command.ShareFiles]
|
|
1144
|
-
// ) {
|
|
1145
|
-
// console.error(
|
|
1146
|
-
// "'shareFiles' command is unavailable. Check MiniKit.install() or update the app version",
|
|
1147
|
-
// );
|
|
1148
|
-
// return null;
|
|
1149
|
-
// }
|
|
1150
|
-
// sendMiniKitEvent<WebViewBasePayload>({
|
|
1151
|
-
// command: Command.ShareFiles,
|
|
1152
|
-
// version: this.miniKitCommandVersion[Command.ShareFiles],
|
|
1153
|
-
// payload,
|
|
1154
|
-
// });
|
|
1155
|
-
// return payload;
|
|
1156
|
-
// },
|
|
1157
1337
|
};
|
|
1158
1338
|
/**
|
|
1159
1339
|
* This object contains async versions of all the commands.
|
|
@@ -1310,38 +1490,28 @@ _MiniKit.commandsAsync = {
|
|
|
1310
1490
|
reject(error);
|
|
1311
1491
|
}
|
|
1312
1492
|
});
|
|
1493
|
+
},
|
|
1494
|
+
share: async (payload) => {
|
|
1495
|
+
return new Promise(async (resolve, reject) => {
|
|
1496
|
+
try {
|
|
1497
|
+
const response = await _MiniKit.awaitCommand(
|
|
1498
|
+
"miniapp-share" /* MiniAppShare */,
|
|
1499
|
+
"share" /* Share */,
|
|
1500
|
+
() => _MiniKit.commands.share(payload)
|
|
1501
|
+
);
|
|
1502
|
+
resolve({
|
|
1503
|
+
commandPayload: response.commandPayload,
|
|
1504
|
+
finalPayload: response.finalPayload
|
|
1505
|
+
});
|
|
1506
|
+
} catch (error) {
|
|
1507
|
+
reject(error);
|
|
1508
|
+
}
|
|
1509
|
+
});
|
|
1313
1510
|
}
|
|
1314
|
-
// shareFiles: async (
|
|
1315
|
-
// payload: ShareFilesInput,
|
|
1316
|
-
// ): AsyncHandlerReturn<
|
|
1317
|
-
// ShareFilesPayload | null,
|
|
1318
|
-
// MiniAppShareFilesPayload
|
|
1319
|
-
// > => {
|
|
1320
|
-
// return new Promise(async (resolve, reject) => {
|
|
1321
|
-
// try {
|
|
1322
|
-
// const response = await MiniKit.awaitCommand(
|
|
1323
|
-
// ResponseEvent.MiniAppShareFiles,
|
|
1324
|
-
// Command.ShareFiles,
|
|
1325
|
-
// () => this.commands.shareFiles(payload),
|
|
1326
|
-
// );
|
|
1327
|
-
// resolve(response);
|
|
1328
|
-
// } catch (error) {
|
|
1329
|
-
// reject(error);
|
|
1330
|
-
// }
|
|
1331
|
-
// });
|
|
1332
|
-
// },
|
|
1333
1511
|
};
|
|
1334
1512
|
var MiniKit = _MiniKit;
|
|
1335
1513
|
|
|
1336
1514
|
export {
|
|
1337
|
-
Tokens,
|
|
1338
|
-
TokenDecimals,
|
|
1339
|
-
Network,
|
|
1340
|
-
tokenToDecimals,
|
|
1341
|
-
parseSiweMessage,
|
|
1342
|
-
verifySiweMessage,
|
|
1343
|
-
Command,
|
|
1344
|
-
Permission,
|
|
1345
1515
|
VerificationErrorMessage,
|
|
1346
1516
|
PaymentErrorCodes,
|
|
1347
1517
|
PaymentErrorMessage,
|
|
@@ -1366,7 +1536,17 @@ export {
|
|
|
1366
1536
|
SendHapticFeedbackErrorMessage,
|
|
1367
1537
|
ShareFilesErrorCodes,
|
|
1368
1538
|
ShareFilesErrorMessage,
|
|
1539
|
+
MicrophoneErrorCodes,
|
|
1540
|
+
MicrophoneErrorMessage,
|
|
1369
1541
|
AppErrorCodes2 as AppErrorCodes,
|
|
1370
1542
|
ResponseEvent,
|
|
1543
|
+
Tokens,
|
|
1544
|
+
TokenDecimals,
|
|
1545
|
+
Network,
|
|
1546
|
+
tokenToDecimals,
|
|
1547
|
+
parseSiweMessage,
|
|
1548
|
+
verifySiweMessage,
|
|
1549
|
+
Command,
|
|
1550
|
+
Permission,
|
|
1371
1551
|
MiniKit
|
|
1372
1552
|
};
|