@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
package/build/index.cjs
CHANGED
|
@@ -23,6 +23,8 @@ __export(core_exports, {
|
|
|
23
23
|
Command: () => Command,
|
|
24
24
|
GetPermissionsErrorCodes: () => GetPermissionsErrorCodes,
|
|
25
25
|
GetPermissionsErrorMessage: () => GetPermissionsErrorMessage,
|
|
26
|
+
MicrophoneErrorCodes: () => MicrophoneErrorCodes,
|
|
27
|
+
MicrophoneErrorMessage: () => MicrophoneErrorMessage,
|
|
26
28
|
MiniKit: () => MiniKit,
|
|
27
29
|
MiniKitInstallErrorCodes: () => MiniKitInstallErrorCodes,
|
|
28
30
|
MiniKitInstallErrorMessage: () => MiniKitInstallErrorMessage,
|
|
@@ -65,14 +67,311 @@ module.exports = __toCommonJS(core_exports);
|
|
|
65
67
|
var import_idkit_core3 = require("@worldcoin/idkit-core");
|
|
66
68
|
var import_hashing = require("@worldcoin/idkit-core/hashing");
|
|
67
69
|
|
|
70
|
+
// helpers/send-webview-event.ts
|
|
71
|
+
var sendWebviewEvent = (payload) => {
|
|
72
|
+
if (window.webkit) {
|
|
73
|
+
window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
|
|
74
|
+
} else if (window.Android) {
|
|
75
|
+
window.Android.postMessage?.(JSON.stringify(payload));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// types/errors.ts
|
|
80
|
+
var import_idkit_core = require("@worldcoin/idkit-core");
|
|
81
|
+
var import_idkit_core2 = require("@worldcoin/idkit-core");
|
|
82
|
+
var VerificationErrorMessage = {
|
|
83
|
+
[import_idkit_core.AppErrorCodes.VerificationRejected]: "You've cancelled the request in World App.",
|
|
84
|
+
[import_idkit_core.AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
85
|
+
[import_idkit_core.AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
86
|
+
[import_idkit_core.AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
87
|
+
[import_idkit_core.AppErrorCodes.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
|
|
88
|
+
[import_idkit_core.AppErrorCodes.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
|
|
89
|
+
[import_idkit_core.AppErrorCodes.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
|
|
90
|
+
[import_idkit_core.AppErrorCodes.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
|
|
91
|
+
[import_idkit_core.AppErrorCodes.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
|
|
92
|
+
[import_idkit_core.AppErrorCodes.GenericError]: "Something unexpected went wrong. Please try again.",
|
|
93
|
+
[import_idkit_core.AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
|
|
94
|
+
};
|
|
95
|
+
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
96
|
+
PaymentErrorCodes2["InputError"] = "input_error";
|
|
97
|
+
PaymentErrorCodes2["UserRejected"] = "user_rejected";
|
|
98
|
+
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
99
|
+
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
100
|
+
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
101
|
+
PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
102
|
+
PaymentErrorCodes2["GenericError"] = "generic_error";
|
|
103
|
+
PaymentErrorCodes2["UserBlocked"] = "user_blocked";
|
|
104
|
+
return PaymentErrorCodes2;
|
|
105
|
+
})(PaymentErrorCodes || {});
|
|
106
|
+
var PaymentErrorMessage = {
|
|
107
|
+
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
108
|
+
["user_rejected" /* UserRejected */]: "You have cancelled the payment in World App.",
|
|
109
|
+
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
110
|
+
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
111
|
+
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
112
|
+
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
113
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
114
|
+
["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
|
|
115
|
+
};
|
|
116
|
+
var PaymentValidationErrors = /* @__PURE__ */ ((PaymentValidationErrors2) => {
|
|
117
|
+
PaymentValidationErrors2["MalformedRequest"] = "There was a problem with this request. Please try again or contact the app owner.";
|
|
118
|
+
PaymentValidationErrors2["InvalidTokenAddress"] = "The token address is invalid. Please contact the app owner.";
|
|
119
|
+
PaymentValidationErrors2["InvalidAppId"] = "The app ID is invalid. Please contact the app owner.";
|
|
120
|
+
PaymentValidationErrors2["DuplicateReference"] = "This reference ID already exists please generate a new one and try again.";
|
|
121
|
+
return PaymentValidationErrors2;
|
|
122
|
+
})(PaymentValidationErrors || {});
|
|
123
|
+
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
124
|
+
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
125
|
+
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
126
|
+
WalletAuthErrorCodes2["GenericError"] = "generic_error";
|
|
127
|
+
return WalletAuthErrorCodes2;
|
|
128
|
+
})(WalletAuthErrorCodes || {});
|
|
129
|
+
var WalletAuthErrorMessage = {
|
|
130
|
+
["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
|
|
131
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
132
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
133
|
+
};
|
|
134
|
+
var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
|
|
135
|
+
SendTransactionErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
136
|
+
SendTransactionErrorCodes2["UserRejected"] = "user_rejected";
|
|
137
|
+
SendTransactionErrorCodes2["InputError"] = "input_error";
|
|
138
|
+
SendTransactionErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
139
|
+
SendTransactionErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
140
|
+
SendTransactionErrorCodes2["GenericError"] = "generic_error";
|
|
141
|
+
SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
142
|
+
SendTransactionErrorCodes2["ValidationError"] = "validation_error";
|
|
143
|
+
SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
144
|
+
SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
145
|
+
SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
|
|
146
|
+
SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
|
|
147
|
+
SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
|
|
148
|
+
return SendTransactionErrorCodes2;
|
|
149
|
+
})(SendTransactionErrorCodes || {});
|
|
150
|
+
var SendTransactionErrorMessage = {
|
|
151
|
+
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
152
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
153
|
+
["input_error" /* InputError */]: "Invalid payload.",
|
|
154
|
+
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
155
|
+
["validation_error" /* ValidationError */]: "The transaction validation failed. Please try again.",
|
|
156
|
+
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again later.",
|
|
157
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
158
|
+
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
159
|
+
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
160
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
|
|
161
|
+
["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
|
|
162
|
+
["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
|
|
163
|
+
["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
|
|
164
|
+
};
|
|
165
|
+
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
166
|
+
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
167
|
+
SignMessageErrorCodes2["UserRejected"] = "user_rejected";
|
|
168
|
+
SignMessageErrorCodes2["GenericError"] = "generic_error";
|
|
169
|
+
return SignMessageErrorCodes2;
|
|
170
|
+
})(SignMessageErrorCodes || {});
|
|
171
|
+
var SignMessageErrorMessage = {
|
|
172
|
+
["invalid_message" /* InvalidMessage */]: "Invalid message requested",
|
|
173
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
174
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
175
|
+
};
|
|
176
|
+
var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
177
|
+
SignTypedDataErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
178
|
+
SignTypedDataErrorCodes2["UserRejected"] = "user_rejected";
|
|
179
|
+
SignTypedDataErrorCodes2["InputError"] = "input_error";
|
|
180
|
+
SignTypedDataErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
181
|
+
SignTypedDataErrorCodes2["GenericError"] = "generic_error";
|
|
182
|
+
SignTypedDataErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
183
|
+
SignTypedDataErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
184
|
+
SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
185
|
+
return SignTypedDataErrorCodes2;
|
|
186
|
+
})(SignTypedDataErrorCodes || {});
|
|
187
|
+
var SignTypedDataErrorMessage = {
|
|
188
|
+
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
189
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
190
|
+
["input_error" /* InputError */]: "Invalid payload.",
|
|
191
|
+
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
192
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
193
|
+
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
194
|
+
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
195
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
196
|
+
};
|
|
197
|
+
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
198
|
+
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
199
|
+
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
200
|
+
MiniKitInstallErrorCodes2["OutsideOfWorldApp"] = "outside_of_worldapp";
|
|
201
|
+
MiniKitInstallErrorCodes2["NotOnClient"] = "not_on_client";
|
|
202
|
+
MiniKitInstallErrorCodes2["AppOutOfDate"] = "app_out_of_date";
|
|
203
|
+
return MiniKitInstallErrorCodes2;
|
|
204
|
+
})(MiniKitInstallErrorCodes || {});
|
|
205
|
+
var MiniKitInstallErrorMessage = {
|
|
206
|
+
["unknown" /* Unknown */]: "Failed to install MiniKit.",
|
|
207
|
+
["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
|
|
208
|
+
["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
|
|
209
|
+
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
210
|
+
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
211
|
+
};
|
|
212
|
+
var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
|
|
213
|
+
ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
|
|
214
|
+
ShareContactsErrorCodes2["GenericError"] = "generic_error";
|
|
215
|
+
return ShareContactsErrorCodes2;
|
|
216
|
+
})(ShareContactsErrorCodes || {});
|
|
217
|
+
var ShareContactsErrorMessage = {
|
|
218
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
219
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
220
|
+
};
|
|
221
|
+
var RequestPermissionErrorCodes = /* @__PURE__ */ ((RequestPermissionErrorCodes2) => {
|
|
222
|
+
RequestPermissionErrorCodes2["UserRejected"] = "user_rejected";
|
|
223
|
+
RequestPermissionErrorCodes2["GenericError"] = "generic_error";
|
|
224
|
+
RequestPermissionErrorCodes2["AlreadyRequested"] = "already_requested";
|
|
225
|
+
RequestPermissionErrorCodes2["PermissionDisabled"] = "permission_disabled";
|
|
226
|
+
RequestPermissionErrorCodes2["AlreadyGranted"] = "already_granted";
|
|
227
|
+
RequestPermissionErrorCodes2["UnsupportedPermission"] = "unsupported_permission";
|
|
228
|
+
return RequestPermissionErrorCodes2;
|
|
229
|
+
})(RequestPermissionErrorCodes || {});
|
|
230
|
+
var RequestPermissionErrorMessage = {
|
|
231
|
+
["user_rejected" /* UserRejected */]: "User declined sharing contacts",
|
|
232
|
+
["generic_error" /* GenericError */]: "Request failed for unknown reason.",
|
|
233
|
+
["already_requested" /* AlreadyRequested */]: "User has already declined turning on notifications once",
|
|
234
|
+
["permission_disabled" /* PermissionDisabled */]: "User does not have this permission enabled in World App",
|
|
235
|
+
["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
|
|
236
|
+
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
237
|
+
};
|
|
238
|
+
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
239
|
+
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
240
|
+
return GetPermissionsErrorCodes2;
|
|
241
|
+
})(GetPermissionsErrorCodes || {});
|
|
242
|
+
var GetPermissionsErrorMessage = {
|
|
243
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
244
|
+
};
|
|
245
|
+
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
246
|
+
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
247
|
+
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
248
|
+
return SendHapticFeedbackErrorCodes2;
|
|
249
|
+
})(SendHapticFeedbackErrorCodes || {});
|
|
250
|
+
var SendHapticFeedbackErrorMessage = {
|
|
251
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
252
|
+
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
253
|
+
};
|
|
254
|
+
var ShareFilesErrorCodes = /* @__PURE__ */ ((ShareFilesErrorCodes2) => {
|
|
255
|
+
ShareFilesErrorCodes2["UserRejected"] = "user_rejected";
|
|
256
|
+
ShareFilesErrorCodes2["GenericError"] = "generic_error";
|
|
257
|
+
ShareFilesErrorCodes2["InvalidFileName"] = "invalid_file_name";
|
|
258
|
+
return ShareFilesErrorCodes2;
|
|
259
|
+
})(ShareFilesErrorCodes || {});
|
|
260
|
+
var ShareFilesErrorMessage = {
|
|
261
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
262
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
263
|
+
["invalid_file_name" /* InvalidFileName */]: "Invalid file name. Make sure you include the extension"
|
|
264
|
+
};
|
|
265
|
+
var MicrophoneErrorCodes = /* @__PURE__ */ ((MicrophoneErrorCodes2) => {
|
|
266
|
+
MicrophoneErrorCodes2["MiniAppPermissionNotEnabled"] = "mini_app_permission_not_enabled";
|
|
267
|
+
MicrophoneErrorCodes2["WorldAppPermissionNotEnabled"] = "world_app_permission_not_enabled";
|
|
268
|
+
return MicrophoneErrorCodes2;
|
|
269
|
+
})(MicrophoneErrorCodes || {});
|
|
270
|
+
var MicrophoneErrorMessage = {
|
|
271
|
+
["mini_app_permission_not_enabled" /* MiniAppPermissionNotEnabled */]: "Microphone permission not enabled for your Mini App",
|
|
272
|
+
["world_app_permission_not_enabled" /* WorldAppPermissionNotEnabled */]: "Microphone permission not enabled in World App"
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// types/responses.ts
|
|
276
|
+
var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
277
|
+
ResponseEvent2["MiniAppVerifyAction"] = "miniapp-verify-action";
|
|
278
|
+
ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
|
|
279
|
+
ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
|
|
280
|
+
ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
|
|
281
|
+
ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
|
|
282
|
+
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
283
|
+
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
284
|
+
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
285
|
+
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
286
|
+
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
287
|
+
ResponseEvent2["MiniAppShare"] = "miniapp-share";
|
|
288
|
+
ResponseEvent2["MiniAppMicrophone"] = "miniapp-microphone";
|
|
289
|
+
return ResponseEvent2;
|
|
290
|
+
})(ResponseEvent || {});
|
|
291
|
+
|
|
292
|
+
// helpers/microphone/index.ts
|
|
293
|
+
var microphoneSetupDone = false;
|
|
294
|
+
var setupMicrophone = () => {
|
|
295
|
+
if (microphoneSetupDone) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (typeof navigator !== "undefined" && !navigator.mediaDevices?.getUserMedia)
|
|
299
|
+
return;
|
|
300
|
+
const originalStop = MediaStreamTrack.prototype.stop;
|
|
301
|
+
MediaStreamTrack.prototype.stop = function() {
|
|
302
|
+
originalStop.call(this);
|
|
303
|
+
if (this.readyState === "ended") {
|
|
304
|
+
setTimeout(() => this.dispatchEvent(new Event("ended")), 0);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
const realGUM = navigator.mediaDevices.getUserMedia.bind(
|
|
308
|
+
navigator.mediaDevices
|
|
309
|
+
);
|
|
310
|
+
const live = /* @__PURE__ */ new Set();
|
|
311
|
+
async function wrapped(constraints) {
|
|
312
|
+
const stream = await realGUM(constraints);
|
|
313
|
+
sendWebviewEvent({
|
|
314
|
+
command: "microphone-stream-started",
|
|
315
|
+
version: 1,
|
|
316
|
+
payload: {
|
|
317
|
+
streamId: stream.id
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
live.add(stream);
|
|
321
|
+
stream.getTracks().forEach((t) => {
|
|
322
|
+
t.addEventListener("ended", () => {
|
|
323
|
+
sendWebviewEvent({
|
|
324
|
+
command: "microphone-stream-ended",
|
|
325
|
+
version: 1,
|
|
326
|
+
payload: {
|
|
327
|
+
streamId: stream.id
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
live.delete(stream);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
return stream;
|
|
334
|
+
}
|
|
335
|
+
Object.defineProperty(navigator.mediaDevices, "getUserMedia", {
|
|
336
|
+
value: wrapped,
|
|
337
|
+
writable: false,
|
|
338
|
+
configurable: false,
|
|
339
|
+
enumerable: true
|
|
340
|
+
});
|
|
341
|
+
Object.freeze(navigator.mediaDevices);
|
|
342
|
+
const stopAllMiniAppMicrophoneStreams = () => {
|
|
343
|
+
live.forEach((s) => {
|
|
344
|
+
s.getTracks().forEach((t) => {
|
|
345
|
+
t.stop();
|
|
346
|
+
sendWebviewEvent({
|
|
347
|
+
command: "microphone-stream-ended",
|
|
348
|
+
version: 1,
|
|
349
|
+
payload: {
|
|
350
|
+
streamId: s.id
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
live.clear();
|
|
356
|
+
};
|
|
357
|
+
MiniKit.subscribe("miniapp-microphone" /* MiniAppMicrophone */, (payload) => {
|
|
358
|
+
if (payload.status === "error" && (payload.error_code === "mini_app_permission_not_enabled" /* MiniAppPermissionNotEnabled */ || payload.error_code === "world_app_permission_not_enabled" /* WorldAppPermissionNotEnabled */)) {
|
|
359
|
+
console.log("stopping all microphone streams", payload);
|
|
360
|
+
stopAllMiniAppMicrophoneStreams();
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
window.__stopAllMiniAppMicrophoneStreams = stopAllMiniAppMicrophoneStreams;
|
|
364
|
+
microphoneSetupDone = true;
|
|
365
|
+
};
|
|
366
|
+
|
|
68
367
|
// types/payment.ts
|
|
69
|
-
var Tokens = /* @__PURE__ */ ((
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
368
|
+
var Tokens = /* @__PURE__ */ ((Tokens2) => {
|
|
369
|
+
Tokens2["USDC"] = "USDCE";
|
|
370
|
+
Tokens2["WLD"] = "WLD";
|
|
371
|
+
return Tokens2;
|
|
73
372
|
})(Tokens || {});
|
|
74
373
|
var TokenDecimals = {
|
|
75
|
-
["USDCE" /*
|
|
374
|
+
["USDCE" /* USDC */]: 6,
|
|
76
375
|
["WLD" /* WLD */]: 18
|
|
77
376
|
};
|
|
78
377
|
var Network = /* @__PURE__ */ ((Network2) => {
|
|
@@ -96,9 +395,9 @@ var tokenToDecimals = (amount, token) => {
|
|
|
96
395
|
};
|
|
97
396
|
var validatePaymentPayload = (payload) => {
|
|
98
397
|
if (payload.tokens.some(
|
|
99
|
-
(token) => token.symbol == "USDCE" && parseFloat(token.token_amount) < 0.1
|
|
398
|
+
(token) => token.symbol == "USDCE" /* USDC */ && parseFloat(token.token_amount) < 0.1
|
|
100
399
|
)) {
|
|
101
|
-
console.error("
|
|
400
|
+
console.error("USDC amount should be greater than $0.1");
|
|
102
401
|
return false;
|
|
103
402
|
}
|
|
104
403
|
if (payload.reference.length > 36) {
|
|
@@ -161,6 +460,72 @@ var compressAndPadProof = async (proof, rpcUrl) => {
|
|
|
161
460
|
}
|
|
162
461
|
};
|
|
163
462
|
|
|
463
|
+
// helpers/share/index.ts
|
|
464
|
+
var MAX_FILES = 10;
|
|
465
|
+
var MAX_TOTAL_SIZE_MB = 50;
|
|
466
|
+
var MAX_TOTAL_SIZE_BYTES = MAX_TOTAL_SIZE_MB * 1024 * 1024;
|
|
467
|
+
var processFile = async (file) => {
|
|
468
|
+
const buffer = await file.arrayBuffer();
|
|
469
|
+
const uint8Array = new Uint8Array(buffer);
|
|
470
|
+
let binaryString = "";
|
|
471
|
+
const K_CHUNK_SIZE = 32768;
|
|
472
|
+
for (let i = 0; i < uint8Array.length; i += K_CHUNK_SIZE) {
|
|
473
|
+
const chunk = uint8Array.subarray(
|
|
474
|
+
i,
|
|
475
|
+
Math.min(i + K_CHUNK_SIZE, uint8Array.length)
|
|
476
|
+
);
|
|
477
|
+
binaryString += String.fromCharCode.apply(
|
|
478
|
+
null,
|
|
479
|
+
Array.from(chunk)
|
|
480
|
+
// Convert Uint8Array chunk to number[]
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
const base64Data = btoa(binaryString);
|
|
484
|
+
return {
|
|
485
|
+
name: file.name,
|
|
486
|
+
type: file.type,
|
|
487
|
+
data: base64Data
|
|
488
|
+
};
|
|
489
|
+
};
|
|
490
|
+
var formatShareInput = async (input) => {
|
|
491
|
+
if (!input.files) {
|
|
492
|
+
return {
|
|
493
|
+
title: input.title,
|
|
494
|
+
text: input.text,
|
|
495
|
+
url: input.url
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
if (!Array.isArray(input.files)) {
|
|
499
|
+
throw new Error('The "files" property must be an array.');
|
|
500
|
+
}
|
|
501
|
+
if (input.files.length === 0) {
|
|
502
|
+
} else {
|
|
503
|
+
if (input.files.length > MAX_FILES) {
|
|
504
|
+
throw new Error(`Cannot share more than ${MAX_FILES} files.`);
|
|
505
|
+
}
|
|
506
|
+
let totalSize = 0;
|
|
507
|
+
for (const file of input.files) {
|
|
508
|
+
if (!(file instanceof File)) {
|
|
509
|
+
throw new Error(
|
|
510
|
+
`Each item in the 'files' array must be a File object. Received: ${typeof file}`
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
totalSize += file.size;
|
|
514
|
+
}
|
|
515
|
+
if (totalSize > MAX_TOTAL_SIZE_BYTES) {
|
|
516
|
+
throw new Error(`Total file size cannot exceed ${MAX_TOTAL_SIZE_MB}MB.`);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const fileProcessingPromises = input.files.map((file) => processFile(file));
|
|
520
|
+
const processedFiles = await Promise.all(fileProcessingPromises);
|
|
521
|
+
return {
|
|
522
|
+
files: processedFiles,
|
|
523
|
+
title: input.title,
|
|
524
|
+
text: input.text,
|
|
525
|
+
url: input.url
|
|
526
|
+
};
|
|
527
|
+
};
|
|
528
|
+
|
|
164
529
|
// helpers/siwe/siwe.ts
|
|
165
530
|
var import_viem2 = require("viem");
|
|
166
531
|
var import_chains2 = require("viem/chains");
|
|
@@ -538,224 +903,16 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
538
903
|
Command2["RequestPermission"] = "request-permission";
|
|
539
904
|
Command2["GetPermissions"] = "get-permissions";
|
|
540
905
|
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
906
|
+
Command2["Share"] = "share";
|
|
541
907
|
return Command2;
|
|
542
908
|
})(Command || {});
|
|
543
909
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
544
910
|
Permission2["Notifications"] = "notifications";
|
|
545
911
|
Permission2["Contacts"] = "contacts";
|
|
912
|
+
Permission2["Microphone"] = "microphone";
|
|
546
913
|
return Permission2;
|
|
547
914
|
})(Permission || {});
|
|
548
915
|
|
|
549
|
-
// types/errors.ts
|
|
550
|
-
var import_idkit_core = require("@worldcoin/idkit-core");
|
|
551
|
-
var import_idkit_core2 = require("@worldcoin/idkit-core");
|
|
552
|
-
var VerificationErrorMessage = {
|
|
553
|
-
[import_idkit_core.AppErrorCodes.VerificationRejected]: "You've cancelled the request in World App.",
|
|
554
|
-
[import_idkit_core.AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
555
|
-
[import_idkit_core.AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
556
|
-
[import_idkit_core.AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
557
|
-
[import_idkit_core.AppErrorCodes.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
|
|
558
|
-
[import_idkit_core.AppErrorCodes.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
|
|
559
|
-
[import_idkit_core.AppErrorCodes.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
|
|
560
|
-
[import_idkit_core.AppErrorCodes.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
|
|
561
|
-
[import_idkit_core.AppErrorCodes.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
|
|
562
|
-
[import_idkit_core.AppErrorCodes.GenericError]: "Something unexpected went wrong. Please try again.",
|
|
563
|
-
[import_idkit_core.AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
|
|
564
|
-
};
|
|
565
|
-
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
566
|
-
PaymentErrorCodes2["InputError"] = "input_error";
|
|
567
|
-
PaymentErrorCodes2["UserRejected"] = "user_rejected";
|
|
568
|
-
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
569
|
-
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
570
|
-
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
571
|
-
PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
572
|
-
PaymentErrorCodes2["GenericError"] = "generic_error";
|
|
573
|
-
PaymentErrorCodes2["UserBlocked"] = "user_blocked";
|
|
574
|
-
return PaymentErrorCodes2;
|
|
575
|
-
})(PaymentErrorCodes || {});
|
|
576
|
-
var PaymentErrorMessage = {
|
|
577
|
-
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
578
|
-
["user_rejected" /* UserRejected */]: "You have cancelled the payment in World App.",
|
|
579
|
-
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
580
|
-
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
581
|
-
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
582
|
-
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
583
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
584
|
-
["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
|
|
585
|
-
};
|
|
586
|
-
var PaymentValidationErrors = /* @__PURE__ */ ((PaymentValidationErrors2) => {
|
|
587
|
-
PaymentValidationErrors2["MalformedRequest"] = "There was a problem with this request. Please try again or contact the app owner.";
|
|
588
|
-
PaymentValidationErrors2["InvalidTokenAddress"] = "The token address is invalid. Please contact the app owner.";
|
|
589
|
-
PaymentValidationErrors2["InvalidAppId"] = "The app ID is invalid. Please contact the app owner.";
|
|
590
|
-
PaymentValidationErrors2["DuplicateReference"] = "This reference ID already exists please generate a new one and try again.";
|
|
591
|
-
return PaymentValidationErrors2;
|
|
592
|
-
})(PaymentValidationErrors || {});
|
|
593
|
-
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
594
|
-
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
595
|
-
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
596
|
-
WalletAuthErrorCodes2["GenericError"] = "generic_error";
|
|
597
|
-
return WalletAuthErrorCodes2;
|
|
598
|
-
})(WalletAuthErrorCodes || {});
|
|
599
|
-
var WalletAuthErrorMessage = {
|
|
600
|
-
["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
|
|
601
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
602
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
603
|
-
};
|
|
604
|
-
var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
|
|
605
|
-
SendTransactionErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
606
|
-
SendTransactionErrorCodes2["UserRejected"] = "user_rejected";
|
|
607
|
-
SendTransactionErrorCodes2["InputError"] = "input_error";
|
|
608
|
-
SendTransactionErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
609
|
-
SendTransactionErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
610
|
-
SendTransactionErrorCodes2["GenericError"] = "generic_error";
|
|
611
|
-
SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
612
|
-
SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
613
|
-
SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
614
|
-
SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
|
|
615
|
-
SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
|
|
616
|
-
SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
|
|
617
|
-
return SendTransactionErrorCodes2;
|
|
618
|
-
})(SendTransactionErrorCodes || {});
|
|
619
|
-
var SendTransactionErrorMessage = {
|
|
620
|
-
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
621
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
622
|
-
["input_error" /* InputError */]: "Invalid payload.",
|
|
623
|
-
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
624
|
-
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again later.",
|
|
625
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
626
|
-
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
627
|
-
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
628
|
-
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
|
|
629
|
-
["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
|
|
630
|
-
["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
|
|
631
|
-
["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
|
|
632
|
-
};
|
|
633
|
-
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
634
|
-
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
635
|
-
SignMessageErrorCodes2["UserRejected"] = "user_rejected";
|
|
636
|
-
SignMessageErrorCodes2["GenericError"] = "generic_error";
|
|
637
|
-
return SignMessageErrorCodes2;
|
|
638
|
-
})(SignMessageErrorCodes || {});
|
|
639
|
-
var SignMessageErrorMessage = {
|
|
640
|
-
["invalid_message" /* InvalidMessage */]: "Invalid message requested",
|
|
641
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
642
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
643
|
-
};
|
|
644
|
-
var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
645
|
-
SignTypedDataErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
646
|
-
SignTypedDataErrorCodes2["UserRejected"] = "user_rejected";
|
|
647
|
-
SignTypedDataErrorCodes2["InputError"] = "input_error";
|
|
648
|
-
SignTypedDataErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
649
|
-
SignTypedDataErrorCodes2["GenericError"] = "generic_error";
|
|
650
|
-
SignTypedDataErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
651
|
-
SignTypedDataErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
652
|
-
SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
653
|
-
return SignTypedDataErrorCodes2;
|
|
654
|
-
})(SignTypedDataErrorCodes || {});
|
|
655
|
-
var SignTypedDataErrorMessage = {
|
|
656
|
-
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
657
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
658
|
-
["input_error" /* InputError */]: "Invalid payload.",
|
|
659
|
-
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
660
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
661
|
-
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
662
|
-
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
663
|
-
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
664
|
-
};
|
|
665
|
-
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
666
|
-
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
667
|
-
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
668
|
-
MiniKitInstallErrorCodes2["OutsideOfWorldApp"] = "outside_of_worldapp";
|
|
669
|
-
MiniKitInstallErrorCodes2["NotOnClient"] = "not_on_client";
|
|
670
|
-
MiniKitInstallErrorCodes2["AppOutOfDate"] = "app_out_of_date";
|
|
671
|
-
return MiniKitInstallErrorCodes2;
|
|
672
|
-
})(MiniKitInstallErrorCodes || {});
|
|
673
|
-
var MiniKitInstallErrorMessage = {
|
|
674
|
-
["unknown" /* Unknown */]: "Failed to install MiniKit.",
|
|
675
|
-
["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
|
|
676
|
-
["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
|
|
677
|
-
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
678
|
-
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
679
|
-
};
|
|
680
|
-
var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
|
|
681
|
-
ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
|
|
682
|
-
ShareContactsErrorCodes2["GenericError"] = "generic_error";
|
|
683
|
-
return ShareContactsErrorCodes2;
|
|
684
|
-
})(ShareContactsErrorCodes || {});
|
|
685
|
-
var ShareContactsErrorMessage = {
|
|
686
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
687
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
688
|
-
};
|
|
689
|
-
var RequestPermissionErrorCodes = /* @__PURE__ */ ((RequestPermissionErrorCodes2) => {
|
|
690
|
-
RequestPermissionErrorCodes2["UserRejected"] = "user_rejected";
|
|
691
|
-
RequestPermissionErrorCodes2["GenericError"] = "generic_error";
|
|
692
|
-
RequestPermissionErrorCodes2["AlreadyRequested"] = "already_requested";
|
|
693
|
-
RequestPermissionErrorCodes2["PermissionDisabled"] = "permission_disabled";
|
|
694
|
-
RequestPermissionErrorCodes2["AlreadyGranted"] = "already_granted";
|
|
695
|
-
RequestPermissionErrorCodes2["UnsupportedPermission"] = "unsupported_permission";
|
|
696
|
-
return RequestPermissionErrorCodes2;
|
|
697
|
-
})(RequestPermissionErrorCodes || {});
|
|
698
|
-
var RequestPermissionErrorMessage = {
|
|
699
|
-
["user_rejected" /* UserRejected */]: "User declined sharing contacts",
|
|
700
|
-
["generic_error" /* GenericError */]: "Request failed for unknown reason.",
|
|
701
|
-
["already_requested" /* AlreadyRequested */]: "User has already declined turning on notifications once",
|
|
702
|
-
["permission_disabled" /* PermissionDisabled */]: "User does not have this permission enabled in World App",
|
|
703
|
-
["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
|
|
704
|
-
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
705
|
-
};
|
|
706
|
-
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
707
|
-
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
708
|
-
return GetPermissionsErrorCodes2;
|
|
709
|
-
})(GetPermissionsErrorCodes || {});
|
|
710
|
-
var GetPermissionsErrorMessage = {
|
|
711
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
712
|
-
};
|
|
713
|
-
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
714
|
-
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
715
|
-
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
716
|
-
return SendHapticFeedbackErrorCodes2;
|
|
717
|
-
})(SendHapticFeedbackErrorCodes || {});
|
|
718
|
-
var SendHapticFeedbackErrorMessage = {
|
|
719
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
720
|
-
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
721
|
-
};
|
|
722
|
-
var ShareFilesErrorCodes = /* @__PURE__ */ ((ShareFilesErrorCodes2) => {
|
|
723
|
-
ShareFilesErrorCodes2["UserRejected"] = "user_rejected";
|
|
724
|
-
ShareFilesErrorCodes2["GenericError"] = "generic_error";
|
|
725
|
-
ShareFilesErrorCodes2["InvalidFileName"] = "invalid_file_name";
|
|
726
|
-
return ShareFilesErrorCodes2;
|
|
727
|
-
})(ShareFilesErrorCodes || {});
|
|
728
|
-
var ShareFilesErrorMessage = {
|
|
729
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
730
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
731
|
-
["invalid_file_name" /* InvalidFileName */]: "Invalid file name. Make sure you include the extension"
|
|
732
|
-
};
|
|
733
|
-
|
|
734
|
-
// helpers/send-webview-event.ts
|
|
735
|
-
var sendWebviewEvent = (payload) => {
|
|
736
|
-
if (window.webkit) {
|
|
737
|
-
window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
|
|
738
|
-
} else if (window.Android) {
|
|
739
|
-
window.Android.postMessage?.(JSON.stringify(payload));
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
// types/responses.ts
|
|
744
|
-
var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
745
|
-
ResponseEvent2["MiniAppVerifyAction"] = "miniapp-verify-action";
|
|
746
|
-
ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
|
|
747
|
-
ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
|
|
748
|
-
ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
|
|
749
|
-
ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
|
|
750
|
-
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
751
|
-
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
752
|
-
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
753
|
-
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
754
|
-
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
755
|
-
ResponseEvent2["MiniAppShareFiles"] = "miniapp-share-files";
|
|
756
|
-
return ResponseEvent2;
|
|
757
|
-
})(ResponseEvent || {});
|
|
758
|
-
|
|
759
916
|
// minikit.ts
|
|
760
917
|
var sendMiniKitEvent = (payload) => {
|
|
761
918
|
sendWebviewEvent(payload);
|
|
@@ -764,7 +921,10 @@ var _MiniKit = class _MiniKit {
|
|
|
764
921
|
static sendInit() {
|
|
765
922
|
sendWebviewEvent({
|
|
766
923
|
command: "init",
|
|
767
|
-
payload: {
|
|
924
|
+
payload: {
|
|
925
|
+
version: this.MINIKIT_VERSION,
|
|
926
|
+
minorVersion: this.MINIKIT_MINOR_VERSION
|
|
927
|
+
}
|
|
768
928
|
});
|
|
769
929
|
}
|
|
770
930
|
static subscribe(event, handler) {
|
|
@@ -879,6 +1039,9 @@ var _MiniKit = class _MiniKit {
|
|
|
879
1039
|
_MiniKit.user.optedIntoOptionalAnalytics = window.WorldApp.is_optional_analytics;
|
|
880
1040
|
_MiniKit.user.deviceOS = window.WorldApp.device_os;
|
|
881
1041
|
_MiniKit.user.worldAppVersion = window.WorldApp.world_app_version;
|
|
1042
|
+
_MiniKit.deviceProperties.safeAreaInsets = window.WorldApp.safe_area_insets;
|
|
1043
|
+
_MiniKit.deviceProperties.deviceOS = window.WorldApp.device_os;
|
|
1044
|
+
_MiniKit.deviceProperties.worldAppVersion = window.WorldApp.world_app_version;
|
|
882
1045
|
try {
|
|
883
1046
|
window.MiniKit = _MiniKit;
|
|
884
1047
|
this.sendInit();
|
|
@@ -894,6 +1057,7 @@ var _MiniKit = class _MiniKit {
|
|
|
894
1057
|
};
|
|
895
1058
|
}
|
|
896
1059
|
_MiniKit.isReady = true;
|
|
1060
|
+
setupMicrophone();
|
|
897
1061
|
if (!this.commandsValid(window.WorldApp.supported_commands)) {
|
|
898
1062
|
return {
|
|
899
1063
|
success: false,
|
|
@@ -914,6 +1078,7 @@ var _MiniKit = class _MiniKit {
|
|
|
914
1078
|
}
|
|
915
1079
|
};
|
|
916
1080
|
_MiniKit.MINIKIT_VERSION = 1;
|
|
1081
|
+
_MiniKit.MINIKIT_MINOR_VERSION = 96;
|
|
917
1082
|
_MiniKit.miniKitCommandVersion = {
|
|
918
1083
|
["verify" /* Verify */]: 1,
|
|
919
1084
|
["pay" /* Pay */]: 1,
|
|
@@ -924,8 +1089,8 @@ _MiniKit.miniKitCommandVersion = {
|
|
|
924
1089
|
["share-contacts" /* ShareContacts */]: 1,
|
|
925
1090
|
["request-permission" /* RequestPermission */]: 1,
|
|
926
1091
|
["get-permissions" /* GetPermissions */]: 1,
|
|
927
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
928
|
-
|
|
1092
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
1093
|
+
["share" /* Share */]: 1
|
|
929
1094
|
};
|
|
930
1095
|
_MiniKit.isCommandAvailable = {
|
|
931
1096
|
["verify" /* Verify */]: false,
|
|
@@ -937,8 +1102,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
937
1102
|
["share-contacts" /* ShareContacts */]: false,
|
|
938
1103
|
["request-permission" /* RequestPermission */]: false,
|
|
939
1104
|
["get-permissions" /* GetPermissions */]: false,
|
|
940
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
941
|
-
|
|
1105
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
1106
|
+
["share" /* Share */]: false
|
|
942
1107
|
};
|
|
943
1108
|
_MiniKit.listeners = {
|
|
944
1109
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -961,12 +1126,15 @@ _MiniKit.listeners = {
|
|
|
961
1126
|
},
|
|
962
1127
|
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
963
1128
|
},
|
|
964
|
-
["miniapp-share
|
|
1129
|
+
["miniapp-share" /* MiniAppShare */]: () => {
|
|
1130
|
+
},
|
|
1131
|
+
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
965
1132
|
}
|
|
966
1133
|
};
|
|
967
1134
|
_MiniKit.appId = null;
|
|
968
1135
|
_MiniKit.user = {};
|
|
969
1136
|
_MiniKit.isReady = false;
|
|
1137
|
+
_MiniKit.deviceProperties = {};
|
|
970
1138
|
_MiniKit.getUserByAddress = async (address) => {
|
|
971
1139
|
const userProfile = await getUserProfile(
|
|
972
1140
|
address ?? _MiniKit.user.walletAddress
|
|
@@ -1132,7 +1300,7 @@ _MiniKit.commands = {
|
|
|
1132
1300
|
return payload;
|
|
1133
1301
|
},
|
|
1134
1302
|
shareContacts: (payload) => {
|
|
1135
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["
|
|
1303
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share-contacts" /* ShareContacts */]) {
|
|
1136
1304
|
console.error(
|
|
1137
1305
|
"'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1138
1306
|
);
|
|
@@ -1188,24 +1356,38 @@ _MiniKit.commands = {
|
|
|
1188
1356
|
payload
|
|
1189
1357
|
});
|
|
1190
1358
|
return payload;
|
|
1359
|
+
},
|
|
1360
|
+
// We return share input here because the payload is formatted asynchronously
|
|
1361
|
+
share: (payload) => {
|
|
1362
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share" /* Share */]) {
|
|
1363
|
+
console.error(
|
|
1364
|
+
"'share' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1365
|
+
);
|
|
1366
|
+
return null;
|
|
1367
|
+
}
|
|
1368
|
+
if (_MiniKit.deviceProperties.deviceOS === "ios" && typeof navigator !== "undefined") {
|
|
1369
|
+
sendMiniKitEvent({
|
|
1370
|
+
command: "share" /* Share */,
|
|
1371
|
+
version: _MiniKit.miniKitCommandVersion["share" /* Share */],
|
|
1372
|
+
payload
|
|
1373
|
+
});
|
|
1374
|
+
navigator.share(payload);
|
|
1375
|
+
} else {
|
|
1376
|
+
formatShareInput(payload).then((formattedResult) => {
|
|
1377
|
+
sendMiniKitEvent({
|
|
1378
|
+
command: "share" /* Share */,
|
|
1379
|
+
version: _MiniKit.miniKitCommandVersion["share" /* Share */],
|
|
1380
|
+
payload: formattedResult
|
|
1381
|
+
});
|
|
1382
|
+
}).catch((error) => {
|
|
1383
|
+
console.error("Failed to format share input", error);
|
|
1384
|
+
});
|
|
1385
|
+
_MiniKit.subscribe("miniapp-share" /* MiniAppShare */, (payload2) => {
|
|
1386
|
+
console.log("Share Response", payload2);
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
return payload;
|
|
1191
1390
|
}
|
|
1192
|
-
// shareFiles: (payload: ShareFilesInput): ShareFilesPayload | null => {
|
|
1193
|
-
// if (
|
|
1194
|
-
// typeof window === 'undefined' ||
|
|
1195
|
-
// !this.isCommandAvailable[Command.ShareFiles]
|
|
1196
|
-
// ) {
|
|
1197
|
-
// console.error(
|
|
1198
|
-
// "'shareFiles' command is unavailable. Check MiniKit.install() or update the app version",
|
|
1199
|
-
// );
|
|
1200
|
-
// return null;
|
|
1201
|
-
// }
|
|
1202
|
-
// sendMiniKitEvent<WebViewBasePayload>({
|
|
1203
|
-
// command: Command.ShareFiles,
|
|
1204
|
-
// version: this.miniKitCommandVersion[Command.ShareFiles],
|
|
1205
|
-
// payload,
|
|
1206
|
-
// });
|
|
1207
|
-
// return payload;
|
|
1208
|
-
// },
|
|
1209
1391
|
};
|
|
1210
1392
|
/**
|
|
1211
1393
|
* This object contains async versions of all the commands.
|
|
@@ -1362,26 +1544,24 @@ _MiniKit.commandsAsync = {
|
|
|
1362
1544
|
reject(error);
|
|
1363
1545
|
}
|
|
1364
1546
|
});
|
|
1547
|
+
},
|
|
1548
|
+
share: async (payload) => {
|
|
1549
|
+
return new Promise(async (resolve, reject) => {
|
|
1550
|
+
try {
|
|
1551
|
+
const response = await _MiniKit.awaitCommand(
|
|
1552
|
+
"miniapp-share" /* MiniAppShare */,
|
|
1553
|
+
"share" /* Share */,
|
|
1554
|
+
() => _MiniKit.commands.share(payload)
|
|
1555
|
+
);
|
|
1556
|
+
resolve({
|
|
1557
|
+
commandPayload: response.commandPayload,
|
|
1558
|
+
finalPayload: response.finalPayload
|
|
1559
|
+
});
|
|
1560
|
+
} catch (error) {
|
|
1561
|
+
reject(error);
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1365
1564
|
}
|
|
1366
|
-
// shareFiles: async (
|
|
1367
|
-
// payload: ShareFilesInput,
|
|
1368
|
-
// ): AsyncHandlerReturn<
|
|
1369
|
-
// ShareFilesPayload | null,
|
|
1370
|
-
// MiniAppShareFilesPayload
|
|
1371
|
-
// > => {
|
|
1372
|
-
// return new Promise(async (resolve, reject) => {
|
|
1373
|
-
// try {
|
|
1374
|
-
// const response = await MiniKit.awaitCommand(
|
|
1375
|
-
// ResponseEvent.MiniAppShareFiles,
|
|
1376
|
-
// Command.ShareFiles,
|
|
1377
|
-
// () => this.commands.shareFiles(payload),
|
|
1378
|
-
// );
|
|
1379
|
-
// resolve(response);
|
|
1380
|
-
// } catch (error) {
|
|
1381
|
-
// reject(error);
|
|
1382
|
-
// }
|
|
1383
|
-
// });
|
|
1384
|
-
// },
|
|
1385
1565
|
};
|
|
1386
1566
|
var MiniKit = _MiniKit;
|
|
1387
1567
|
|
|
@@ -1445,6 +1625,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
1445
1625
|
Command,
|
|
1446
1626
|
GetPermissionsErrorCodes,
|
|
1447
1627
|
GetPermissionsErrorMessage,
|
|
1628
|
+
MicrophoneErrorCodes,
|
|
1629
|
+
MicrophoneErrorMessage,
|
|
1448
1630
|
MiniKit,
|
|
1449
1631
|
MiniKitInstallErrorCodes,
|
|
1450
1632
|
MiniKitInstallErrorMessage,
|