@worldcoin/minikit-js 1.9.8 → 1.9.10
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/README.md +7 -0
- package/build/{chunk-Q55KYUW6.js → chunk-XFGJKKI2.js} +1476 -1086
- package/build/index.cjs +1713 -1292
- package/build/index.d.cts +495 -486
- package/build/index.d.ts +495 -486
- package/build/index.js +71 -9
- package/build/minikit-provider.cjs +1174 -816
- package/build/minikit-provider.js +1 -1
- package/index.ts +12 -3
- package/package.json +5 -1
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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."
|
|
1
|
+
// helpers/send-webview-event.ts
|
|
2
|
+
var sendWebviewEvent = (payload) => {
|
|
3
|
+
if (window.webkit) {
|
|
4
|
+
window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
|
|
5
|
+
} else if (window.Android) {
|
|
6
|
+
window.Android.postMessage?.(JSON.stringify(payload));
|
|
7
|
+
}
|
|
97
8
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
["
|
|
111
|
-
["
|
|
112
|
-
["
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
["
|
|
117
|
-
["
|
|
9
|
+
|
|
10
|
+
// commands/types.ts
|
|
11
|
+
var Command = /* @__PURE__ */ ((Command2) => {
|
|
12
|
+
Command2["Verify"] = "verify";
|
|
13
|
+
Command2["Pay"] = "pay";
|
|
14
|
+
Command2["WalletAuth"] = "wallet-auth";
|
|
15
|
+
Command2["SendTransaction"] = "send-transaction";
|
|
16
|
+
Command2["SignMessage"] = "sign-message";
|
|
17
|
+
Command2["SignTypedData"] = "sign-typed-data";
|
|
18
|
+
Command2["ShareContacts"] = "share-contacts";
|
|
19
|
+
Command2["RequestPermission"] = "request-permission";
|
|
20
|
+
Command2["GetPermissions"] = "get-permissions";
|
|
21
|
+
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
22
|
+
Command2["Share"] = "share";
|
|
23
|
+
Command2["Chat"] = "chat";
|
|
24
|
+
return Command2;
|
|
25
|
+
})(Command || {});
|
|
26
|
+
var ResponseEvent = /* @__PURE__ */ ((ResponseEvent3) => {
|
|
27
|
+
ResponseEvent3["MiniAppVerifyAction"] = "miniapp-verify-action";
|
|
28
|
+
ResponseEvent3["MiniAppPayment"] = "miniapp-payment";
|
|
29
|
+
ResponseEvent3["MiniAppWalletAuth"] = "miniapp-wallet-auth";
|
|
30
|
+
ResponseEvent3["MiniAppSendTransaction"] = "miniapp-send-transaction";
|
|
31
|
+
ResponseEvent3["MiniAppSignMessage"] = "miniapp-sign-message";
|
|
32
|
+
ResponseEvent3["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
33
|
+
ResponseEvent3["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
34
|
+
ResponseEvent3["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
35
|
+
ResponseEvent3["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
36
|
+
ResponseEvent3["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
37
|
+
ResponseEvent3["MiniAppShare"] = "miniapp-share";
|
|
38
|
+
ResponseEvent3["MiniAppMicrophone"] = "miniapp-microphone";
|
|
39
|
+
ResponseEvent3["MiniAppChat"] = "miniapp-chat";
|
|
40
|
+
return ResponseEvent3;
|
|
41
|
+
})(ResponseEvent || {});
|
|
42
|
+
var COMMAND_VERSIONS = {
|
|
43
|
+
["verify" /* Verify */]: 1,
|
|
44
|
+
["pay" /* Pay */]: 1,
|
|
45
|
+
["wallet-auth" /* WalletAuth */]: 2,
|
|
46
|
+
["send-transaction" /* SendTransaction */]: 1,
|
|
47
|
+
["sign-message" /* SignMessage */]: 1,
|
|
48
|
+
["sign-typed-data" /* SignTypedData */]: 1,
|
|
49
|
+
["share-contacts" /* ShareContacts */]: 1,
|
|
50
|
+
["request-permission" /* RequestPermission */]: 1,
|
|
51
|
+
["get-permissions" /* GetPermissions */]: 1,
|
|
52
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
53
|
+
["share" /* Share */]: 1,
|
|
54
|
+
["chat" /* Chat */]: 1
|
|
118
55
|
};
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
["
|
|
129
|
-
["
|
|
130
|
-
["
|
|
131
|
-
["
|
|
132
|
-
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
56
|
+
var commandAvailability = {
|
|
57
|
+
["verify" /* Verify */]: false,
|
|
58
|
+
["pay" /* Pay */]: false,
|
|
59
|
+
["wallet-auth" /* WalletAuth */]: false,
|
|
60
|
+
["send-transaction" /* SendTransaction */]: false,
|
|
61
|
+
["sign-message" /* SignMessage */]: false,
|
|
62
|
+
["sign-typed-data" /* SignTypedData */]: false,
|
|
63
|
+
["share-contacts" /* ShareContacts */]: false,
|
|
64
|
+
["request-permission" /* RequestPermission */]: false,
|
|
65
|
+
["get-permissions" /* GetPermissions */]: false,
|
|
66
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
67
|
+
["share" /* Share */]: false,
|
|
68
|
+
["chat" /* Chat */]: false
|
|
133
69
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
70
|
+
function isCommandAvailable(command) {
|
|
71
|
+
return commandAvailability[command];
|
|
72
|
+
}
|
|
73
|
+
function setCommandAvailable(command, available) {
|
|
74
|
+
commandAvailability[command] = available;
|
|
75
|
+
}
|
|
76
|
+
function validateCommands(worldAppSupportedCommands) {
|
|
77
|
+
let allCommandsValid = true;
|
|
78
|
+
Object.entries(COMMAND_VERSIONS).forEach(([commandName, version]) => {
|
|
79
|
+
const commandInput = worldAppSupportedCommands.find(
|
|
80
|
+
(cmd) => cmd.name === commandName
|
|
81
|
+
);
|
|
82
|
+
let isCommandValid = false;
|
|
83
|
+
if (!commandInput) {
|
|
84
|
+
console.warn(
|
|
85
|
+
`Command ${commandName} is not supported by the app. Try updating the app version`
|
|
86
|
+
);
|
|
87
|
+
} else {
|
|
88
|
+
if (commandInput.supported_versions.includes(version)) {
|
|
89
|
+
setCommandAvailable(commandName, true);
|
|
90
|
+
isCommandValid = true;
|
|
91
|
+
} else {
|
|
92
|
+
isCommandValid = true;
|
|
93
|
+
console.warn(
|
|
94
|
+
`Command ${commandName} version ${version} is not supported by the app. Supported versions: ${commandInput.supported_versions.join(", ")}. This is not an error, but it is recommended to update the World App version.`
|
|
95
|
+
);
|
|
96
|
+
setCommandAvailable(commandName, true);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!isCommandValid) {
|
|
100
|
+
allCommandsValid = false;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return allCommandsValid;
|
|
104
|
+
}
|
|
105
|
+
function sendMiniKitEvent(payload) {
|
|
106
|
+
sendWebviewEvent(payload);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// commands/chat.ts
|
|
110
|
+
var ChatErrorCodes = /* @__PURE__ */ ((ChatErrorCodes2) => {
|
|
111
|
+
ChatErrorCodes2["UserRejected"] = "user_rejected";
|
|
112
|
+
ChatErrorCodes2["SendFailed"] = "send_failed";
|
|
113
|
+
ChatErrorCodes2["GenericError"] = "generic_error";
|
|
114
|
+
return ChatErrorCodes2;
|
|
115
|
+
})(ChatErrorCodes || {});
|
|
116
|
+
var ChatErrorMessage = {
|
|
140
117
|
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
118
|
+
["send_failed" /* SendFailed */]: "Failed to send the message.",
|
|
141
119
|
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
142
120
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
};
|
|
121
|
+
function createChatCommand(_ctx) {
|
|
122
|
+
return (payload) => {
|
|
123
|
+
if (typeof window === "undefined" || !isCommandAvailable("chat" /* Chat */)) {
|
|
124
|
+
console.error(
|
|
125
|
+
"'chat' command is unavailable. Check MiniKit.install() or update the app version"
|
|
126
|
+
);
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
if (payload.message.length === 0) {
|
|
130
|
+
console.error("'chat' command requires a non-empty message");
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
sendMiniKitEvent({
|
|
134
|
+
command: "chat" /* Chat */,
|
|
135
|
+
version: COMMAND_VERSIONS["chat" /* Chat */],
|
|
136
|
+
payload
|
|
137
|
+
});
|
|
138
|
+
return payload;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function createChatAsyncCommand(ctx, syncCommand) {
|
|
142
|
+
return async (payload) => {
|
|
143
|
+
return new Promise((resolve, reject) => {
|
|
144
|
+
try {
|
|
145
|
+
let commandPayload = null;
|
|
146
|
+
const handleResponse = (response) => {
|
|
147
|
+
ctx.events.unsubscribe("miniapp-chat" /* MiniAppChat */);
|
|
148
|
+
resolve({ commandPayload, finalPayload: response });
|
|
149
|
+
};
|
|
150
|
+
ctx.events.subscribe("miniapp-chat" /* MiniAppChat */, handleResponse);
|
|
151
|
+
commandPayload = syncCommand(payload);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
reject(error);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// commands/get-permissions.ts
|
|
160
160
|
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
161
161
|
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
162
162
|
return GetPermissionsErrorCodes2;
|
|
@@ -164,58 +164,56 @@ var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
|
164
164
|
var GetPermissionsErrorMessage = {
|
|
165
165
|
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
166
166
|
};
|
|
167
|
-
var
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return ResponseEvent2;
|
|
212
|
-
})(ResponseEvent || {});
|
|
167
|
+
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
168
|
+
Permission2["Notifications"] = "notifications";
|
|
169
|
+
Permission2["Contacts"] = "contacts";
|
|
170
|
+
Permission2["Microphone"] = "microphone";
|
|
171
|
+
return Permission2;
|
|
172
|
+
})(Permission || {});
|
|
173
|
+
function createGetPermissionsCommand(_ctx) {
|
|
174
|
+
return () => {
|
|
175
|
+
if (typeof window === "undefined" || !isCommandAvailable("get-permissions" /* GetPermissions */)) {
|
|
176
|
+
console.error(
|
|
177
|
+
"'getPermissions' command is unavailable. Check MiniKit.install() or update the app version"
|
|
178
|
+
);
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
sendMiniKitEvent({
|
|
182
|
+
command: "get-permissions" /* GetPermissions */,
|
|
183
|
+
version: COMMAND_VERSIONS["get-permissions" /* GetPermissions */],
|
|
184
|
+
payload: {}
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
status: "sent"
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function createGetPermissionsAsyncCommand(ctx, syncCommand) {
|
|
192
|
+
return async () => {
|
|
193
|
+
return new Promise((resolve, reject) => {
|
|
194
|
+
try {
|
|
195
|
+
let commandPayload = null;
|
|
196
|
+
const handleResponse = (payload) => {
|
|
197
|
+
ctx.events.unsubscribe("miniapp-get-permissions" /* MiniAppGetPermissions */);
|
|
198
|
+
resolve({ commandPayload, finalPayload: payload });
|
|
199
|
+
};
|
|
200
|
+
ctx.events.subscribe(
|
|
201
|
+
"miniapp-get-permissions" /* MiniAppGetPermissions */,
|
|
202
|
+
handleResponse
|
|
203
|
+
);
|
|
204
|
+
commandPayload = syncCommand();
|
|
205
|
+
} catch (error) {
|
|
206
|
+
reject(error);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
}
|
|
213
211
|
|
|
214
212
|
// types/payment.ts
|
|
215
|
-
var Tokens = /* @__PURE__ */ ((
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return
|
|
213
|
+
var Tokens = /* @__PURE__ */ ((Tokens3) => {
|
|
214
|
+
Tokens3["USDC"] = "USDCE";
|
|
215
|
+
Tokens3["WLD"] = "WLD";
|
|
216
|
+
return Tokens3;
|
|
219
217
|
})(Tokens || {});
|
|
220
218
|
var TokenDecimals = {
|
|
221
219
|
["USDCE" /* USDC */]: 6,
|
|
@@ -257,6 +255,647 @@ var validatePaymentPayload = (payload) => {
|
|
|
257
255
|
return true;
|
|
258
256
|
};
|
|
259
257
|
|
|
258
|
+
// commands/pay.ts
|
|
259
|
+
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
260
|
+
PaymentErrorCodes2["InputError"] = "input_error";
|
|
261
|
+
PaymentErrorCodes2["UserRejected"] = "user_rejected";
|
|
262
|
+
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
263
|
+
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
264
|
+
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
265
|
+
PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
266
|
+
PaymentErrorCodes2["GenericError"] = "generic_error";
|
|
267
|
+
PaymentErrorCodes2["UserBlocked"] = "user_blocked";
|
|
268
|
+
return PaymentErrorCodes2;
|
|
269
|
+
})(PaymentErrorCodes || {});
|
|
270
|
+
var PaymentErrorMessage = {
|
|
271
|
+
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
272
|
+
["user_rejected" /* UserRejected */]: "You have cancelled the payment in World App.",
|
|
273
|
+
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
274
|
+
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
275
|
+
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
276
|
+
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
277
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
278
|
+
["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
|
|
279
|
+
};
|
|
280
|
+
function createPayCommand(_ctx) {
|
|
281
|
+
return (payload) => {
|
|
282
|
+
if (typeof window === "undefined" || !isCommandAvailable("pay" /* Pay */)) {
|
|
283
|
+
console.error(
|
|
284
|
+
"'pay' command is unavailable. Check MiniKit.install() or update the app version"
|
|
285
|
+
);
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
if (!validatePaymentPayload(payload)) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
const eventPayload = {
|
|
292
|
+
...payload,
|
|
293
|
+
network: "worldchain" /* WorldChain */
|
|
294
|
+
};
|
|
295
|
+
sendMiniKitEvent({
|
|
296
|
+
command: "pay" /* Pay */,
|
|
297
|
+
version: COMMAND_VERSIONS["pay" /* Pay */],
|
|
298
|
+
payload: eventPayload
|
|
299
|
+
});
|
|
300
|
+
return eventPayload;
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function createPayAsyncCommand(ctx, syncCommand) {
|
|
304
|
+
return async (payload) => {
|
|
305
|
+
return new Promise((resolve, reject) => {
|
|
306
|
+
try {
|
|
307
|
+
let commandPayload = null;
|
|
308
|
+
const handleResponse = (response) => {
|
|
309
|
+
ctx.events.unsubscribe("miniapp-payment" /* MiniAppPayment */);
|
|
310
|
+
resolve({ commandPayload, finalPayload: response });
|
|
311
|
+
};
|
|
312
|
+
ctx.events.subscribe(
|
|
313
|
+
"miniapp-payment" /* MiniAppPayment */,
|
|
314
|
+
handleResponse
|
|
315
|
+
);
|
|
316
|
+
commandPayload = syncCommand(payload);
|
|
317
|
+
} catch (error) {
|
|
318
|
+
reject(error);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// commands/request-permission.ts
|
|
325
|
+
var RequestPermissionErrorCodes = /* @__PURE__ */ ((RequestPermissionErrorCodes2) => {
|
|
326
|
+
RequestPermissionErrorCodes2["UserRejected"] = "user_rejected";
|
|
327
|
+
RequestPermissionErrorCodes2["GenericError"] = "generic_error";
|
|
328
|
+
RequestPermissionErrorCodes2["AlreadyRequested"] = "already_requested";
|
|
329
|
+
RequestPermissionErrorCodes2["PermissionDisabled"] = "permission_disabled";
|
|
330
|
+
RequestPermissionErrorCodes2["AlreadyGranted"] = "already_granted";
|
|
331
|
+
RequestPermissionErrorCodes2["UnsupportedPermission"] = "unsupported_permission";
|
|
332
|
+
return RequestPermissionErrorCodes2;
|
|
333
|
+
})(RequestPermissionErrorCodes || {});
|
|
334
|
+
var RequestPermissionErrorMessage = {
|
|
335
|
+
["user_rejected" /* UserRejected */]: "User declined sharing contacts",
|
|
336
|
+
["generic_error" /* GenericError */]: "Request failed for unknown reason.",
|
|
337
|
+
["already_requested" /* AlreadyRequested */]: "User has already declined turning on notifications once",
|
|
338
|
+
["permission_disabled" /* PermissionDisabled */]: "User does not have this permission enabled in World App",
|
|
339
|
+
["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
|
|
340
|
+
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
341
|
+
};
|
|
342
|
+
function createRequestPermissionCommand(_ctx) {
|
|
343
|
+
return (payload) => {
|
|
344
|
+
if (typeof window === "undefined" || !isCommandAvailable("request-permission" /* RequestPermission */)) {
|
|
345
|
+
console.error(
|
|
346
|
+
"'requestPermission' command is unavailable. Check MiniKit.install() or update the app version"
|
|
347
|
+
);
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
sendMiniKitEvent({
|
|
351
|
+
command: "request-permission" /* RequestPermission */,
|
|
352
|
+
version: COMMAND_VERSIONS["request-permission" /* RequestPermission */],
|
|
353
|
+
payload
|
|
354
|
+
});
|
|
355
|
+
return payload;
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function createRequestPermissionAsyncCommand(ctx, syncCommand) {
|
|
359
|
+
return async (payload) => {
|
|
360
|
+
return new Promise((resolve, reject) => {
|
|
361
|
+
try {
|
|
362
|
+
let commandPayload = null;
|
|
363
|
+
const handleResponse = (response) => {
|
|
364
|
+
ctx.events.unsubscribe("miniapp-request-permission" /* MiniAppRequestPermission */);
|
|
365
|
+
resolve({ commandPayload, finalPayload: response });
|
|
366
|
+
};
|
|
367
|
+
ctx.events.subscribe(
|
|
368
|
+
"miniapp-request-permission" /* MiniAppRequestPermission */,
|
|
369
|
+
handleResponse
|
|
370
|
+
);
|
|
371
|
+
commandPayload = syncCommand(payload);
|
|
372
|
+
} catch (error) {
|
|
373
|
+
reject(error);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// commands/send-haptic-feedback.ts
|
|
380
|
+
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
381
|
+
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
382
|
+
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
383
|
+
return SendHapticFeedbackErrorCodes2;
|
|
384
|
+
})(SendHapticFeedbackErrorCodes || {});
|
|
385
|
+
var SendHapticFeedbackErrorMessage = {
|
|
386
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
387
|
+
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
388
|
+
};
|
|
389
|
+
function createSendHapticFeedbackCommand(_ctx) {
|
|
390
|
+
return (payload) => {
|
|
391
|
+
if (typeof window === "undefined" || !isCommandAvailable("send-haptic-feedback" /* SendHapticFeedback */)) {
|
|
392
|
+
console.error(
|
|
393
|
+
"'sendHapticFeedback' command is unavailable. Check MiniKit.install() or update the app version"
|
|
394
|
+
);
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
sendMiniKitEvent({
|
|
398
|
+
command: "send-haptic-feedback" /* SendHapticFeedback */,
|
|
399
|
+
version: COMMAND_VERSIONS["send-haptic-feedback" /* SendHapticFeedback */],
|
|
400
|
+
payload
|
|
401
|
+
});
|
|
402
|
+
return payload;
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function createSendHapticFeedbackAsyncCommand(ctx, syncCommand) {
|
|
406
|
+
return async (payload) => {
|
|
407
|
+
return new Promise((resolve, reject) => {
|
|
408
|
+
try {
|
|
409
|
+
let commandPayload = null;
|
|
410
|
+
const handleResponse = (response) => {
|
|
411
|
+
ctx.events.unsubscribe("miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */);
|
|
412
|
+
resolve({ commandPayload, finalPayload: response });
|
|
413
|
+
};
|
|
414
|
+
ctx.events.subscribe(
|
|
415
|
+
"miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
|
|
416
|
+
handleResponse
|
|
417
|
+
);
|
|
418
|
+
commandPayload = syncCommand(payload);
|
|
419
|
+
} catch (error) {
|
|
420
|
+
reject(error);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// helpers/transaction/validate-payload.ts
|
|
427
|
+
var isValidHex = (str) => {
|
|
428
|
+
return /^0x[0-9A-Fa-f]+$/.test(str);
|
|
429
|
+
};
|
|
430
|
+
var objectValuesToArrayRecursive = (input) => {
|
|
431
|
+
if (input === null || typeof input !== "object") {
|
|
432
|
+
return input;
|
|
433
|
+
}
|
|
434
|
+
if (Array.isArray(input)) {
|
|
435
|
+
return input.map((item) => objectValuesToArrayRecursive(item));
|
|
436
|
+
}
|
|
437
|
+
const values = Object.values(input);
|
|
438
|
+
return values.map((value) => objectValuesToArrayRecursive(value));
|
|
439
|
+
};
|
|
440
|
+
var processPayload = (payload) => {
|
|
441
|
+
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
442
|
+
return payload;
|
|
443
|
+
}
|
|
444
|
+
if (typeof payload === "number" || typeof payload === "bigint") {
|
|
445
|
+
return String(payload);
|
|
446
|
+
}
|
|
447
|
+
if (Array.isArray(payload)) {
|
|
448
|
+
return payload.map((value) => processPayload(value));
|
|
449
|
+
}
|
|
450
|
+
if (typeof payload === "object") {
|
|
451
|
+
const result = { ...payload };
|
|
452
|
+
if ("value" in result && result.value !== void 0) {
|
|
453
|
+
if (typeof result.value !== "string") {
|
|
454
|
+
result.value = String(result.value);
|
|
455
|
+
}
|
|
456
|
+
if (!isValidHex(result.value)) {
|
|
457
|
+
console.error(
|
|
458
|
+
"Transaction value must be a valid hex string",
|
|
459
|
+
result.value
|
|
460
|
+
);
|
|
461
|
+
throw new Error(
|
|
462
|
+
`Transaction value must be a valid hex string: ${result.value}`
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
for (const key in result) {
|
|
467
|
+
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
468
|
+
result[key] = processPayload(result[key]);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return result;
|
|
472
|
+
}
|
|
473
|
+
return payload;
|
|
474
|
+
};
|
|
475
|
+
var validateSendTransactionPayload = (payload) => {
|
|
476
|
+
if (payload.formatPayload) {
|
|
477
|
+
const formattedPayload = processPayload(payload);
|
|
478
|
+
formattedPayload.transaction = formattedPayload.transaction.map((tx) => {
|
|
479
|
+
const args = objectValuesToArrayRecursive(tx.args);
|
|
480
|
+
return {
|
|
481
|
+
...tx,
|
|
482
|
+
args
|
|
483
|
+
};
|
|
484
|
+
});
|
|
485
|
+
return formattedPayload;
|
|
486
|
+
}
|
|
487
|
+
return payload;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// commands/send-transaction.ts
|
|
491
|
+
var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
|
|
492
|
+
SendTransactionErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
493
|
+
SendTransactionErrorCodes2["UserRejected"] = "user_rejected";
|
|
494
|
+
SendTransactionErrorCodes2["InputError"] = "input_error";
|
|
495
|
+
SendTransactionErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
496
|
+
SendTransactionErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
497
|
+
SendTransactionErrorCodes2["GenericError"] = "generic_error";
|
|
498
|
+
SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
499
|
+
SendTransactionErrorCodes2["ValidationError"] = "validation_error";
|
|
500
|
+
SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
501
|
+
SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
502
|
+
SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
|
|
503
|
+
SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
|
|
504
|
+
SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
|
|
505
|
+
return SendTransactionErrorCodes2;
|
|
506
|
+
})(SendTransactionErrorCodes || {});
|
|
507
|
+
var SendTransactionErrorMessage = {
|
|
508
|
+
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
509
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
510
|
+
["input_error" /* InputError */]: "Invalid payload.",
|
|
511
|
+
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
512
|
+
["validation_error" /* ValidationError */]: "The transaction validation failed. Please try again.",
|
|
513
|
+
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again later.",
|
|
514
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
515
|
+
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
516
|
+
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
517
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
|
|
518
|
+
["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
|
|
519
|
+
["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
|
|
520
|
+
["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
|
|
521
|
+
};
|
|
522
|
+
function createSendTransactionCommand(_ctx) {
|
|
523
|
+
return (payload) => {
|
|
524
|
+
if (typeof window === "undefined" || !isCommandAvailable("send-transaction" /* SendTransaction */)) {
|
|
525
|
+
console.error(
|
|
526
|
+
"'sendTransaction' command is unavailable. Check MiniKit.install() or update the app version"
|
|
527
|
+
);
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
payload.formatPayload = payload.formatPayload !== false;
|
|
531
|
+
const validatedPayload = validateSendTransactionPayload(payload);
|
|
532
|
+
sendMiniKitEvent({
|
|
533
|
+
command: "send-transaction" /* SendTransaction */,
|
|
534
|
+
version: COMMAND_VERSIONS["send-transaction" /* SendTransaction */],
|
|
535
|
+
payload: validatedPayload
|
|
536
|
+
});
|
|
537
|
+
return validatedPayload;
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function createSendTransactionAsyncCommand(ctx, syncCommand) {
|
|
541
|
+
return async (payload) => {
|
|
542
|
+
return new Promise((resolve, reject) => {
|
|
543
|
+
try {
|
|
544
|
+
let commandPayload = null;
|
|
545
|
+
const handleResponse = (response) => {
|
|
546
|
+
ctx.events.unsubscribe("miniapp-send-transaction" /* MiniAppSendTransaction */);
|
|
547
|
+
resolve({ commandPayload, finalPayload: response });
|
|
548
|
+
};
|
|
549
|
+
ctx.events.subscribe(
|
|
550
|
+
"miniapp-send-transaction" /* MiniAppSendTransaction */,
|
|
551
|
+
handleResponse
|
|
552
|
+
);
|
|
553
|
+
commandPayload = syncCommand(payload);
|
|
554
|
+
} catch (error) {
|
|
555
|
+
reject(error);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// helpers/share/index.ts
|
|
562
|
+
var MAX_FILES = 10;
|
|
563
|
+
var MAX_TOTAL_SIZE_MB = 50;
|
|
564
|
+
var MAX_TOTAL_SIZE_BYTES = MAX_TOTAL_SIZE_MB * 1024 * 1024;
|
|
565
|
+
var processFile = async (file) => {
|
|
566
|
+
const buffer = await file.arrayBuffer();
|
|
567
|
+
const uint8Array = new Uint8Array(buffer);
|
|
568
|
+
let binaryString = "";
|
|
569
|
+
const K_CHUNK_SIZE = 32768;
|
|
570
|
+
for (let i = 0; i < uint8Array.length; i += K_CHUNK_SIZE) {
|
|
571
|
+
const chunk = uint8Array.subarray(
|
|
572
|
+
i,
|
|
573
|
+
Math.min(i + K_CHUNK_SIZE, uint8Array.length)
|
|
574
|
+
);
|
|
575
|
+
binaryString += String.fromCharCode.apply(
|
|
576
|
+
null,
|
|
577
|
+
Array.from(chunk)
|
|
578
|
+
// Convert Uint8Array chunk to number[]
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
const base64Data = btoa(binaryString);
|
|
582
|
+
return {
|
|
583
|
+
name: file.name,
|
|
584
|
+
type: file.type,
|
|
585
|
+
data: base64Data
|
|
586
|
+
};
|
|
587
|
+
};
|
|
588
|
+
var formatShareInput = async (input) => {
|
|
589
|
+
if (!input.files) {
|
|
590
|
+
return {
|
|
591
|
+
title: input.title,
|
|
592
|
+
text: input.text,
|
|
593
|
+
url: input.url
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
if (!Array.isArray(input.files)) {
|
|
597
|
+
throw new Error('The "files" property must be an array.');
|
|
598
|
+
}
|
|
599
|
+
if (input.files.length === 0) {
|
|
600
|
+
} else {
|
|
601
|
+
if (input.files.length > MAX_FILES) {
|
|
602
|
+
throw new Error(`Cannot share more than ${MAX_FILES} files.`);
|
|
603
|
+
}
|
|
604
|
+
let totalSize = 0;
|
|
605
|
+
for (const file of input.files) {
|
|
606
|
+
if (!(file instanceof File)) {
|
|
607
|
+
throw new Error(
|
|
608
|
+
`Each item in the 'files' array must be a File object. Received: ${typeof file}`
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
totalSize += file.size;
|
|
612
|
+
}
|
|
613
|
+
if (totalSize > MAX_TOTAL_SIZE_BYTES) {
|
|
614
|
+
throw new Error(`Total file size cannot exceed ${MAX_TOTAL_SIZE_MB}MB.`);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
const fileProcessingPromises = input.files.map((file) => processFile(file));
|
|
618
|
+
const processedFiles = await Promise.all(fileProcessingPromises);
|
|
619
|
+
return {
|
|
620
|
+
files: processedFiles,
|
|
621
|
+
title: input.title,
|
|
622
|
+
text: input.text,
|
|
623
|
+
url: input.url
|
|
624
|
+
};
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
// commands/share.ts
|
|
628
|
+
var ShareFilesErrorCodes = /* @__PURE__ */ ((ShareFilesErrorCodes2) => {
|
|
629
|
+
ShareFilesErrorCodes2["UserRejected"] = "user_rejected";
|
|
630
|
+
ShareFilesErrorCodes2["GenericError"] = "generic_error";
|
|
631
|
+
ShareFilesErrorCodes2["InvalidFileName"] = "invalid_file_name";
|
|
632
|
+
return ShareFilesErrorCodes2;
|
|
633
|
+
})(ShareFilesErrorCodes || {});
|
|
634
|
+
var ShareFilesErrorMessage = {
|
|
635
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
636
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
637
|
+
["invalid_file_name" /* InvalidFileName */]: "Invalid file name. Make sure you include the extension"
|
|
638
|
+
};
|
|
639
|
+
function createShareCommand(ctx) {
|
|
640
|
+
return (payload) => {
|
|
641
|
+
if (typeof window === "undefined" || !isCommandAvailable("share" /* Share */)) {
|
|
642
|
+
console.error(
|
|
643
|
+
"'share' command is unavailable. Check MiniKit.install() or update the app version"
|
|
644
|
+
);
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
if (ctx.state.deviceProperties.deviceOS === "ios" && typeof navigator !== "undefined") {
|
|
648
|
+
sendMiniKitEvent({
|
|
649
|
+
command: "share" /* Share */,
|
|
650
|
+
version: COMMAND_VERSIONS["share" /* Share */],
|
|
651
|
+
payload
|
|
652
|
+
});
|
|
653
|
+
navigator.share(payload);
|
|
654
|
+
} else {
|
|
655
|
+
formatShareInput(payload).then((formattedResult) => {
|
|
656
|
+
sendMiniKitEvent({
|
|
657
|
+
command: "share" /* Share */,
|
|
658
|
+
version: COMMAND_VERSIONS["share" /* Share */],
|
|
659
|
+
payload: formattedResult
|
|
660
|
+
});
|
|
661
|
+
}).catch((error) => {
|
|
662
|
+
console.error("Failed to format share input", error);
|
|
663
|
+
});
|
|
664
|
+
ctx.events.subscribe("miniapp-share" /* MiniAppShare */, (response) => {
|
|
665
|
+
console.log("Share Response", response);
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
return payload;
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
function createShareAsyncCommand(ctx, syncCommand) {
|
|
672
|
+
return async (payload) => {
|
|
673
|
+
return new Promise((resolve, reject) => {
|
|
674
|
+
try {
|
|
675
|
+
let commandPayload = null;
|
|
676
|
+
const handleResponse = (response) => {
|
|
677
|
+
ctx.events.unsubscribe("miniapp-share" /* MiniAppShare */);
|
|
678
|
+
resolve({ commandPayload, finalPayload: response });
|
|
679
|
+
};
|
|
680
|
+
ctx.events.subscribe("miniapp-share" /* MiniAppShare */, handleResponse);
|
|
681
|
+
commandPayload = syncCommand(payload);
|
|
682
|
+
} catch (error) {
|
|
683
|
+
reject(error);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// commands/share-contacts.ts
|
|
690
|
+
var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
|
|
691
|
+
ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
|
|
692
|
+
ShareContactsErrorCodes2["GenericError"] = "generic_error";
|
|
693
|
+
return ShareContactsErrorCodes2;
|
|
694
|
+
})(ShareContactsErrorCodes || {});
|
|
695
|
+
var ShareContactsErrorMessage = {
|
|
696
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
697
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
698
|
+
};
|
|
699
|
+
function createShareContactsCommand(_ctx) {
|
|
700
|
+
return (payload) => {
|
|
701
|
+
if (typeof window === "undefined" || !isCommandAvailable("share-contacts" /* ShareContacts */)) {
|
|
702
|
+
console.error(
|
|
703
|
+
"'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
|
|
704
|
+
);
|
|
705
|
+
return null;
|
|
706
|
+
}
|
|
707
|
+
sendMiniKitEvent({
|
|
708
|
+
command: "share-contacts" /* ShareContacts */,
|
|
709
|
+
version: COMMAND_VERSIONS["share-contacts" /* ShareContacts */],
|
|
710
|
+
payload
|
|
711
|
+
});
|
|
712
|
+
return payload;
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
function createShareContactsAsyncCommand(ctx, syncCommand) {
|
|
716
|
+
return async (payload) => {
|
|
717
|
+
return new Promise((resolve, reject) => {
|
|
718
|
+
try {
|
|
719
|
+
let commandPayload = null;
|
|
720
|
+
const handleResponse = (response) => {
|
|
721
|
+
ctx.events.unsubscribe("miniapp-share-contacts" /* MiniAppShareContacts */);
|
|
722
|
+
resolve({ commandPayload, finalPayload: response });
|
|
723
|
+
};
|
|
724
|
+
ctx.events.subscribe(
|
|
725
|
+
"miniapp-share-contacts" /* MiniAppShareContacts */,
|
|
726
|
+
handleResponse
|
|
727
|
+
);
|
|
728
|
+
commandPayload = syncCommand(payload);
|
|
729
|
+
} catch (error) {
|
|
730
|
+
reject(error);
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
// commands/sign-message.ts
|
|
737
|
+
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
738
|
+
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
739
|
+
SignMessageErrorCodes2["UserRejected"] = "user_rejected";
|
|
740
|
+
SignMessageErrorCodes2["GenericError"] = "generic_error";
|
|
741
|
+
return SignMessageErrorCodes2;
|
|
742
|
+
})(SignMessageErrorCodes || {});
|
|
743
|
+
var SignMessageErrorMessage = {
|
|
744
|
+
["invalid_message" /* InvalidMessage */]: "Invalid message requested",
|
|
745
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
746
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
747
|
+
};
|
|
748
|
+
function createSignMessageCommand(_ctx) {
|
|
749
|
+
return (payload) => {
|
|
750
|
+
if (typeof window === "undefined" || !isCommandAvailable("sign-message" /* SignMessage */)) {
|
|
751
|
+
console.error(
|
|
752
|
+
"'signMessage' command is unavailable. Check MiniKit.install() or update the app version"
|
|
753
|
+
);
|
|
754
|
+
return null;
|
|
755
|
+
}
|
|
756
|
+
sendMiniKitEvent({
|
|
757
|
+
command: "sign-message" /* SignMessage */,
|
|
758
|
+
version: COMMAND_VERSIONS["sign-message" /* SignMessage */],
|
|
759
|
+
payload
|
|
760
|
+
});
|
|
761
|
+
return payload;
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function createSignMessageAsyncCommand(ctx, syncCommand) {
|
|
765
|
+
return async (payload) => {
|
|
766
|
+
return new Promise((resolve, reject) => {
|
|
767
|
+
try {
|
|
768
|
+
let commandPayload = null;
|
|
769
|
+
const handleResponse = (response) => {
|
|
770
|
+
ctx.events.unsubscribe("miniapp-sign-message" /* MiniAppSignMessage */);
|
|
771
|
+
resolve({ commandPayload, finalPayload: response });
|
|
772
|
+
};
|
|
773
|
+
ctx.events.subscribe(
|
|
774
|
+
"miniapp-sign-message" /* MiniAppSignMessage */,
|
|
775
|
+
handleResponse
|
|
776
|
+
);
|
|
777
|
+
commandPayload = syncCommand(payload);
|
|
778
|
+
} catch (error) {
|
|
779
|
+
reject(error);
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// commands/sign-typed-data.ts
|
|
786
|
+
var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
787
|
+
SignTypedDataErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
788
|
+
SignTypedDataErrorCodes2["UserRejected"] = "user_rejected";
|
|
789
|
+
SignTypedDataErrorCodes2["InputError"] = "input_error";
|
|
790
|
+
SignTypedDataErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
791
|
+
SignTypedDataErrorCodes2["GenericError"] = "generic_error";
|
|
792
|
+
SignTypedDataErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
793
|
+
SignTypedDataErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
794
|
+
SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
795
|
+
return SignTypedDataErrorCodes2;
|
|
796
|
+
})(SignTypedDataErrorCodes || {});
|
|
797
|
+
var SignTypedDataErrorMessage = {
|
|
798
|
+
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
799
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
800
|
+
["input_error" /* InputError */]: "Invalid payload.",
|
|
801
|
+
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
802
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
803
|
+
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
804
|
+
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
805
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
806
|
+
};
|
|
807
|
+
function createSignTypedDataCommand(_ctx) {
|
|
808
|
+
return (payload) => {
|
|
809
|
+
if (typeof window === "undefined" || !isCommandAvailable("sign-typed-data" /* SignTypedData */)) {
|
|
810
|
+
console.error(
|
|
811
|
+
"'signTypedData' command is unavailable. Check MiniKit.install() or update the app version"
|
|
812
|
+
);
|
|
813
|
+
return null;
|
|
814
|
+
}
|
|
815
|
+
if (!payload.chainId) {
|
|
816
|
+
payload.chainId = 480;
|
|
817
|
+
}
|
|
818
|
+
sendMiniKitEvent({
|
|
819
|
+
command: "sign-typed-data" /* SignTypedData */,
|
|
820
|
+
version: COMMAND_VERSIONS["sign-typed-data" /* SignTypedData */],
|
|
821
|
+
payload
|
|
822
|
+
});
|
|
823
|
+
return payload;
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
function createSignTypedDataAsyncCommand(ctx, syncCommand) {
|
|
827
|
+
return async (payload) => {
|
|
828
|
+
return new Promise((resolve, reject) => {
|
|
829
|
+
try {
|
|
830
|
+
let commandPayload = null;
|
|
831
|
+
const handleResponse = (response) => {
|
|
832
|
+
ctx.events.unsubscribe("miniapp-sign-typed-data" /* MiniAppSignTypedData */);
|
|
833
|
+
resolve({ commandPayload, finalPayload: response });
|
|
834
|
+
};
|
|
835
|
+
ctx.events.subscribe(
|
|
836
|
+
"miniapp-sign-typed-data" /* MiniAppSignTypedData */,
|
|
837
|
+
handleResponse
|
|
838
|
+
);
|
|
839
|
+
commandPayload = syncCommand(payload);
|
|
840
|
+
} catch (error) {
|
|
841
|
+
reject(error);
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// commands/verify.ts
|
|
848
|
+
import { VerificationLevel } from "@worldcoin/idkit-core";
|
|
849
|
+
import { encodeAction, generateSignal } from "@worldcoin/idkit-core/hashing";
|
|
850
|
+
import { AppErrorCodes } from "@worldcoin/idkit-core";
|
|
851
|
+
function createVerifyCommand(_ctx) {
|
|
852
|
+
return (payload) => {
|
|
853
|
+
if (typeof window === "undefined" || !isCommandAvailable("verify" /* Verify */)) {
|
|
854
|
+
console.error(
|
|
855
|
+
"'verify' command is unavailable. Check MiniKit.install() or update the app version"
|
|
856
|
+
);
|
|
857
|
+
return null;
|
|
858
|
+
}
|
|
859
|
+
if (Array.isArray(payload.verification_level) && payload.verification_level.length === 0) {
|
|
860
|
+
console.error("'verification_level' must not be an empty array");
|
|
861
|
+
return null;
|
|
862
|
+
}
|
|
863
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
864
|
+
const eventPayload = {
|
|
865
|
+
action: encodeAction(payload.action),
|
|
866
|
+
signal: generateSignal(payload.signal).digest,
|
|
867
|
+
verification_level: payload.verification_level || VerificationLevel.Orb,
|
|
868
|
+
timestamp
|
|
869
|
+
};
|
|
870
|
+
sendMiniKitEvent({
|
|
871
|
+
command: "verify" /* Verify */,
|
|
872
|
+
version: COMMAND_VERSIONS["verify" /* Verify */],
|
|
873
|
+
payload: eventPayload
|
|
874
|
+
});
|
|
875
|
+
return eventPayload;
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
function createVerifyAsyncCommand(ctx, syncCommand) {
|
|
879
|
+
return async (payload) => {
|
|
880
|
+
return new Promise((resolve, reject) => {
|
|
881
|
+
try {
|
|
882
|
+
let commandPayload = null;
|
|
883
|
+
const handleResponse = (response) => {
|
|
884
|
+
ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
|
|
885
|
+
resolve({ commandPayload, finalPayload: response });
|
|
886
|
+
};
|
|
887
|
+
ctx.events.subscribe(
|
|
888
|
+
"miniapp-verify-action" /* MiniAppVerifyAction */,
|
|
889
|
+
handleResponse
|
|
890
|
+
);
|
|
891
|
+
commandPayload = syncCommand(payload);
|
|
892
|
+
} catch (error) {
|
|
893
|
+
reject(error);
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
|
|
260
899
|
// helpers/siwe/siwe.ts
|
|
261
900
|
import {
|
|
262
901
|
createPublicClient,
|
|
@@ -526,125 +1165,219 @@ var verifySiweMessageV2 = async (payload, nonce, statement, requestId, userProvi
|
|
|
526
1165
|
}
|
|
527
1166
|
};
|
|
528
1167
|
|
|
529
|
-
//
|
|
530
|
-
var
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
return Permission2;
|
|
549
|
-
})(Permission || {});
|
|
550
|
-
|
|
551
|
-
// minikit.ts
|
|
552
|
-
import { VerificationLevel } from "@worldcoin/idkit-core";
|
|
553
|
-
import { encodeAction, generateSignal } from "@worldcoin/idkit-core/hashing";
|
|
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));
|
|
1168
|
+
// helpers/siwe/validate-wallet-auth-command-input.ts
|
|
1169
|
+
var validateWalletAuthCommandInput = (params) => {
|
|
1170
|
+
if (!params.nonce) {
|
|
1171
|
+
return { valid: false, message: "'nonce' is required" };
|
|
1172
|
+
}
|
|
1173
|
+
if (params.nonce.length < 8) {
|
|
1174
|
+
return { valid: false, message: "'nonce' must be at least 8 characters" };
|
|
1175
|
+
}
|
|
1176
|
+
if (params.statement && params.statement.includes("\n")) {
|
|
1177
|
+
return { valid: false, message: "'statement' must not contain newlines" };
|
|
1178
|
+
}
|
|
1179
|
+
if (params.expirationTime && new Date(params.expirationTime) < /* @__PURE__ */ new Date()) {
|
|
1180
|
+
return { valid: false, message: "'expirationTime' must be in the future" };
|
|
1181
|
+
}
|
|
1182
|
+
if (params.expirationTime && new Date(params.expirationTime) > new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3)) {
|
|
1183
|
+
return { valid: false, message: "'expirationTime' must be within 7 days" };
|
|
1184
|
+
}
|
|
1185
|
+
if (params.notBefore && new Date(params.notBefore) > new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3)) {
|
|
1186
|
+
return { valid: false, message: "'notBefore' must be within 7 days" };
|
|
561
1187
|
}
|
|
1188
|
+
return { valid: true };
|
|
562
1189
|
};
|
|
563
1190
|
|
|
564
|
-
//
|
|
565
|
-
var
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
1191
|
+
// commands/wallet-auth.ts
|
|
1192
|
+
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
1193
|
+
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
1194
|
+
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
1195
|
+
WalletAuthErrorCodes2["GenericError"] = "generic_error";
|
|
1196
|
+
return WalletAuthErrorCodes2;
|
|
1197
|
+
})(WalletAuthErrorCodes || {});
|
|
1198
|
+
var WalletAuthErrorMessage = {
|
|
1199
|
+
["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
|
|
1200
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
1201
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
1202
|
+
};
|
|
1203
|
+
function createWalletAuthCommand(ctx) {
|
|
1204
|
+
return (payload) => {
|
|
1205
|
+
if (typeof window === "undefined" || !isCommandAvailable("wallet-auth" /* WalletAuth */)) {
|
|
1206
|
+
console.error(
|
|
1207
|
+
"'walletAuth' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1208
|
+
);
|
|
1209
|
+
return null;
|
|
577
1210
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
const hasAudioTrack = stream.getAudioTracks().length > 0;
|
|
586
|
-
if (hasAudioTrack) {
|
|
587
|
-
sendWebviewEvent({
|
|
588
|
-
command: "microphone-stream-started",
|
|
589
|
-
version: 1,
|
|
590
|
-
payload: {
|
|
591
|
-
streamId: stream.id
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
live.add(stream);
|
|
595
|
-
stream.getAudioTracks().forEach((t) => {
|
|
596
|
-
t.addEventListener("ended", () => {
|
|
597
|
-
const allAudioTracksEnded = stream.getAudioTracks().every((track) => track.readyState === "ended");
|
|
598
|
-
if (allAudioTracksEnded) {
|
|
599
|
-
sendWebviewEvent({
|
|
600
|
-
command: "microphone-stream-ended",
|
|
601
|
-
version: 1,
|
|
602
|
-
payload: {
|
|
603
|
-
streamId: stream.id
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
live.delete(stream);
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
});
|
|
1211
|
+
const validationResult = validateWalletAuthCommandInput(payload);
|
|
1212
|
+
if (!validationResult.valid) {
|
|
1213
|
+
console.error(
|
|
1214
|
+
"Failed to validate wallet auth input:\n\n -->",
|
|
1215
|
+
validationResult.message
|
|
1216
|
+
);
|
|
1217
|
+
return null;
|
|
610
1218
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
1219
|
+
let protocol = null;
|
|
1220
|
+
try {
|
|
1221
|
+
const currentUrl = new URL(window.location.href);
|
|
1222
|
+
protocol = currentUrl.protocol.split(":")[0];
|
|
1223
|
+
} catch (error) {
|
|
1224
|
+
console.error("Failed to get current URL", error);
|
|
1225
|
+
return null;
|
|
1226
|
+
}
|
|
1227
|
+
const siweMessage = generateSiweMessage({
|
|
1228
|
+
scheme: protocol,
|
|
1229
|
+
domain: window.location.host,
|
|
1230
|
+
statement: payload.statement ?? void 0,
|
|
1231
|
+
uri: window.location.href,
|
|
1232
|
+
version: "1",
|
|
1233
|
+
chain_id: 480,
|
|
1234
|
+
nonce: payload.nonce,
|
|
1235
|
+
issued_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1236
|
+
expiration_time: payload.expirationTime?.toISOString() ?? void 0,
|
|
1237
|
+
not_before: payload.notBefore?.toISOString() ?? void 0,
|
|
1238
|
+
request_id: payload.requestId ?? void 0
|
|
1239
|
+
});
|
|
1240
|
+
const walletAuthPayload = { siweMessage };
|
|
1241
|
+
const walletAuthVersion = ctx.state.user.worldAppVersion && ctx.state.user.worldAppVersion > 2087900 ? COMMAND_VERSIONS["wallet-auth" /* WalletAuth */] : 1;
|
|
1242
|
+
sendMiniKitEvent({
|
|
1243
|
+
command: "wallet-auth" /* WalletAuth */,
|
|
1244
|
+
version: walletAuthVersion,
|
|
1245
|
+
payload: walletAuthPayload
|
|
1246
|
+
});
|
|
1247
|
+
return walletAuthPayload;
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
function createWalletAuthAsyncCommand(ctx, syncCommand) {
|
|
1251
|
+
return async (payload) => {
|
|
1252
|
+
return new Promise((resolve, reject) => {
|
|
1253
|
+
try {
|
|
1254
|
+
let commandPayload = null;
|
|
1255
|
+
const handleResponse = async (response) => {
|
|
1256
|
+
ctx.events.unsubscribe("miniapp-wallet-auth" /* MiniAppWalletAuth */);
|
|
1257
|
+
if (response.status === "success") {
|
|
1258
|
+
await ctx.state.updateUserFromWalletAuth(response.address);
|
|
632
1259
|
}
|
|
633
|
-
|
|
1260
|
+
resolve({ commandPayload, finalPayload: response });
|
|
1261
|
+
};
|
|
1262
|
+
ctx.events.subscribe(
|
|
1263
|
+
"miniapp-wallet-auth" /* MiniAppWalletAuth */,
|
|
1264
|
+
handleResponse
|
|
1265
|
+
);
|
|
1266
|
+
commandPayload = syncCommand(payload);
|
|
1267
|
+
} catch (error) {
|
|
1268
|
+
reject(error);
|
|
634
1269
|
}
|
|
635
1270
|
});
|
|
636
|
-
live.clear();
|
|
637
1271
|
};
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
// commands/index.ts
|
|
1275
|
+
function createCommands(ctx) {
|
|
1276
|
+
return {
|
|
1277
|
+
verify: createVerifyCommand(ctx),
|
|
1278
|
+
pay: createPayCommand(ctx),
|
|
1279
|
+
walletAuth: createWalletAuthCommand(ctx),
|
|
1280
|
+
sendTransaction: createSendTransactionCommand(ctx),
|
|
1281
|
+
signMessage: createSignMessageCommand(ctx),
|
|
1282
|
+
signTypedData: createSignTypedDataCommand(ctx),
|
|
1283
|
+
shareContacts: createShareContactsCommand(ctx),
|
|
1284
|
+
requestPermission: createRequestPermissionCommand(ctx),
|
|
1285
|
+
getPermissions: createGetPermissionsCommand(ctx),
|
|
1286
|
+
sendHapticFeedback: createSendHapticFeedbackCommand(ctx),
|
|
1287
|
+
share: createShareCommand(ctx),
|
|
1288
|
+
chat: createChatCommand(ctx)
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
function createAsyncCommands(ctx, commands) {
|
|
1292
|
+
return {
|
|
1293
|
+
verify: createVerifyAsyncCommand(ctx, commands.verify),
|
|
1294
|
+
pay: createPayAsyncCommand(ctx, commands.pay),
|
|
1295
|
+
walletAuth: createWalletAuthAsyncCommand(ctx, commands.walletAuth),
|
|
1296
|
+
sendTransaction: createSendTransactionAsyncCommand(
|
|
1297
|
+
ctx,
|
|
1298
|
+
commands.sendTransaction
|
|
1299
|
+
),
|
|
1300
|
+
signMessage: createSignMessageAsyncCommand(ctx, commands.signMessage),
|
|
1301
|
+
signTypedData: createSignTypedDataAsyncCommand(ctx, commands.signTypedData),
|
|
1302
|
+
shareContacts: createShareContactsAsyncCommand(ctx, commands.shareContacts),
|
|
1303
|
+
requestPermission: createRequestPermissionAsyncCommand(
|
|
1304
|
+
ctx,
|
|
1305
|
+
commands.requestPermission
|
|
1306
|
+
),
|
|
1307
|
+
getPermissions: createGetPermissionsAsyncCommand(
|
|
1308
|
+
ctx,
|
|
1309
|
+
commands.getPermissions
|
|
1310
|
+
),
|
|
1311
|
+
sendHapticFeedback: createSendHapticFeedbackAsyncCommand(
|
|
1312
|
+
ctx,
|
|
1313
|
+
commands.sendHapticFeedback
|
|
1314
|
+
),
|
|
1315
|
+
share: createShareAsyncCommand(ctx, commands.share),
|
|
1316
|
+
chat: createChatAsyncCommand(ctx, commands.chat)
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
// types/init.ts
|
|
1321
|
+
var MiniAppLaunchLocation = /* @__PURE__ */ ((MiniAppLaunchLocation3) => {
|
|
1322
|
+
MiniAppLaunchLocation3["Chat"] = "chat";
|
|
1323
|
+
MiniAppLaunchLocation3["Home"] = "home";
|
|
1324
|
+
MiniAppLaunchLocation3["AppStore"] = "app-store";
|
|
1325
|
+
MiniAppLaunchLocation3["DeepLink"] = "deep-link";
|
|
1326
|
+
MiniAppLaunchLocation3["WalletTab"] = "wallet-tab";
|
|
1327
|
+
return MiniAppLaunchLocation3;
|
|
1328
|
+
})(MiniAppLaunchLocation || {});
|
|
1329
|
+
var WORLD_APP_LAUNCH_LOCATION_MAP = {
|
|
1330
|
+
"app-store": "app-store" /* AppStore */,
|
|
1331
|
+
carousel: "app-store" /* AppStore */,
|
|
1332
|
+
explore: "app-store" /* AppStore */,
|
|
1333
|
+
app_details: "app-store" /* AppStore */,
|
|
1334
|
+
deeplink: "deep-link" /* DeepLink */,
|
|
1335
|
+
homepage: "home" /* Home */,
|
|
1336
|
+
wallet_tab: "wallet-tab" /* WalletTab */,
|
|
1337
|
+
world_chat: "chat" /* Chat */
|
|
1338
|
+
};
|
|
1339
|
+
var mapWorldAppLaunchLocation = (location) => {
|
|
1340
|
+
if (!location || typeof location !== "string") return null;
|
|
1341
|
+
console.log("MiniKit launch location mapped:", location);
|
|
1342
|
+
const normalizedLocation = location.toLowerCase();
|
|
1343
|
+
return WORLD_APP_LAUNCH_LOCATION_MAP[normalizedLocation] ?? null;
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1346
|
+
// types/errors.ts
|
|
1347
|
+
import { AppErrorCodes as AppErrorCodes2 } from "@worldcoin/idkit-core";
|
|
1348
|
+
import { AppErrorCodes as AppErrorCodes3 } from "@worldcoin/idkit-core";
|
|
1349
|
+
var VerificationErrorMessage = {
|
|
1350
|
+
[AppErrorCodes2.VerificationRejected]: "You've cancelled the request in World App.",
|
|
1351
|
+
[AppErrorCodes2.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
1352
|
+
[AppErrorCodes2.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
1353
|
+
[AppErrorCodes2.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
1354
|
+
[AppErrorCodes2.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
|
|
1355
|
+
[AppErrorCodes2.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
|
|
1356
|
+
[AppErrorCodes2.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
|
|
1357
|
+
[AppErrorCodes2.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
|
|
1358
|
+
[AppErrorCodes2.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
|
|
1359
|
+
[AppErrorCodes2.GenericError]: "Something unexpected went wrong. Please try again.",
|
|
1360
|
+
[AppErrorCodes2.ConnectionFailed]: "Connection to your wallet failed. Please try again."
|
|
1361
|
+
};
|
|
1362
|
+
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
1363
|
+
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
1364
|
+
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
1365
|
+
MiniKitInstallErrorCodes2["OutsideOfWorldApp"] = "outside_of_worldapp";
|
|
1366
|
+
MiniKitInstallErrorCodes2["NotOnClient"] = "not_on_client";
|
|
1367
|
+
MiniKitInstallErrorCodes2["AppOutOfDate"] = "app_out_of_date";
|
|
1368
|
+
return MiniKitInstallErrorCodes2;
|
|
1369
|
+
})(MiniKitInstallErrorCodes || {});
|
|
1370
|
+
var MiniKitInstallErrorMessage = {
|
|
1371
|
+
["unknown" /* Unknown */]: "Failed to install MiniKit.",
|
|
1372
|
+
["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
|
|
1373
|
+
["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
|
|
1374
|
+
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
1375
|
+
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
646
1376
|
};
|
|
647
1377
|
|
|
1378
|
+
// core/events.ts
|
|
1379
|
+
import { AppErrorCodes as AppErrorCodes4, VerificationLevel as VerificationLevel2 } from "@worldcoin/idkit-core";
|
|
1380
|
+
|
|
648
1381
|
// helpers/proof/index.ts
|
|
649
1382
|
import {
|
|
650
1383
|
createPublicClient as createPublicClient2,
|
|
@@ -700,862 +1433,519 @@ var compressAndPadProof = async (proof, rpcUrl) => {
|
|
|
700
1433
|
}
|
|
701
1434
|
};
|
|
702
1435
|
|
|
703
|
-
//
|
|
704
|
-
var
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
title: input.title,
|
|
734
|
-
text: input.text,
|
|
735
|
-
url: input.url
|
|
1436
|
+
// core/events.ts
|
|
1437
|
+
var EventManager = class {
|
|
1438
|
+
constructor() {
|
|
1439
|
+
this.listeners = {
|
|
1440
|
+
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
1441
|
+
},
|
|
1442
|
+
["miniapp-payment" /* MiniAppPayment */]: () => {
|
|
1443
|
+
},
|
|
1444
|
+
["miniapp-wallet-auth" /* MiniAppWalletAuth */]: () => {
|
|
1445
|
+
},
|
|
1446
|
+
["miniapp-send-transaction" /* MiniAppSendTransaction */]: () => {
|
|
1447
|
+
},
|
|
1448
|
+
["miniapp-sign-message" /* MiniAppSignMessage */]: () => {
|
|
1449
|
+
},
|
|
1450
|
+
["miniapp-sign-typed-data" /* MiniAppSignTypedData */]: () => {
|
|
1451
|
+
},
|
|
1452
|
+
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
1453
|
+
},
|
|
1454
|
+
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
1455
|
+
},
|
|
1456
|
+
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
1457
|
+
},
|
|
1458
|
+
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
1459
|
+
},
|
|
1460
|
+
["miniapp-share" /* MiniAppShare */]: () => {
|
|
1461
|
+
},
|
|
1462
|
+
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
1463
|
+
},
|
|
1464
|
+
["miniapp-chat" /* MiniAppChat */]: () => {
|
|
1465
|
+
}
|
|
736
1466
|
};
|
|
737
1467
|
}
|
|
738
|
-
|
|
739
|
-
|
|
1468
|
+
subscribe(event, handler) {
|
|
1469
|
+
this.listeners[event] = handler;
|
|
740
1470
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
1471
|
+
unsubscribe(event) {
|
|
1472
|
+
delete this.listeners[event];
|
|
1473
|
+
}
|
|
1474
|
+
trigger(event, payload) {
|
|
1475
|
+
if (!this.listeners[event]) {
|
|
1476
|
+
console.error(
|
|
1477
|
+
`No handler for event ${event}, payload: ${JSON.stringify(payload)}`
|
|
1478
|
+
);
|
|
1479
|
+
return;
|
|
745
1480
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
1481
|
+
if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
1482
|
+
const handler = this.listeners[event];
|
|
1483
|
+
this.unsubscribe(event);
|
|
1484
|
+
this.processVerifyActionPayload(
|
|
1485
|
+
payload,
|
|
1486
|
+
handler
|
|
1487
|
+
);
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
this.listeners[event](payload);
|
|
1491
|
+
}
|
|
1492
|
+
async processVerifyActionPayload(payload, handler) {
|
|
1493
|
+
if (payload.status === "error" && payload.error_code === "user_rejected") {
|
|
1494
|
+
payload.error_code = AppErrorCodes4.VerificationRejected;
|
|
1495
|
+
}
|
|
1496
|
+
if (payload.status === "success") {
|
|
1497
|
+
if ("verifications" in payload) {
|
|
1498
|
+
const orbVerification = payload.verifications.find(
|
|
1499
|
+
(v) => v.verification_level === VerificationLevel2.Orb
|
|
1500
|
+
);
|
|
1501
|
+
if (orbVerification) {
|
|
1502
|
+
orbVerification.proof = await this.compressProofSafely(
|
|
1503
|
+
orbVerification.proof,
|
|
1504
|
+
{
|
|
1505
|
+
mode: "multi",
|
|
1506
|
+
payloadVersion: payload.version,
|
|
1507
|
+
verificationsCount: payload.verifications.length,
|
|
1508
|
+
verificationLevel: orbVerification.verification_level
|
|
1509
|
+
}
|
|
1510
|
+
);
|
|
1511
|
+
}
|
|
1512
|
+
} else if (payload.verification_level === VerificationLevel2.Orb) {
|
|
1513
|
+
payload.proof = await this.compressProofSafely(
|
|
1514
|
+
payload.proof,
|
|
1515
|
+
{
|
|
1516
|
+
mode: "single",
|
|
1517
|
+
payloadVersion: payload.version,
|
|
1518
|
+
verificationLevel: payload.verification_level
|
|
1519
|
+
}
|
|
751
1520
|
);
|
|
752
1521
|
}
|
|
753
|
-
totalSize += file.size;
|
|
754
1522
|
}
|
|
755
|
-
|
|
756
|
-
|
|
1523
|
+
handler(payload);
|
|
1524
|
+
}
|
|
1525
|
+
async compressProofSafely(proof, context) {
|
|
1526
|
+
try {
|
|
1527
|
+
return await compressAndPadProof(proof);
|
|
1528
|
+
} catch (error) {
|
|
1529
|
+
console.error(
|
|
1530
|
+
"Failed to compress verification proof. Delivering payload with uncompressed proof.",
|
|
1531
|
+
{
|
|
1532
|
+
...context,
|
|
1533
|
+
error
|
|
1534
|
+
}
|
|
1535
|
+
);
|
|
1536
|
+
return proof;
|
|
757
1537
|
}
|
|
758
1538
|
}
|
|
759
|
-
const fileProcessingPromises = input.files.map((file) => processFile(file));
|
|
760
|
-
const processedFiles = await Promise.all(fileProcessingPromises);
|
|
761
|
-
return {
|
|
762
|
-
files: processedFiles,
|
|
763
|
-
title: input.title,
|
|
764
|
-
text: input.text,
|
|
765
|
-
url: input.url
|
|
766
|
-
};
|
|
767
1539
|
};
|
|
768
1540
|
|
|
769
|
-
// helpers/
|
|
770
|
-
var
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
1541
|
+
// helpers/usernames/index.ts
|
|
1542
|
+
var getUserProfile = async (address) => {
|
|
1543
|
+
const res = await fetch("https://usernames.worldcoin.org/api/v1/query", {
|
|
1544
|
+
method: "POST",
|
|
1545
|
+
headers: {
|
|
1546
|
+
"Content-Type": "application/json"
|
|
1547
|
+
},
|
|
1548
|
+
body: JSON.stringify({
|
|
1549
|
+
addresses: [address]
|
|
1550
|
+
})
|
|
1551
|
+
});
|
|
1552
|
+
const usernames = await res.json();
|
|
1553
|
+
return usernames?.[0] ?? { username: null, profile_picture_url: null };
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1556
|
+
// core/state.ts
|
|
1557
|
+
var MiniKitState = class {
|
|
1558
|
+
constructor() {
|
|
1559
|
+
this.appId = null;
|
|
1560
|
+
this.user = {};
|
|
1561
|
+
this.deviceProperties = {};
|
|
1562
|
+
this.location = null;
|
|
1563
|
+
this.isReady = false;
|
|
776
1564
|
}
|
|
777
|
-
|
|
778
|
-
|
|
1565
|
+
initFromWorldApp(worldApp) {
|
|
1566
|
+
if (!worldApp) return;
|
|
1567
|
+
this.user.optedIntoOptionalAnalytics = worldApp.is_optional_analytics;
|
|
1568
|
+
this.user.deviceOS = worldApp.device_os;
|
|
1569
|
+
this.user.worldAppVersion = worldApp.world_app_version;
|
|
1570
|
+
this.deviceProperties.safeAreaInsets = worldApp.safe_area_insets;
|
|
1571
|
+
this.deviceProperties.deviceOS = worldApp.device_os;
|
|
1572
|
+
this.deviceProperties.worldAppVersion = worldApp.world_app_version;
|
|
1573
|
+
this.location = mapWorldAppLaunchLocation(worldApp.location);
|
|
779
1574
|
}
|
|
780
|
-
|
|
781
|
-
|
|
1575
|
+
async updateUserFromWalletAuth(address) {
|
|
1576
|
+
this.user.walletAddress = address;
|
|
1577
|
+
try {
|
|
1578
|
+
const userProfile = await getUserProfile(address);
|
|
1579
|
+
this.user.username = userProfile.username;
|
|
1580
|
+
this.user.profilePictureUrl = userProfile.profile_picture_url;
|
|
1581
|
+
} catch (error) {
|
|
1582
|
+
console.error("Failed to fetch user profile:", error);
|
|
1583
|
+
}
|
|
782
1584
|
}
|
|
783
|
-
|
|
784
|
-
|
|
1585
|
+
async getUserByAddress(address) {
|
|
1586
|
+
const walletAddress = address ?? this.user.walletAddress;
|
|
1587
|
+
const userProfile = await getUserProfile(walletAddress);
|
|
1588
|
+
return {
|
|
1589
|
+
walletAddress,
|
|
1590
|
+
username: userProfile.username,
|
|
1591
|
+
profilePictureUrl: userProfile.profile_picture_url
|
|
1592
|
+
};
|
|
785
1593
|
}
|
|
786
|
-
|
|
787
|
-
|
|
1594
|
+
async getUserByUsername(username) {
|
|
1595
|
+
const res = await fetch(
|
|
1596
|
+
`https://usernames.worldcoin.org/api/v1/${username}`,
|
|
1597
|
+
{
|
|
1598
|
+
method: "GET",
|
|
1599
|
+
headers: {
|
|
1600
|
+
"Content-Type": "application/json"
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
);
|
|
1604
|
+
const user = await res.json();
|
|
1605
|
+
return {
|
|
1606
|
+
walletAddress: user.address,
|
|
1607
|
+
username: user.username,
|
|
1608
|
+
profilePictureUrl: user.profile_picture_url
|
|
1609
|
+
};
|
|
788
1610
|
}
|
|
789
|
-
return { valid: true };
|
|
790
1611
|
};
|
|
791
1612
|
|
|
792
|
-
// helpers/
|
|
793
|
-
var
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
if (input === null || typeof input !== "object") {
|
|
798
|
-
return input;
|
|
799
|
-
}
|
|
800
|
-
if (Array.isArray(input)) {
|
|
801
|
-
return input.map((item) => objectValuesToArrayRecursive(item));
|
|
802
|
-
}
|
|
803
|
-
const values = Object.values(input);
|
|
804
|
-
return values.map((value) => objectValuesToArrayRecursive(value));
|
|
805
|
-
};
|
|
806
|
-
var processPayload = (payload) => {
|
|
807
|
-
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
808
|
-
return payload;
|
|
809
|
-
}
|
|
810
|
-
if (typeof payload === "number" || typeof payload === "bigint") {
|
|
811
|
-
return String(payload);
|
|
812
|
-
}
|
|
813
|
-
if (Array.isArray(payload)) {
|
|
814
|
-
return payload.map((value) => processPayload(value));
|
|
1613
|
+
// helpers/microphone/index.ts
|
|
1614
|
+
var microphoneSetupDone = false;
|
|
1615
|
+
var setupMicrophone = () => {
|
|
1616
|
+
if (microphoneSetupDone) {
|
|
1617
|
+
return;
|
|
815
1618
|
}
|
|
816
|
-
if (typeof
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
console.error(
|
|
824
|
-
"Transaction value must be a valid hex string",
|
|
825
|
-
result.value
|
|
826
|
-
);
|
|
827
|
-
throw new Error(
|
|
828
|
-
`Transaction value must be a valid hex string: ${result.value}`
|
|
829
|
-
);
|
|
830
|
-
}
|
|
1619
|
+
if (typeof navigator !== "undefined" && !navigator.mediaDevices?.getUserMedia)
|
|
1620
|
+
return;
|
|
1621
|
+
const originalStop = MediaStreamTrack.prototype.stop;
|
|
1622
|
+
MediaStreamTrack.prototype.stop = function() {
|
|
1623
|
+
originalStop.call(this);
|
|
1624
|
+
if (this.readyState === "ended") {
|
|
1625
|
+
setTimeout(() => this.dispatchEvent(new Event("ended")), 0);
|
|
831
1626
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
1627
|
+
};
|
|
1628
|
+
const realGUM = navigator.mediaDevices.getUserMedia.bind(
|
|
1629
|
+
navigator.mediaDevices
|
|
1630
|
+
);
|
|
1631
|
+
const live = /* @__PURE__ */ new Set();
|
|
1632
|
+
async function wrapped(constraints) {
|
|
1633
|
+
const stream = await realGUM(constraints);
|
|
1634
|
+
const hasAudioTrack = stream.getAudioTracks().length > 0;
|
|
1635
|
+
if (hasAudioTrack) {
|
|
1636
|
+
sendWebviewEvent({
|
|
1637
|
+
command: "microphone-stream-started",
|
|
1638
|
+
version: 1,
|
|
1639
|
+
payload: {
|
|
1640
|
+
streamId: stream.id
|
|
1641
|
+
}
|
|
1642
|
+
});
|
|
1643
|
+
live.add(stream);
|
|
1644
|
+
stream.getAudioTracks().forEach((t) => {
|
|
1645
|
+
t.addEventListener("ended", () => {
|
|
1646
|
+
const allAudioTracksEnded = stream.getAudioTracks().every((track) => track.readyState === "ended");
|
|
1647
|
+
if (allAudioTracksEnded) {
|
|
1648
|
+
sendWebviewEvent({
|
|
1649
|
+
command: "microphone-stream-ended",
|
|
1650
|
+
version: 1,
|
|
1651
|
+
payload: {
|
|
1652
|
+
streamId: stream.id
|
|
1653
|
+
}
|
|
1654
|
+
});
|
|
1655
|
+
live.delete(stream);
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
});
|
|
836
1659
|
}
|
|
837
|
-
return
|
|
1660
|
+
return stream;
|
|
838
1661
|
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
1662
|
+
Object.defineProperty(navigator.mediaDevices, "getUserMedia", {
|
|
1663
|
+
value: wrapped,
|
|
1664
|
+
writable: false,
|
|
1665
|
+
configurable: false,
|
|
1666
|
+
enumerable: true
|
|
1667
|
+
});
|
|
1668
|
+
Object.freeze(navigator.mediaDevices);
|
|
1669
|
+
const stopAllMiniAppMicrophoneStreams = () => {
|
|
1670
|
+
live.forEach((s) => {
|
|
1671
|
+
const audioTracks = s.getAudioTracks();
|
|
1672
|
+
if (audioTracks.length > 0) {
|
|
1673
|
+
audioTracks.forEach((t) => {
|
|
1674
|
+
t.stop();
|
|
1675
|
+
});
|
|
1676
|
+
sendWebviewEvent({
|
|
1677
|
+
command: "microphone-stream-ended",
|
|
1678
|
+
version: 1,
|
|
1679
|
+
payload: {
|
|
1680
|
+
streamId: s.id
|
|
1681
|
+
}
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
850
1684
|
});
|
|
851
|
-
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
const res = await fetch("https://usernames.worldcoin.org/api/v1/query", {
|
|
859
|
-
method: "POST",
|
|
860
|
-
headers: {
|
|
861
|
-
"Content-Type": "application/json"
|
|
862
|
-
},
|
|
863
|
-
body: JSON.stringify({
|
|
864
|
-
addresses: [address]
|
|
865
|
-
})
|
|
1685
|
+
live.clear();
|
|
1686
|
+
};
|
|
1687
|
+
MiniKit.subscribe("miniapp-microphone" /* MiniAppMicrophone */, (payload) => {
|
|
1688
|
+
if (payload.status === "error" && (payload.error_code === "mini_app_permission_not_enabled" /* MiniAppPermissionNotEnabled */ || payload.error_code === "world_app_permission_not_enabled" /* WorldAppPermissionNotEnabled */)) {
|
|
1689
|
+
console.log("stopping all microphone streams", payload);
|
|
1690
|
+
stopAllMiniAppMicrophoneStreams();
|
|
1691
|
+
}
|
|
866
1692
|
});
|
|
867
|
-
|
|
868
|
-
|
|
1693
|
+
window.__stopAllMiniAppMicrophoneStreams = stopAllMiniAppMicrophoneStreams;
|
|
1694
|
+
microphoneSetupDone = true;
|
|
869
1695
|
};
|
|
870
1696
|
|
|
871
1697
|
// minikit.ts
|
|
872
|
-
var
|
|
873
|
-
|
|
874
|
-
};
|
|
1698
|
+
var MINIKIT_VERSION = 1;
|
|
1699
|
+
var MINIKIT_MINOR_VERSION = 96;
|
|
875
1700
|
var _MiniKit = class _MiniKit {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
1701
|
+
// ============================================================================
|
|
1702
|
+
// Public State Accessors
|
|
1703
|
+
// ============================================================================
|
|
1704
|
+
static get appId() {
|
|
1705
|
+
return this.stateManager.appId;
|
|
1706
|
+
}
|
|
1707
|
+
static set appId(value) {
|
|
1708
|
+
this.stateManager.appId = value;
|
|
1709
|
+
}
|
|
1710
|
+
static get user() {
|
|
1711
|
+
return this.stateManager.user;
|
|
1712
|
+
}
|
|
1713
|
+
static set user(value) {
|
|
1714
|
+
this.stateManager.user = value;
|
|
1715
|
+
}
|
|
1716
|
+
static get deviceProperties() {
|
|
1717
|
+
return this.stateManager.deviceProperties;
|
|
1718
|
+
}
|
|
1719
|
+
static get location() {
|
|
1720
|
+
return this.stateManager.location;
|
|
884
1721
|
}
|
|
1722
|
+
// ============================================================================
|
|
1723
|
+
// Event System
|
|
1724
|
+
// ============================================================================
|
|
885
1725
|
static subscribe(event, handler) {
|
|
886
1726
|
if (event === "miniapp-wallet-auth" /* MiniAppWalletAuth */) {
|
|
887
1727
|
const originalHandler = handler;
|
|
888
1728
|
const wrappedHandler = async (payload) => {
|
|
889
1729
|
if (payload.status === "success") {
|
|
890
|
-
|
|
891
|
-
try {
|
|
892
|
-
const user = await _MiniKit.getUserByAddress(payload.address);
|
|
893
|
-
_MiniKit.user = { ..._MiniKit.user, ...user };
|
|
894
|
-
} catch (error) {
|
|
895
|
-
console.error("Failed to fetch user profile:", error);
|
|
896
|
-
}
|
|
1730
|
+
await this.stateManager.updateUserFromWalletAuth(payload.address);
|
|
897
1731
|
}
|
|
898
1732
|
originalHandler(payload);
|
|
899
1733
|
};
|
|
900
|
-
this.
|
|
901
|
-
} else if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
902
|
-
const originalHandler = handler;
|
|
903
|
-
const wrappedHandler = (payload) => {
|
|
904
|
-
if (payload.status === "success" && payload.verification_level === VerificationLevel.Orb) {
|
|
905
|
-
compressAndPadProof(payload.proof).then(
|
|
906
|
-
(compressedProof) => {
|
|
907
|
-
payload.proof = compressedProof;
|
|
908
|
-
originalHandler(payload);
|
|
909
|
-
}
|
|
910
|
-
);
|
|
911
|
-
} else {
|
|
912
|
-
originalHandler(payload);
|
|
913
|
-
}
|
|
914
|
-
};
|
|
915
|
-
this.listeners[event] = wrappedHandler;
|
|
1734
|
+
this.eventManager.subscribe(event, wrappedHandler);
|
|
916
1735
|
} else {
|
|
917
|
-
this.
|
|
1736
|
+
this.eventManager.subscribe(event, handler);
|
|
918
1737
|
}
|
|
919
1738
|
}
|
|
920
1739
|
static unsubscribe(event) {
|
|
921
|
-
|
|
1740
|
+
this.eventManager.unsubscribe(event);
|
|
922
1741
|
}
|
|
923
1742
|
static trigger(event, payload) {
|
|
924
|
-
|
|
925
|
-
console.error(
|
|
926
|
-
`No handler for event ${event}, payload: ${JSON.stringify(payload)}`
|
|
927
|
-
);
|
|
928
|
-
return;
|
|
929
|
-
}
|
|
930
|
-
this.listeners[event](payload);
|
|
931
|
-
}
|
|
932
|
-
static async awaitCommand(event, command, executor) {
|
|
933
|
-
return new Promise((resolve) => {
|
|
934
|
-
let commandPayload = null;
|
|
935
|
-
const handleAndUnsubscribe = (payload) => {
|
|
936
|
-
this.unsubscribe(event);
|
|
937
|
-
resolve({ commandPayload, finalPayload: payload });
|
|
938
|
-
};
|
|
939
|
-
this.subscribe(event, handleAndUnsubscribe);
|
|
940
|
-
commandPayload = executor();
|
|
941
|
-
});
|
|
1743
|
+
this.eventManager.trigger(event, payload);
|
|
942
1744
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
console.warn(
|
|
953
|
-
`Command ${minikitCommandName} is not supported by the app. Try updating the app version`
|
|
954
|
-
);
|
|
955
|
-
} else {
|
|
956
|
-
if (commandInput.supported_versions.includes(version)) {
|
|
957
|
-
_MiniKit.isCommandAvailable[minikitCommandName] = true;
|
|
958
|
-
isCommandValid = true;
|
|
959
|
-
} else {
|
|
960
|
-
isCommandValid = true;
|
|
961
|
-
console.warn(
|
|
962
|
-
`Command ${minikitCommandName} version ${version} is not supported by the app. Supported versions: ${commandInput.supported_versions.join(", ")}. This is not an error, but it is recommended to update the World App version.`
|
|
963
|
-
);
|
|
964
|
-
_MiniKit.isCommandAvailable[minikitCommandName] = isCommandValid;
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
if (!isCommandValid) {
|
|
968
|
-
allCommandsValid = false;
|
|
969
|
-
}
|
|
1745
|
+
// ============================================================================
|
|
1746
|
+
// Installation
|
|
1747
|
+
// ============================================================================
|
|
1748
|
+
static sendInit() {
|
|
1749
|
+
sendWebviewEvent({
|
|
1750
|
+
command: "init",
|
|
1751
|
+
payload: {
|
|
1752
|
+
version: MINIKIT_VERSION,
|
|
1753
|
+
minorVersion: MINIKIT_MINOR_VERSION
|
|
970
1754
|
}
|
|
971
|
-
);
|
|
972
|
-
return allCommandsValid;
|
|
1755
|
+
});
|
|
973
1756
|
}
|
|
974
1757
|
static install(appId) {
|
|
975
1758
|
if (typeof window === "undefined" || Boolean(window.MiniKit)) {
|
|
976
1759
|
return {
|
|
977
1760
|
success: false,
|
|
978
|
-
errorCode: "already_installed" /* AlreadyInstalled */,
|
|
979
|
-
errorMessage: MiniKitInstallErrorMessage["already_installed" /* AlreadyInstalled */]
|
|
980
|
-
};
|
|
981
|
-
}
|
|
982
|
-
if (!appId) {
|
|
983
|
-
console.warn("App ID not provided during install");
|
|
984
|
-
} else {
|
|
985
|
-
_MiniKit.appId = appId;
|
|
986
|
-
}
|
|
987
|
-
if (!window.WorldApp) {
|
|
988
|
-
return {
|
|
989
|
-
success: false,
|
|
990
|
-
errorCode: "outside_of_worldapp" /* OutsideOfWorldApp */,
|
|
991
|
-
errorMessage: MiniKitInstallErrorMessage["outside_of_worldapp" /* OutsideOfWorldApp */]
|
|
992
|
-
};
|
|
993
|
-
}
|
|
994
|
-
_MiniKit.user.optedIntoOptionalAnalytics = window.WorldApp.is_optional_analytics;
|
|
995
|
-
_MiniKit.user.deviceOS = window.WorldApp.device_os;
|
|
996
|
-
_MiniKit.user.worldAppVersion = window.WorldApp.world_app_version;
|
|
997
|
-
_MiniKit.deviceProperties.safeAreaInsets = window.WorldApp.safe_area_insets;
|
|
998
|
-
_MiniKit.deviceProperties.deviceOS = window.WorldApp.device_os;
|
|
999
|
-
_MiniKit.deviceProperties.worldAppVersion = window.WorldApp.world_app_version;
|
|
1000
|
-
try {
|
|
1001
|
-
window.MiniKit = _MiniKit;
|
|
1002
|
-
this.sendInit();
|
|
1003
|
-
} catch (error) {
|
|
1004
|
-
console.error(
|
|
1005
|
-
MiniKitInstallErrorMessage["unknown" /* Unknown */],
|
|
1006
|
-
error
|
|
1007
|
-
);
|
|
1008
|
-
return {
|
|
1009
|
-
success: false,
|
|
1010
|
-
errorCode: "unknown" /* Unknown */,
|
|
1011
|
-
errorMessage: MiniKitInstallErrorMessage["unknown" /* Unknown */]
|
|
1012
|
-
};
|
|
1013
|
-
}
|
|
1014
|
-
_MiniKit.isReady = true;
|
|
1015
|
-
setupMicrophone();
|
|
1016
|
-
if (!this.commandsValid(window.WorldApp.supported_commands)) {
|
|
1017
|
-
return {
|
|
1018
|
-
success: false,
|
|
1019
|
-
errorCode: "app_out_of_date" /* AppOutOfDate */,
|
|
1020
|
-
errorMessage: MiniKitInstallErrorMessage["app_out_of_date" /* AppOutOfDate */]
|
|
1021
|
-
};
|
|
1022
|
-
}
|
|
1023
|
-
return { success: true };
|
|
1024
|
-
}
|
|
1025
|
-
static isInstalled(debug) {
|
|
1026
|
-
const isInstalled = _MiniKit.isReady && Boolean(window.MiniKit);
|
|
1027
|
-
if (!isInstalled)
|
|
1028
|
-
console.error(
|
|
1029
|
-
"MiniKit is not installed. Make sure you're running the application inside of World App"
|
|
1030
|
-
);
|
|
1031
|
-
if (debug && isInstalled) console.log("MiniKit is alive!");
|
|
1032
|
-
return isInstalled;
|
|
1033
|
-
}
|
|
1034
|
-
};
|
|
1035
|
-
_MiniKit.MINIKIT_VERSION = 1;
|
|
1036
|
-
_MiniKit.MINIKIT_MINOR_VERSION = 96;
|
|
1037
|
-
_MiniKit.miniKitCommandVersion = {
|
|
1038
|
-
["verify" /* Verify */]: 1,
|
|
1039
|
-
["pay" /* Pay */]: 1,
|
|
1040
|
-
["wallet-auth" /* WalletAuth */]: 2,
|
|
1041
|
-
["send-transaction" /* SendTransaction */]: 1,
|
|
1042
|
-
["sign-message" /* SignMessage */]: 1,
|
|
1043
|
-
["sign-typed-data" /* SignTypedData */]: 1,
|
|
1044
|
-
["share-contacts" /* ShareContacts */]: 1,
|
|
1045
|
-
["request-permission" /* RequestPermission */]: 1,
|
|
1046
|
-
["get-permissions" /* GetPermissions */]: 1,
|
|
1047
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
1048
|
-
["share" /* Share */]: 1
|
|
1049
|
-
};
|
|
1050
|
-
_MiniKit.isCommandAvailable = {
|
|
1051
|
-
["verify" /* Verify */]: false,
|
|
1052
|
-
["pay" /* Pay */]: false,
|
|
1053
|
-
["wallet-auth" /* WalletAuth */]: false,
|
|
1054
|
-
["send-transaction" /* SendTransaction */]: false,
|
|
1055
|
-
["sign-message" /* SignMessage */]: false,
|
|
1056
|
-
["sign-typed-data" /* SignTypedData */]: false,
|
|
1057
|
-
["share-contacts" /* ShareContacts */]: false,
|
|
1058
|
-
["request-permission" /* RequestPermission */]: false,
|
|
1059
|
-
["get-permissions" /* GetPermissions */]: false,
|
|
1060
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
1061
|
-
["share" /* Share */]: false
|
|
1062
|
-
};
|
|
1063
|
-
_MiniKit.listeners = {
|
|
1064
|
-
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
1065
|
-
},
|
|
1066
|
-
["miniapp-payment" /* MiniAppPayment */]: () => {
|
|
1067
|
-
},
|
|
1068
|
-
["miniapp-wallet-auth" /* MiniAppWalletAuth */]: () => {
|
|
1069
|
-
},
|
|
1070
|
-
["miniapp-send-transaction" /* MiniAppSendTransaction */]: () => {
|
|
1071
|
-
},
|
|
1072
|
-
["miniapp-sign-message" /* MiniAppSignMessage */]: () => {
|
|
1073
|
-
},
|
|
1074
|
-
["miniapp-sign-typed-data" /* MiniAppSignTypedData */]: () => {
|
|
1075
|
-
},
|
|
1076
|
-
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
1077
|
-
},
|
|
1078
|
-
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
1079
|
-
},
|
|
1080
|
-
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
1081
|
-
},
|
|
1082
|
-
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
1083
|
-
},
|
|
1084
|
-
["miniapp-share" /* MiniAppShare */]: () => {
|
|
1085
|
-
},
|
|
1086
|
-
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
_MiniKit.appId = null;
|
|
1090
|
-
_MiniKit.user = {};
|
|
1091
|
-
_MiniKit.deviceProperties = {};
|
|
1092
|
-
_MiniKit.isReady = false;
|
|
1093
|
-
_MiniKit.getUserByAddress = async (address) => {
|
|
1094
|
-
const userProfile = await getUserProfile(
|
|
1095
|
-
address ?? _MiniKit.user.walletAddress
|
|
1096
|
-
);
|
|
1097
|
-
return {
|
|
1098
|
-
walletAddress: address ?? _MiniKit.user.walletAddress,
|
|
1099
|
-
username: userProfile.username,
|
|
1100
|
-
profilePictureUrl: userProfile.profile_picture_url
|
|
1101
|
-
};
|
|
1102
|
-
};
|
|
1103
|
-
_MiniKit.getUserByUsername = async (username) => {
|
|
1104
|
-
const res = await fetch(
|
|
1105
|
-
`https://usernames.worldcoin.org/api/v1/${username}`,
|
|
1106
|
-
{
|
|
1107
|
-
method: "GET",
|
|
1108
|
-
headers: {
|
|
1109
|
-
"Content-Type": "application/json"
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
);
|
|
1113
|
-
const user = await res.json();
|
|
1114
|
-
return {
|
|
1115
|
-
walletAddress: user.address,
|
|
1116
|
-
username: user.username,
|
|
1117
|
-
profilePictureUrl: user.profile_picture_url
|
|
1118
|
-
};
|
|
1119
|
-
};
|
|
1120
|
-
// Simply re-exporting the existing function
|
|
1121
|
-
_MiniKit.getUserInfo = _MiniKit.getUserByAddress;
|
|
1122
|
-
_MiniKit.commands = {
|
|
1123
|
-
verify: (payload) => {
|
|
1124
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["verify" /* Verify */]) {
|
|
1125
|
-
console.error(
|
|
1126
|
-
"'verify' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1127
|
-
);
|
|
1128
|
-
return null;
|
|
1129
|
-
}
|
|
1130
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
1131
|
-
const eventPayload = {
|
|
1132
|
-
action: encodeAction(payload.action),
|
|
1133
|
-
signal: generateSignal(payload.signal).digest,
|
|
1134
|
-
verification_level: payload.verification_level || VerificationLevel.Orb,
|
|
1135
|
-
timestamp
|
|
1136
|
-
};
|
|
1137
|
-
sendMiniKitEvent({
|
|
1138
|
-
command: "verify" /* Verify */,
|
|
1139
|
-
version: _MiniKit.miniKitCommandVersion["verify" /* Verify */],
|
|
1140
|
-
payload: eventPayload
|
|
1141
|
-
});
|
|
1142
|
-
return eventPayload;
|
|
1143
|
-
},
|
|
1144
|
-
pay: (payload) => {
|
|
1145
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["pay" /* Pay */]) {
|
|
1146
|
-
console.error(
|
|
1147
|
-
"'pay' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1148
|
-
);
|
|
1149
|
-
return null;
|
|
1150
|
-
}
|
|
1151
|
-
if (!validatePaymentPayload(payload)) {
|
|
1152
|
-
return null;
|
|
1153
|
-
}
|
|
1154
|
-
const eventPayload = {
|
|
1155
|
-
...payload,
|
|
1156
|
-
network: "worldchain" /* WorldChain */
|
|
1157
|
-
};
|
|
1158
|
-
sendMiniKitEvent({
|
|
1159
|
-
command: "pay" /* Pay */,
|
|
1160
|
-
version: _MiniKit.miniKitCommandVersion["pay" /* Pay */],
|
|
1161
|
-
payload: eventPayload
|
|
1162
|
-
});
|
|
1163
|
-
return eventPayload;
|
|
1164
|
-
},
|
|
1165
|
-
walletAuth: (payload) => {
|
|
1166
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["wallet-auth" /* WalletAuth */]) {
|
|
1167
|
-
console.error(
|
|
1168
|
-
"'walletAuth' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1169
|
-
);
|
|
1170
|
-
return null;
|
|
1171
|
-
}
|
|
1172
|
-
const validationResult = validateWalletAuthCommandInput(payload);
|
|
1173
|
-
if (!validationResult.valid) {
|
|
1174
|
-
console.error(
|
|
1175
|
-
"Failed to validate wallet auth input:\n\n -->",
|
|
1176
|
-
validationResult.message
|
|
1177
|
-
);
|
|
1178
|
-
return null;
|
|
1179
|
-
}
|
|
1180
|
-
let protocol = null;
|
|
1181
|
-
try {
|
|
1182
|
-
const currentUrl = new URL(window.location.href);
|
|
1183
|
-
protocol = currentUrl.protocol.split(":")[0];
|
|
1184
|
-
} catch (error) {
|
|
1185
|
-
console.error("Failed to get current URL", error);
|
|
1186
|
-
return null;
|
|
1187
|
-
}
|
|
1188
|
-
const siweMessage = generateSiweMessage({
|
|
1189
|
-
scheme: protocol,
|
|
1190
|
-
domain: window.location.host,
|
|
1191
|
-
statement: payload.statement ?? void 0,
|
|
1192
|
-
uri: window.location.href,
|
|
1193
|
-
version: "1",
|
|
1194
|
-
chain_id: 480,
|
|
1195
|
-
nonce: payload.nonce,
|
|
1196
|
-
issued_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1197
|
-
expiration_time: payload.expirationTime?.toISOString() ?? void 0,
|
|
1198
|
-
not_before: payload.notBefore?.toISOString() ?? void 0,
|
|
1199
|
-
request_id: payload.requestId ?? void 0
|
|
1200
|
-
});
|
|
1201
|
-
const walletAuthPayload = { siweMessage };
|
|
1202
|
-
const walletAuthVersion = _MiniKit.user.worldAppVersion && _MiniKit.user.worldAppVersion > 2087900 ? _MiniKit.miniKitCommandVersion["wallet-auth" /* WalletAuth */] : 1;
|
|
1203
|
-
sendMiniKitEvent({
|
|
1204
|
-
command: "wallet-auth" /* WalletAuth */,
|
|
1205
|
-
version: walletAuthVersion,
|
|
1206
|
-
payload: walletAuthPayload
|
|
1207
|
-
});
|
|
1208
|
-
return walletAuthPayload;
|
|
1209
|
-
},
|
|
1210
|
-
sendTransaction: (payload) => {
|
|
1211
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-transaction" /* SendTransaction */]) {
|
|
1212
|
-
console.error(
|
|
1213
|
-
"'sendTransaction' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1214
|
-
);
|
|
1215
|
-
return null;
|
|
1216
|
-
}
|
|
1217
|
-
payload.formatPayload = payload.formatPayload !== false;
|
|
1218
|
-
const validatedPayload = validateSendTransactionPayload(payload);
|
|
1219
|
-
sendMiniKitEvent({
|
|
1220
|
-
command: "send-transaction" /* SendTransaction */,
|
|
1221
|
-
version: _MiniKit.miniKitCommandVersion["send-transaction" /* SendTransaction */],
|
|
1222
|
-
payload: validatedPayload
|
|
1223
|
-
});
|
|
1224
|
-
return validatedPayload;
|
|
1225
|
-
},
|
|
1226
|
-
signMessage: (payload) => {
|
|
1227
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-message" /* SignMessage */]) {
|
|
1228
|
-
console.error(
|
|
1229
|
-
"'signMessage' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1230
|
-
);
|
|
1231
|
-
return null;
|
|
1761
|
+
errorCode: "already_installed" /* AlreadyInstalled */,
|
|
1762
|
+
errorMessage: MiniKitInstallErrorMessage["already_installed" /* AlreadyInstalled */]
|
|
1763
|
+
};
|
|
1232
1764
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
});
|
|
1238
|
-
return payload;
|
|
1239
|
-
},
|
|
1240
|
-
signTypedData: (payload) => {
|
|
1241
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-typed-data" /* SignTypedData */]) {
|
|
1242
|
-
console.error(
|
|
1243
|
-
"'signTypedData' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1244
|
-
);
|
|
1245
|
-
return null;
|
|
1765
|
+
if (!appId) {
|
|
1766
|
+
console.warn("App ID not provided during install");
|
|
1767
|
+
} else {
|
|
1768
|
+
this.stateManager.appId = appId;
|
|
1246
1769
|
}
|
|
1247
|
-
if (!
|
|
1248
|
-
|
|
1770
|
+
if (!window.WorldApp) {
|
|
1771
|
+
return {
|
|
1772
|
+
success: false,
|
|
1773
|
+
errorCode: "outside_of_worldapp" /* OutsideOfWorldApp */,
|
|
1774
|
+
errorMessage: MiniKitInstallErrorMessage["outside_of_worldapp" /* OutsideOfWorldApp */]
|
|
1775
|
+
};
|
|
1249
1776
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
})
|
|
1255
|
-
return payload;
|
|
1256
|
-
},
|
|
1257
|
-
shareContacts: (payload) => {
|
|
1258
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share-contacts" /* ShareContacts */]) {
|
|
1777
|
+
this.stateManager.initFromWorldApp(window.WorldApp);
|
|
1778
|
+
try {
|
|
1779
|
+
window.MiniKit = _MiniKit;
|
|
1780
|
+
this.sendInit();
|
|
1781
|
+
} catch (error) {
|
|
1259
1782
|
console.error(
|
|
1260
|
-
"
|
|
1783
|
+
MiniKitInstallErrorMessage["unknown" /* Unknown */],
|
|
1784
|
+
error
|
|
1261
1785
|
);
|
|
1262
|
-
return
|
|
1786
|
+
return {
|
|
1787
|
+
success: false,
|
|
1788
|
+
errorCode: "unknown" /* Unknown */,
|
|
1789
|
+
errorMessage: MiniKitInstallErrorMessage["unknown" /* Unknown */]
|
|
1790
|
+
};
|
|
1263
1791
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["request-permission" /* RequestPermission */]) {
|
|
1273
|
-
console.error(
|
|
1274
|
-
"'requestPermission' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1275
|
-
);
|
|
1276
|
-
return null;
|
|
1792
|
+
this.stateManager.isReady = true;
|
|
1793
|
+
setupMicrophone();
|
|
1794
|
+
if (!validateCommands(window.WorldApp.supported_commands)) {
|
|
1795
|
+
return {
|
|
1796
|
+
success: false,
|
|
1797
|
+
errorCode: "app_out_of_date" /* AppOutOfDate */,
|
|
1798
|
+
errorMessage: MiniKitInstallErrorMessage["app_out_of_date" /* AppOutOfDate */]
|
|
1799
|
+
};
|
|
1277
1800
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
return payload;
|
|
1284
|
-
},
|
|
1285
|
-
getPermissions: () => {
|
|
1286
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["get-permissions" /* GetPermissions */]) {
|
|
1801
|
+
return { success: true };
|
|
1802
|
+
}
|
|
1803
|
+
static isInstalled(debug) {
|
|
1804
|
+
const isInstalled = this.stateManager.isReady && Boolean(window.MiniKit);
|
|
1805
|
+
if (!isInstalled) {
|
|
1287
1806
|
console.error(
|
|
1288
|
-
"
|
|
1807
|
+
"MiniKit is not installed. Make sure you're running the application inside of World App"
|
|
1289
1808
|
);
|
|
1290
|
-
return null;
|
|
1291
1809
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1810
|
+
if (debug && isInstalled) {
|
|
1811
|
+
console.log("MiniKit is alive!");
|
|
1812
|
+
}
|
|
1813
|
+
return isInstalled;
|
|
1814
|
+
}
|
|
1815
|
+
// ============================================================================
|
|
1816
|
+
// Commands
|
|
1817
|
+
// ============================================================================
|
|
1818
|
+
static getContext() {
|
|
1297
1819
|
return {
|
|
1298
|
-
|
|
1820
|
+
events: this.eventManager,
|
|
1821
|
+
state: this.stateManager
|
|
1299
1822
|
};
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
if (
|
|
1303
|
-
|
|
1304
|
-
"'sendHapticFeedback' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1305
|
-
);
|
|
1306
|
-
return null;
|
|
1823
|
+
}
|
|
1824
|
+
static get commands() {
|
|
1825
|
+
if (!this.commandsInstance) {
|
|
1826
|
+
this.commandsInstance = createCommands(this.getContext());
|
|
1307
1827
|
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
// We return share input here because the payload is formatted asynchronously
|
|
1316
|
-
share: (payload) => {
|
|
1317
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share" /* Share */]) {
|
|
1318
|
-
console.error(
|
|
1319
|
-
"'share' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1828
|
+
return this.commandsInstance;
|
|
1829
|
+
}
|
|
1830
|
+
static get commandsAsync() {
|
|
1831
|
+
if (!this.asyncCommandsInstance) {
|
|
1832
|
+
this.asyncCommandsInstance = createAsyncCommands(
|
|
1833
|
+
this.getContext(),
|
|
1834
|
+
this.commands
|
|
1320
1835
|
);
|
|
1321
|
-
return null;
|
|
1322
|
-
}
|
|
1323
|
-
if (_MiniKit.deviceProperties.deviceOS === "ios" && typeof navigator !== "undefined") {
|
|
1324
|
-
sendMiniKitEvent({
|
|
1325
|
-
command: "share" /* Share */,
|
|
1326
|
-
version: _MiniKit.miniKitCommandVersion["share" /* Share */],
|
|
1327
|
-
payload
|
|
1328
|
-
});
|
|
1329
|
-
navigator.share(payload);
|
|
1330
|
-
} else {
|
|
1331
|
-
formatShareInput(payload).then((formattedResult) => {
|
|
1332
|
-
sendMiniKitEvent({
|
|
1333
|
-
command: "share" /* Share */,
|
|
1334
|
-
version: _MiniKit.miniKitCommandVersion["share" /* Share */],
|
|
1335
|
-
payload: formattedResult
|
|
1336
|
-
});
|
|
1337
|
-
}).catch((error) => {
|
|
1338
|
-
console.error("Failed to format share input", error);
|
|
1339
|
-
});
|
|
1340
|
-
_MiniKit.subscribe("miniapp-share" /* MiniAppShare */, (payload2) => {
|
|
1341
|
-
console.log("Share Response", payload2);
|
|
1342
|
-
});
|
|
1343
1836
|
}
|
|
1344
|
-
return
|
|
1837
|
+
return this.asyncCommandsInstance;
|
|
1345
1838
|
}
|
|
1346
1839
|
};
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
_MiniKit.
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
resolve(response);
|
|
1386
|
-
} catch (error) {
|
|
1387
|
-
reject(error);
|
|
1388
|
-
}
|
|
1389
|
-
});
|
|
1390
|
-
},
|
|
1391
|
-
walletAuth: async (payload) => {
|
|
1392
|
-
return new Promise(async (resolve, reject) => {
|
|
1393
|
-
try {
|
|
1394
|
-
const response = await _MiniKit.awaitCommand(
|
|
1395
|
-
"miniapp-wallet-auth" /* MiniAppWalletAuth */,
|
|
1396
|
-
"wallet-auth" /* WalletAuth */,
|
|
1397
|
-
() => _MiniKit.commands.walletAuth(payload)
|
|
1398
|
-
);
|
|
1399
|
-
return resolve(response);
|
|
1400
|
-
} catch (error) {
|
|
1401
|
-
reject(error);
|
|
1402
|
-
}
|
|
1403
|
-
});
|
|
1404
|
-
},
|
|
1405
|
-
sendTransaction: async (payload) => {
|
|
1406
|
-
return new Promise(async (resolve, reject) => {
|
|
1407
|
-
try {
|
|
1408
|
-
const response = await _MiniKit.awaitCommand(
|
|
1409
|
-
"miniapp-send-transaction" /* MiniAppSendTransaction */,
|
|
1410
|
-
"send-transaction" /* SendTransaction */,
|
|
1411
|
-
() => _MiniKit.commands.sendTransaction(payload)
|
|
1412
|
-
);
|
|
1413
|
-
return resolve(response);
|
|
1414
|
-
} catch (error) {
|
|
1415
|
-
reject(error);
|
|
1416
|
-
}
|
|
1417
|
-
});
|
|
1418
|
-
},
|
|
1419
|
-
signMessage: async (payload) => {
|
|
1420
|
-
return new Promise(async (resolve, reject) => {
|
|
1421
|
-
try {
|
|
1422
|
-
const response = await _MiniKit.awaitCommand(
|
|
1423
|
-
"miniapp-sign-message" /* MiniAppSignMessage */,
|
|
1424
|
-
"sign-message" /* SignMessage */,
|
|
1425
|
-
() => _MiniKit.commands.signMessage(payload)
|
|
1426
|
-
);
|
|
1427
|
-
return resolve(response);
|
|
1428
|
-
} catch (error) {
|
|
1429
|
-
reject(error);
|
|
1430
|
-
}
|
|
1431
|
-
});
|
|
1432
|
-
},
|
|
1433
|
-
signTypedData: async (payload) => {
|
|
1434
|
-
return new Promise(async (resolve, reject) => {
|
|
1435
|
-
try {
|
|
1436
|
-
const response = await _MiniKit.awaitCommand(
|
|
1437
|
-
"miniapp-sign-typed-data" /* MiniAppSignTypedData */,
|
|
1438
|
-
"sign-typed-data" /* SignTypedData */,
|
|
1439
|
-
() => _MiniKit.commands.signTypedData(payload)
|
|
1440
|
-
);
|
|
1441
|
-
return resolve(response);
|
|
1442
|
-
} catch (error) {
|
|
1443
|
-
reject(error);
|
|
1444
|
-
}
|
|
1445
|
-
});
|
|
1446
|
-
},
|
|
1447
|
-
shareContacts: async (payload) => {
|
|
1448
|
-
return new Promise(async (resolve, reject) => {
|
|
1449
|
-
try {
|
|
1450
|
-
const response = await _MiniKit.awaitCommand(
|
|
1451
|
-
"miniapp-share-contacts" /* MiniAppShareContacts */,
|
|
1452
|
-
"share-contacts" /* ShareContacts */,
|
|
1453
|
-
() => _MiniKit.commands.shareContacts(payload)
|
|
1454
|
-
);
|
|
1455
|
-
return resolve(response);
|
|
1456
|
-
} catch (error) {
|
|
1457
|
-
reject(error);
|
|
1458
|
-
}
|
|
1459
|
-
});
|
|
1460
|
-
},
|
|
1461
|
-
requestPermission: async (payload) => {
|
|
1462
|
-
return new Promise(async (resolve, reject) => {
|
|
1463
|
-
try {
|
|
1464
|
-
const response = await _MiniKit.awaitCommand(
|
|
1465
|
-
"miniapp-request-permission" /* MiniAppRequestPermission */,
|
|
1466
|
-
"request-permission" /* RequestPermission */,
|
|
1467
|
-
() => _MiniKit.commands.requestPermission(payload)
|
|
1468
|
-
);
|
|
1469
|
-
resolve(response);
|
|
1470
|
-
} catch (error) {
|
|
1471
|
-
reject(error);
|
|
1472
|
-
}
|
|
1473
|
-
});
|
|
1474
|
-
},
|
|
1475
|
-
getPermissions: async () => {
|
|
1476
|
-
return new Promise(async (resolve, reject) => {
|
|
1477
|
-
try {
|
|
1478
|
-
const response = await _MiniKit.awaitCommand(
|
|
1479
|
-
"miniapp-get-permissions" /* MiniAppGetPermissions */,
|
|
1480
|
-
"get-permissions" /* GetPermissions */,
|
|
1481
|
-
() => _MiniKit.commands.getPermissions()
|
|
1482
|
-
);
|
|
1483
|
-
resolve(response);
|
|
1484
|
-
} catch (error) {
|
|
1485
|
-
reject(error);
|
|
1486
|
-
}
|
|
1487
|
-
});
|
|
1488
|
-
},
|
|
1489
|
-
sendHapticFeedback: async (payload) => {
|
|
1490
|
-
return new Promise(async (resolve, reject) => {
|
|
1491
|
-
try {
|
|
1492
|
-
const response = await _MiniKit.awaitCommand(
|
|
1493
|
-
"miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
|
|
1494
|
-
"send-haptic-feedback" /* SendHapticFeedback */,
|
|
1495
|
-
() => _MiniKit.commands.sendHapticFeedback(payload)
|
|
1496
|
-
);
|
|
1497
|
-
resolve(response);
|
|
1498
|
-
} catch (error) {
|
|
1499
|
-
reject(error);
|
|
1500
|
-
}
|
|
1501
|
-
});
|
|
1502
|
-
},
|
|
1503
|
-
share: async (payload) => {
|
|
1504
|
-
return new Promise(async (resolve, reject) => {
|
|
1505
|
-
try {
|
|
1506
|
-
const response = await _MiniKit.awaitCommand(
|
|
1507
|
-
"miniapp-share" /* MiniAppShare */,
|
|
1508
|
-
"share" /* Share */,
|
|
1509
|
-
() => _MiniKit.commands.share(payload)
|
|
1510
|
-
);
|
|
1511
|
-
resolve({
|
|
1512
|
-
commandPayload: response.commandPayload,
|
|
1513
|
-
finalPayload: response.finalPayload
|
|
1514
|
-
});
|
|
1515
|
-
} catch (error) {
|
|
1516
|
-
reject(error);
|
|
1517
|
-
}
|
|
1518
|
-
});
|
|
1840
|
+
_MiniKit.eventManager = new EventManager();
|
|
1841
|
+
_MiniKit.stateManager = new MiniKitState();
|
|
1842
|
+
_MiniKit.commandsInstance = null;
|
|
1843
|
+
_MiniKit.asyncCommandsInstance = null;
|
|
1844
|
+
// ============================================================================
|
|
1845
|
+
// Utility Methods
|
|
1846
|
+
// ============================================================================
|
|
1847
|
+
_MiniKit.getUserByAddress = async (address) => {
|
|
1848
|
+
return _MiniKit.stateManager.getUserByAddress(address);
|
|
1849
|
+
};
|
|
1850
|
+
_MiniKit.getUserByUsername = async (username) => {
|
|
1851
|
+
return _MiniKit.stateManager.getUserByUsername(username);
|
|
1852
|
+
};
|
|
1853
|
+
_MiniKit.getUserInfo = _MiniKit.getUserByAddress;
|
|
1854
|
+
_MiniKit.getMiniAppUrl = (appId, path) => {
|
|
1855
|
+
const baseUrl = new URL("https://world.org/mini-app");
|
|
1856
|
+
baseUrl.searchParams.append("app_id", appId);
|
|
1857
|
+
if (path) {
|
|
1858
|
+
const fullPath = path.startsWith("/") ? path : `/${path}`;
|
|
1859
|
+
baseUrl.searchParams.append("path", encodeURIComponent(fullPath));
|
|
1860
|
+
}
|
|
1861
|
+
return baseUrl.toString();
|
|
1862
|
+
};
|
|
1863
|
+
_MiniKit.showProfileCard = (username, walletAddress) => {
|
|
1864
|
+
if (!username && !walletAddress) {
|
|
1865
|
+
console.error(
|
|
1866
|
+
"Either username or walletAddress must be provided to show profile card"
|
|
1867
|
+
);
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
if (username) {
|
|
1871
|
+
window.open(
|
|
1872
|
+
`worldapp://profile?username=${encodeURIComponent(username)}`
|
|
1873
|
+
);
|
|
1874
|
+
} else {
|
|
1875
|
+
window.open(
|
|
1876
|
+
`worldapp://profile?address=${encodeURIComponent(walletAddress || "")}`
|
|
1877
|
+
);
|
|
1519
1878
|
}
|
|
1520
1879
|
};
|
|
1521
1880
|
var MiniKit = _MiniKit;
|
|
1522
1881
|
|
|
1523
1882
|
export {
|
|
1524
|
-
|
|
1883
|
+
Command,
|
|
1884
|
+
ResponseEvent,
|
|
1885
|
+
COMMAND_VERSIONS,
|
|
1886
|
+
isCommandAvailable,
|
|
1887
|
+
setCommandAvailable,
|
|
1888
|
+
validateCommands,
|
|
1889
|
+
sendMiniKitEvent,
|
|
1890
|
+
ChatErrorCodes,
|
|
1891
|
+
ChatErrorMessage,
|
|
1892
|
+
createChatCommand,
|
|
1893
|
+
createChatAsyncCommand,
|
|
1894
|
+
GetPermissionsErrorCodes,
|
|
1895
|
+
GetPermissionsErrorMessage,
|
|
1896
|
+
Permission,
|
|
1897
|
+
createGetPermissionsCommand,
|
|
1898
|
+
createGetPermissionsAsyncCommand,
|
|
1899
|
+
Tokens,
|
|
1900
|
+
TokenDecimals,
|
|
1901
|
+
Network,
|
|
1902
|
+
tokenToDecimals,
|
|
1525
1903
|
PaymentErrorCodes,
|
|
1526
1904
|
PaymentErrorMessage,
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
WalletAuthErrorMessage,
|
|
1530
|
-
SendTransactionErrorCodes,
|
|
1531
|
-
SendTransactionErrorMessage,
|
|
1532
|
-
SignMessageErrorCodes,
|
|
1533
|
-
SignMessageErrorMessage,
|
|
1534
|
-
SignTypedDataErrorCodes,
|
|
1535
|
-
SignTypedDataErrorMessage,
|
|
1536
|
-
MiniKitInstallErrorCodes,
|
|
1537
|
-
MiniKitInstallErrorMessage,
|
|
1538
|
-
ShareContactsErrorCodes,
|
|
1539
|
-
ShareContactsErrorMessage,
|
|
1905
|
+
createPayCommand,
|
|
1906
|
+
createPayAsyncCommand,
|
|
1540
1907
|
RequestPermissionErrorCodes,
|
|
1541
1908
|
RequestPermissionErrorMessage,
|
|
1542
|
-
|
|
1543
|
-
|
|
1909
|
+
createRequestPermissionCommand,
|
|
1910
|
+
createRequestPermissionAsyncCommand,
|
|
1544
1911
|
SendHapticFeedbackErrorCodes,
|
|
1545
1912
|
SendHapticFeedbackErrorMessage,
|
|
1913
|
+
createSendHapticFeedbackCommand,
|
|
1914
|
+
createSendHapticFeedbackAsyncCommand,
|
|
1915
|
+
SendTransactionErrorCodes,
|
|
1916
|
+
SendTransactionErrorMessage,
|
|
1917
|
+
createSendTransactionCommand,
|
|
1918
|
+
createSendTransactionAsyncCommand,
|
|
1546
1919
|
ShareFilesErrorCodes,
|
|
1547
1920
|
ShareFilesErrorMessage,
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1921
|
+
createShareCommand,
|
|
1922
|
+
createShareAsyncCommand,
|
|
1923
|
+
ShareContactsErrorCodes,
|
|
1924
|
+
ShareContactsErrorMessage,
|
|
1925
|
+
createShareContactsCommand,
|
|
1926
|
+
createShareContactsAsyncCommand,
|
|
1927
|
+
SignMessageErrorCodes,
|
|
1928
|
+
SignMessageErrorMessage,
|
|
1929
|
+
createSignMessageCommand,
|
|
1930
|
+
createSignMessageAsyncCommand,
|
|
1931
|
+
SignTypedDataErrorCodes,
|
|
1932
|
+
SignTypedDataErrorMessage,
|
|
1933
|
+
createSignTypedDataCommand,
|
|
1934
|
+
createSignTypedDataAsyncCommand,
|
|
1935
|
+
createVerifyCommand,
|
|
1936
|
+
createVerifyAsyncCommand,
|
|
1937
|
+
AppErrorCodes,
|
|
1556
1938
|
parseSiweMessage,
|
|
1557
1939
|
verifySiweMessage,
|
|
1558
|
-
|
|
1559
|
-
|
|
1940
|
+
WalletAuthErrorCodes,
|
|
1941
|
+
WalletAuthErrorMessage,
|
|
1942
|
+
createWalletAuthCommand,
|
|
1943
|
+
createWalletAuthAsyncCommand,
|
|
1944
|
+
createCommands,
|
|
1945
|
+
createAsyncCommands,
|
|
1946
|
+
MiniAppLaunchLocation,
|
|
1947
|
+
mapWorldAppLaunchLocation,
|
|
1948
|
+
MiniKitInstallErrorCodes,
|
|
1949
|
+
MiniKitInstallErrorMessage,
|
|
1560
1950
|
MiniKit
|
|
1561
1951
|
};
|