@worldcoin/minikit-js 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.cjs +380 -225
- package/build/index.d.cts +129 -73
- package/build/index.d.ts +129 -73
- package/build/index.js +380 -228
- package/index.ts +13 -17
- package/package.json +39 -34
package/build/index.cjs
CHANGED
|
@@ -28,6 +28,9 @@ __export(core_exports, {
|
|
|
28
28
|
PaymentErrorCodes: () => PaymentErrorCodes,
|
|
29
29
|
PaymentErrorMessage: () => PaymentErrorMessage,
|
|
30
30
|
PaymentValidationErrors: () => PaymentValidationErrors,
|
|
31
|
+
Permission: () => Permission,
|
|
32
|
+
RequestPermissionErrorCodes: () => RequestPermissionErrorCodes,
|
|
33
|
+
RequestPermissionErrorMessage: () => RequestPermissionErrorMessage,
|
|
31
34
|
ResponseEvent: () => ResponseEvent,
|
|
32
35
|
SAFE_CONTRACT_ABI: () => SAFE_CONTRACT_ABI,
|
|
33
36
|
SendTransactionErrorCodes: () => SendTransactionErrorCodes,
|
|
@@ -45,6 +48,7 @@ __export(core_exports, {
|
|
|
45
48
|
VerificationLevel: () => import_idkit_core4.VerificationLevel,
|
|
46
49
|
WalletAuthErrorCodes: () => WalletAuthErrorCodes,
|
|
47
50
|
WalletAuthErrorMessage: () => WalletAuthErrorMessage,
|
|
51
|
+
getIsUserVerified: () => getIsUserVerified,
|
|
48
52
|
parseSiweMessage: () => parseSiweMessage,
|
|
49
53
|
tokenToDecimals: () => tokenToDecimals,
|
|
50
54
|
verifyCloudProof: () => import_backend.verifyCloudProof,
|
|
@@ -52,44 +56,15 @@ __export(core_exports, {
|
|
|
52
56
|
});
|
|
53
57
|
module.exports = __toCommonJS(core_exports);
|
|
54
58
|
|
|
55
|
-
//
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
|
|
59
|
-
} else if (window.Android) {
|
|
60
|
-
window.Android.postMessage?.(JSON.stringify(payload));
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// types/commands.ts
|
|
65
|
-
var Command = /* @__PURE__ */ ((Command2) => {
|
|
66
|
-
Command2["Verify"] = "verify";
|
|
67
|
-
Command2["Pay"] = "pay";
|
|
68
|
-
Command2["WalletAuth"] = "wallet-auth";
|
|
69
|
-
Command2["SendTransaction"] = "send-transaction";
|
|
70
|
-
Command2["SignMessage"] = "sign-message";
|
|
71
|
-
Command2["SignTypedData"] = "sign-typed-data";
|
|
72
|
-
Command2["ShareContacts"] = "share-contacts";
|
|
73
|
-
return Command2;
|
|
74
|
-
})(Command || {});
|
|
75
|
-
|
|
76
|
-
// types/responses.ts
|
|
77
|
-
var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
78
|
-
ResponseEvent2["MiniAppVerifyAction"] = "miniapp-verify-action";
|
|
79
|
-
ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
|
|
80
|
-
ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
|
|
81
|
-
ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
|
|
82
|
-
ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
|
|
83
|
-
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
84
|
-
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
85
|
-
return ResponseEvent2;
|
|
86
|
-
})(ResponseEvent || {});
|
|
59
|
+
// minikit.ts
|
|
60
|
+
var import_idkit_core3 = require("@worldcoin/idkit-core");
|
|
61
|
+
var import_hashing = require("@worldcoin/idkit-core/hashing");
|
|
87
62
|
|
|
88
63
|
// types/payment.ts
|
|
89
|
-
var Tokens = /* @__PURE__ */ ((
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return
|
|
64
|
+
var Tokens = /* @__PURE__ */ ((Tokens3) => {
|
|
65
|
+
Tokens3["USDCE"] = "USDCE";
|
|
66
|
+
Tokens3["WLD"] = "WLD";
|
|
67
|
+
return Tokens3;
|
|
93
68
|
})(Tokens || {});
|
|
94
69
|
var TokenDecimals = {
|
|
95
70
|
["USDCE" /* USDCE */]: 6,
|
|
@@ -101,155 +76,31 @@ var Network = /* @__PURE__ */ ((Network2) => {
|
|
|
101
76
|
return Network2;
|
|
102
77
|
})(Network || {});
|
|
103
78
|
|
|
104
|
-
//
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
[import_idkit_core.AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
110
|
-
[import_idkit_core.AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
111
|
-
[import_idkit_core.AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
112
|
-
[import_idkit_core.AppErrorCodes.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
|
|
113
|
-
[import_idkit_core.AppErrorCodes.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
|
|
114
|
-
[import_idkit_core.AppErrorCodes.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
|
|
115
|
-
[import_idkit_core.AppErrorCodes.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
|
|
116
|
-
[import_idkit_core.AppErrorCodes.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
|
|
117
|
-
[import_idkit_core.AppErrorCodes.GenericError]: "Something unexpected went wrong. Please try again.",
|
|
118
|
-
[import_idkit_core.AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
|
|
119
|
-
};
|
|
120
|
-
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
121
|
-
PaymentErrorCodes2["InputError"] = "input_error";
|
|
122
|
-
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
123
|
-
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
124
|
-
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
125
|
-
PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
126
|
-
PaymentErrorCodes2["GenericError"] = "generic_error";
|
|
127
|
-
PaymentErrorCodes2["UserBlocked"] = "user_blocked";
|
|
128
|
-
return PaymentErrorCodes2;
|
|
129
|
-
})(PaymentErrorCodes || {});
|
|
130
|
-
var PaymentErrorMessage = {
|
|
131
|
-
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
132
|
-
["payment_rejected" /* PaymentRejected */]: "You\u2019ve cancelled the payment in World App.",
|
|
133
|
-
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
134
|
-
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
135
|
-
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
136
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
137
|
-
["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
|
|
138
|
-
};
|
|
139
|
-
var PaymentValidationErrors = /* @__PURE__ */ ((PaymentValidationErrors2) => {
|
|
140
|
-
PaymentValidationErrors2["MalformedRequest"] = "There was a problem with this request. Please try again or contact the app owner.";
|
|
141
|
-
PaymentValidationErrors2["InvalidTokenAddress"] = "The token address is invalid. Please contact the app owner.";
|
|
142
|
-
PaymentValidationErrors2["InvalidAppId"] = "The app ID is invalid. Please contact the app owner.";
|
|
143
|
-
PaymentValidationErrors2["DuplicateReference"] = "This reference ID already exists please generate a new one and try again.";
|
|
144
|
-
return PaymentValidationErrors2;
|
|
145
|
-
})(PaymentValidationErrors || {});
|
|
146
|
-
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
147
|
-
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
148
|
-
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
149
|
-
WalletAuthErrorCodes2["GenericError"] = "generic_error";
|
|
150
|
-
return WalletAuthErrorCodes2;
|
|
151
|
-
})(WalletAuthErrorCodes || {});
|
|
152
|
-
var WalletAuthErrorMessage = {
|
|
153
|
-
["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
|
|
154
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
155
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
156
|
-
};
|
|
157
|
-
var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
|
|
158
|
-
SendTransactionErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
159
|
-
SendTransactionErrorCodes2["UserRejected"] = "user_rejected";
|
|
160
|
-
SendTransactionErrorCodes2["InputError"] = "input_error";
|
|
161
|
-
SendTransactionErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
162
|
-
SendTransactionErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
163
|
-
SendTransactionErrorCodes2["GenericError"] = "generic_error";
|
|
164
|
-
SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
165
|
-
SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
166
|
-
SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
167
|
-
return SendTransactionErrorCodes2;
|
|
168
|
-
})(SendTransactionErrorCodes || {});
|
|
169
|
-
var SendTransactionErrorMessage = {
|
|
170
|
-
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
171
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
172
|
-
["input_error" /* InputError */]: "Invalid payload.",
|
|
173
|
-
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
174
|
-
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again later.",
|
|
175
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
176
|
-
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
177
|
-
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
178
|
-
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
179
|
-
};
|
|
180
|
-
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
181
|
-
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
182
|
-
SignMessageErrorCodes2["UserRejected"] = "user_rejected";
|
|
183
|
-
SignMessageErrorCodes2["GenericError"] = "generic_error";
|
|
184
|
-
return SignMessageErrorCodes2;
|
|
185
|
-
})(SignMessageErrorCodes || {});
|
|
186
|
-
var SignMessageErrorMessage = {
|
|
187
|
-
["invalid_message" /* InvalidMessage */]: "Invalid message requested",
|
|
188
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
189
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
190
|
-
};
|
|
191
|
-
var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
192
|
-
SignTypedDataErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
193
|
-
SignTypedDataErrorCodes2["UserRejected"] = "user_rejected";
|
|
194
|
-
SignTypedDataErrorCodes2["InputError"] = "input_error";
|
|
195
|
-
SignTypedDataErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
196
|
-
SignTypedDataErrorCodes2["GenericError"] = "generic_error";
|
|
197
|
-
SignTypedDataErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
198
|
-
SignTypedDataErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
199
|
-
SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
200
|
-
return SignTypedDataErrorCodes2;
|
|
201
|
-
})(SignTypedDataErrorCodes || {});
|
|
202
|
-
var SignTypedDataErrorMessage = SendTransactionErrorMessage;
|
|
203
|
-
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
204
|
-
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
205
|
-
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
206
|
-
MiniKitInstallErrorCodes2["OutsideOfWorldApp"] = "outside_of_worldapp";
|
|
207
|
-
MiniKitInstallErrorCodes2["NotOnClient"] = "not_on_client";
|
|
208
|
-
MiniKitInstallErrorCodes2["AppOutOfDate"] = "app_out_of_date";
|
|
209
|
-
return MiniKitInstallErrorCodes2;
|
|
210
|
-
})(MiniKitInstallErrorCodes || {});
|
|
211
|
-
var MiniKitInstallErrorMessage = {
|
|
212
|
-
["unknown" /* Unknown */]: "Failed to install MiniKit.",
|
|
213
|
-
["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
|
|
214
|
-
["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
|
|
215
|
-
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
216
|
-
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
217
|
-
};
|
|
218
|
-
var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
|
|
219
|
-
ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
|
|
220
|
-
ShareContactsErrorCodes2["GenericError"] = "generic_error";
|
|
221
|
-
return ShareContactsErrorCodes2;
|
|
222
|
-
})(ShareContactsErrorCodes || {});
|
|
223
|
-
var ShareContactsErrorMessage = {
|
|
224
|
-
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
225
|
-
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
// minikit.ts
|
|
229
|
-
var import_idkit_core3 = require("@worldcoin/idkit-core");
|
|
230
|
-
var import_hashing = require("@worldcoin/idkit-core/hashing");
|
|
231
|
-
|
|
232
|
-
// helpers/siwe/validate-wallet-auth-command-input.ts
|
|
233
|
-
var validateWalletAuthCommandInput = (params) => {
|
|
234
|
-
if (!params.nonce) {
|
|
235
|
-
return { valid: false, message: "'nonce' is required" };
|
|
236
|
-
}
|
|
237
|
-
if (params.nonce.length < 8) {
|
|
238
|
-
return { valid: false, message: "'nonce' must be at least 8 characters" };
|
|
239
|
-
}
|
|
240
|
-
if (params.statement && params.statement.includes("\n")) {
|
|
241
|
-
return { valid: false, message: "'statement' must not contain newlines" };
|
|
79
|
+
// helpers/payment/client.ts
|
|
80
|
+
var tokenToDecimals = (amount, token) => {
|
|
81
|
+
const decimals = TokenDecimals[token];
|
|
82
|
+
if (decimals === void 0) {
|
|
83
|
+
throw new Error(`Invalid token: ${token}`);
|
|
242
84
|
}
|
|
243
|
-
|
|
244
|
-
|
|
85
|
+
const factor = 10 ** decimals;
|
|
86
|
+
const result = amount * factor;
|
|
87
|
+
if (!Number.isInteger(result)) {
|
|
88
|
+
throw new Error(`The resulting amount is not a whole number: ${result}`);
|
|
245
89
|
}
|
|
246
|
-
|
|
247
|
-
|
|
90
|
+
return result;
|
|
91
|
+
};
|
|
92
|
+
var validatePaymentPayload = (payload) => {
|
|
93
|
+
if (payload.tokens.some(
|
|
94
|
+
(token) => token.symbol == "USDCE" && parseFloat(token.token_amount) < 0.1
|
|
95
|
+
)) {
|
|
96
|
+
console.error("USDCE amount should be greater than $0.1");
|
|
97
|
+
return false;
|
|
248
98
|
}
|
|
249
|
-
if (
|
|
250
|
-
|
|
99
|
+
if (payload.reference.length > 36) {
|
|
100
|
+
console.error("Reference must not exceed 36 characters");
|
|
101
|
+
return false;
|
|
251
102
|
}
|
|
252
|
-
return
|
|
103
|
+
return true;
|
|
253
104
|
};
|
|
254
105
|
|
|
255
106
|
// helpers/siwe/siwe.ts
|
|
@@ -363,15 +214,23 @@ var generateSiweMessage = (siweMessageData) => {
|
|
|
363
214
|
};
|
|
364
215
|
var SAFE_CONTRACT_ABI = [
|
|
365
216
|
{
|
|
366
|
-
name: "checkSignatures",
|
|
367
|
-
type: "function",
|
|
368
|
-
stateMutability: "view",
|
|
369
217
|
inputs: [
|
|
370
|
-
{
|
|
371
|
-
|
|
372
|
-
|
|
218
|
+
{
|
|
219
|
+
internalType: "address",
|
|
220
|
+
name: "owner",
|
|
221
|
+
type: "address"
|
|
222
|
+
}
|
|
373
223
|
],
|
|
374
|
-
|
|
224
|
+
name: "isOwner",
|
|
225
|
+
outputs: [
|
|
226
|
+
{
|
|
227
|
+
internalType: "bool",
|
|
228
|
+
name: "",
|
|
229
|
+
type: "bool"
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
stateMutability: "view",
|
|
233
|
+
type: "function"
|
|
375
234
|
}
|
|
376
235
|
];
|
|
377
236
|
var verifySiweMessage = async (payload, nonce, statement, requestId, userProvider) => {
|
|
@@ -407,9 +266,8 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
|
|
|
407
266
|
`Request ID mismatch. Got: ${siweMessageData.request_id}, Expected: ${requestId}`
|
|
408
267
|
);
|
|
409
268
|
}
|
|
410
|
-
let provider = userProvider || (0, import_viem.createPublicClient)({ chain: import_chains.
|
|
269
|
+
let provider = userProvider || (0, import_viem.createPublicClient)({ chain: import_chains.worldchain, transport: (0, import_viem.http)() });
|
|
411
270
|
const signedMessage = `${ERC_191_PREFIX}${message.length}${message}`;
|
|
412
|
-
const messageBytes = Buffer.from(signedMessage, "utf8").toString("hex");
|
|
413
271
|
const hashedMessage = (0, import_viem.hashMessage)(signedMessage);
|
|
414
272
|
const contract = (0, import_viem.getContract)({
|
|
415
273
|
address,
|
|
@@ -417,43 +275,59 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
|
|
|
417
275
|
client: provider
|
|
418
276
|
});
|
|
419
277
|
try {
|
|
420
|
-
await
|
|
421
|
-
hashedMessage,
|
|
422
|
-
`0x${
|
|
423
|
-
|
|
424
|
-
]);
|
|
278
|
+
const recoveredAddress = await (0, import_viem.recoverAddress)({
|
|
279
|
+
hash: hashedMessage,
|
|
280
|
+
signature: `0x${signature}`
|
|
281
|
+
});
|
|
282
|
+
const isOwner = await contract.read.isOwner([recoveredAddress]);
|
|
283
|
+
if (!isOwner) {
|
|
284
|
+
throw new Error("Signature verification failed, invalid owner");
|
|
285
|
+
}
|
|
425
286
|
} catch (error) {
|
|
426
287
|
throw new Error("Signature verification failed");
|
|
427
288
|
}
|
|
428
289
|
return { isValid: true, siweMessageData };
|
|
429
290
|
};
|
|
430
291
|
|
|
431
|
-
// helpers/
|
|
432
|
-
var
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
throw new Error(`Invalid token: ${token}`);
|
|
292
|
+
// helpers/siwe/validate-wallet-auth-command-input.ts
|
|
293
|
+
var validateWalletAuthCommandInput = (params) => {
|
|
294
|
+
if (!params.nonce) {
|
|
295
|
+
return { valid: false, message: "'nonce' is required" };
|
|
436
296
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (!Number.isInteger(result)) {
|
|
440
|
-
throw new Error(`The resulting amount is not a whole number: ${result}`);
|
|
297
|
+
if (params.nonce.length < 8) {
|
|
298
|
+
return { valid: false, message: "'nonce' must be at least 8 characters" };
|
|
441
299
|
}
|
|
442
|
-
|
|
300
|
+
if (params.statement && params.statement.includes("\n")) {
|
|
301
|
+
return { valid: false, message: "'statement' must not contain newlines" };
|
|
302
|
+
}
|
|
303
|
+
if (params.expirationTime && new Date(params.expirationTime) < /* @__PURE__ */ new Date()) {
|
|
304
|
+
return { valid: false, message: "'expirationTime' must be in the future" };
|
|
305
|
+
}
|
|
306
|
+
if (params.expirationTime && new Date(params.expirationTime) > new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3)) {
|
|
307
|
+
return { valid: false, message: "'expirationTime' must be within 7 days" };
|
|
308
|
+
}
|
|
309
|
+
if (params.notBefore && new Date(params.notBefore) > new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3)) {
|
|
310
|
+
return { valid: false, message: "'notBefore' must be within 7 days" };
|
|
311
|
+
}
|
|
312
|
+
return { valid: true };
|
|
443
313
|
};
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
)
|
|
448
|
-
|
|
449
|
-
|
|
314
|
+
|
|
315
|
+
// helpers/transaction/validate-payload.ts
|
|
316
|
+
var validate = (payload) => {
|
|
317
|
+
if (typeof payload === "string") return { isValid: true };
|
|
318
|
+
if (typeof payload === "object") {
|
|
319
|
+
const isValid = Object.values(payload).every(
|
|
320
|
+
(value) => validate(value).isValid
|
|
321
|
+
);
|
|
322
|
+
return { isValid };
|
|
450
323
|
}
|
|
451
|
-
if (payload
|
|
452
|
-
|
|
453
|
-
return
|
|
324
|
+
if (Array.isArray(payload)) {
|
|
325
|
+
const isValid = payload.every((value) => validate(value).isValid);
|
|
326
|
+
return { isValid };
|
|
454
327
|
}
|
|
455
|
-
return
|
|
328
|
+
return { isValid: false };
|
|
456
329
|
};
|
|
330
|
+
var validateSendTransactionPayload = (payload) => validate(payload);
|
|
457
331
|
|
|
458
332
|
// helpers/usernames/index.ts
|
|
459
333
|
var getUserProfile = async (address) => {
|
|
@@ -467,9 +341,189 @@ var getUserProfile = async (address) => {
|
|
|
467
341
|
})
|
|
468
342
|
});
|
|
469
343
|
const usernames = await res.json();
|
|
470
|
-
return usernames[0] ?? { username: null, profilePictureUrl: null };
|
|
344
|
+
return usernames?.[0] ?? { username: null, profilePictureUrl: null };
|
|
471
345
|
};
|
|
472
346
|
|
|
347
|
+
// types/commands.ts
|
|
348
|
+
var Command = /* @__PURE__ */ ((Command2) => {
|
|
349
|
+
Command2["Verify"] = "verify";
|
|
350
|
+
Command2["Pay"] = "pay";
|
|
351
|
+
Command2["WalletAuth"] = "wallet-auth";
|
|
352
|
+
Command2["SendTransaction"] = "send-transaction";
|
|
353
|
+
Command2["SignMessage"] = "sign-message";
|
|
354
|
+
Command2["SignTypedData"] = "sign-typed-data";
|
|
355
|
+
Command2["ShareContacts"] = "share-contacts";
|
|
356
|
+
Command2["RequestPermission"] = "request-permission";
|
|
357
|
+
return Command2;
|
|
358
|
+
})(Command || {});
|
|
359
|
+
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
360
|
+
Permission2["Notifications"] = "notifications";
|
|
361
|
+
return Permission2;
|
|
362
|
+
})(Permission || {});
|
|
363
|
+
|
|
364
|
+
// types/errors.ts
|
|
365
|
+
var import_idkit_core = require("@worldcoin/idkit-core");
|
|
366
|
+
var import_idkit_core2 = require("@worldcoin/idkit-core");
|
|
367
|
+
var VerificationErrorMessage = {
|
|
368
|
+
[import_idkit_core.AppErrorCodes.VerificationRejected]: "You\u2019ve cancelled the request in World App.",
|
|
369
|
+
[import_idkit_core.AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
370
|
+
[import_idkit_core.AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
371
|
+
[import_idkit_core.AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
372
|
+
[import_idkit_core.AppErrorCodes.InvalidNetwork]: "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details.",
|
|
373
|
+
[import_idkit_core.AppErrorCodes.InclusionProofFailed]: "There was an issue fetching your credential. Please try again.",
|
|
374
|
+
[import_idkit_core.AppErrorCodes.InclusionProofPending]: "Your identity is still being registered. Please wait a few minutes and try again.",
|
|
375
|
+
[import_idkit_core.AppErrorCodes.UnexpectedResponse]: "Unexpected response from your wallet. Please try again.",
|
|
376
|
+
[import_idkit_core.AppErrorCodes.FailedByHostApp]: "Verification failed by the app. Please contact the app owner for details.",
|
|
377
|
+
[import_idkit_core.AppErrorCodes.GenericError]: "Something unexpected went wrong. Please try again.",
|
|
378
|
+
[import_idkit_core.AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
|
|
379
|
+
};
|
|
380
|
+
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
381
|
+
PaymentErrorCodes2["InputError"] = "input_error";
|
|
382
|
+
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
383
|
+
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
384
|
+
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
385
|
+
PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
386
|
+
PaymentErrorCodes2["GenericError"] = "generic_error";
|
|
387
|
+
PaymentErrorCodes2["UserBlocked"] = "user_blocked";
|
|
388
|
+
return PaymentErrorCodes2;
|
|
389
|
+
})(PaymentErrorCodes || {});
|
|
390
|
+
var PaymentErrorMessage = {
|
|
391
|
+
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
392
|
+
["payment_rejected" /* PaymentRejected */]: "You\u2019ve cancelled the payment in World App.",
|
|
393
|
+
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
394
|
+
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
395
|
+
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
396
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
397
|
+
["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
|
|
398
|
+
};
|
|
399
|
+
var PaymentValidationErrors = /* @__PURE__ */ ((PaymentValidationErrors2) => {
|
|
400
|
+
PaymentValidationErrors2["MalformedRequest"] = "There was a problem with this request. Please try again or contact the app owner.";
|
|
401
|
+
PaymentValidationErrors2["InvalidTokenAddress"] = "The token address is invalid. Please contact the app owner.";
|
|
402
|
+
PaymentValidationErrors2["InvalidAppId"] = "The app ID is invalid. Please contact the app owner.";
|
|
403
|
+
PaymentValidationErrors2["DuplicateReference"] = "This reference ID already exists please generate a new one and try again.";
|
|
404
|
+
return PaymentValidationErrors2;
|
|
405
|
+
})(PaymentValidationErrors || {});
|
|
406
|
+
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
407
|
+
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
408
|
+
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
409
|
+
WalletAuthErrorCodes2["GenericError"] = "generic_error";
|
|
410
|
+
return WalletAuthErrorCodes2;
|
|
411
|
+
})(WalletAuthErrorCodes || {});
|
|
412
|
+
var WalletAuthErrorMessage = {
|
|
413
|
+
["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
|
|
414
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
415
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
416
|
+
};
|
|
417
|
+
var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) => {
|
|
418
|
+
SendTransactionErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
419
|
+
SendTransactionErrorCodes2["UserRejected"] = "user_rejected";
|
|
420
|
+
SendTransactionErrorCodes2["InputError"] = "input_error";
|
|
421
|
+
SendTransactionErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
422
|
+
SendTransactionErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
423
|
+
SendTransactionErrorCodes2["GenericError"] = "generic_error";
|
|
424
|
+
SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
425
|
+
SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
426
|
+
SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
427
|
+
return SendTransactionErrorCodes2;
|
|
428
|
+
})(SendTransactionErrorCodes || {});
|
|
429
|
+
var SendTransactionErrorMessage = {
|
|
430
|
+
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
431
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
432
|
+
["input_error" /* InputError */]: "Invalid payload.",
|
|
433
|
+
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
434
|
+
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again later.",
|
|
435
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
436
|
+
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
437
|
+
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
438
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
439
|
+
};
|
|
440
|
+
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
441
|
+
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
442
|
+
SignMessageErrorCodes2["UserRejected"] = "user_rejected";
|
|
443
|
+
SignMessageErrorCodes2["GenericError"] = "generic_error";
|
|
444
|
+
return SignMessageErrorCodes2;
|
|
445
|
+
})(SignMessageErrorCodes || {});
|
|
446
|
+
var SignMessageErrorMessage = {
|
|
447
|
+
["invalid_message" /* InvalidMessage */]: "Invalid message requested",
|
|
448
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
449
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
450
|
+
};
|
|
451
|
+
var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
452
|
+
SignTypedDataErrorCodes2["InvalidOperation"] = "invalid_operation";
|
|
453
|
+
SignTypedDataErrorCodes2["UserRejected"] = "user_rejected";
|
|
454
|
+
SignTypedDataErrorCodes2["InputError"] = "input_error";
|
|
455
|
+
SignTypedDataErrorCodes2["SimulationFailed"] = "simulation_failed";
|
|
456
|
+
SignTypedDataErrorCodes2["GenericError"] = "generic_error";
|
|
457
|
+
SignTypedDataErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
458
|
+
SignTypedDataErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
459
|
+
SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
460
|
+
return SignTypedDataErrorCodes2;
|
|
461
|
+
})(SignTypedDataErrorCodes || {});
|
|
462
|
+
var SignTypedDataErrorMessage = SendTransactionErrorMessage;
|
|
463
|
+
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
464
|
+
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
465
|
+
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
466
|
+
MiniKitInstallErrorCodes2["OutsideOfWorldApp"] = "outside_of_worldapp";
|
|
467
|
+
MiniKitInstallErrorCodes2["NotOnClient"] = "not_on_client";
|
|
468
|
+
MiniKitInstallErrorCodes2["AppOutOfDate"] = "app_out_of_date";
|
|
469
|
+
return MiniKitInstallErrorCodes2;
|
|
470
|
+
})(MiniKitInstallErrorCodes || {});
|
|
471
|
+
var MiniKitInstallErrorMessage = {
|
|
472
|
+
["unknown" /* Unknown */]: "Failed to install MiniKit.",
|
|
473
|
+
["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
|
|
474
|
+
["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
|
|
475
|
+
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
476
|
+
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
477
|
+
};
|
|
478
|
+
var ShareContactsErrorCodes = /* @__PURE__ */ ((ShareContactsErrorCodes2) => {
|
|
479
|
+
ShareContactsErrorCodes2["UserRejected"] = "user_rejected";
|
|
480
|
+
ShareContactsErrorCodes2["GenericError"] = "generic_error";
|
|
481
|
+
return ShareContactsErrorCodes2;
|
|
482
|
+
})(ShareContactsErrorCodes || {});
|
|
483
|
+
var ShareContactsErrorMessage = {
|
|
484
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
485
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
486
|
+
};
|
|
487
|
+
var RequestPermissionErrorCodes = /* @__PURE__ */ ((RequestPermissionErrorCodes2) => {
|
|
488
|
+
RequestPermissionErrorCodes2["UserRejected"] = "user_rejected";
|
|
489
|
+
RequestPermissionErrorCodes2["GenericError"] = "generic_error";
|
|
490
|
+
RequestPermissionErrorCodes2["AlreadyRequested"] = "already_requested";
|
|
491
|
+
RequestPermissionErrorCodes2["PermissionDisabled"] = "permission_disabled";
|
|
492
|
+
RequestPermissionErrorCodes2["AlreadyGranted"] = "already_granted";
|
|
493
|
+
RequestPermissionErrorCodes2["UnsupportedPermission"] = "unsupported_permission";
|
|
494
|
+
return RequestPermissionErrorCodes2;
|
|
495
|
+
})(RequestPermissionErrorCodes || {});
|
|
496
|
+
var RequestPermissionErrorMessage = {
|
|
497
|
+
["user_rejected" /* UserRejected */]: "User declined sharing contacts",
|
|
498
|
+
["generic_error" /* GenericError */]: "Request failed for unknown reason.",
|
|
499
|
+
["already_requested" /* AlreadyRequested */]: "User has already declined turning on notifications once",
|
|
500
|
+
["permission_disabled" /* PermissionDisabled */]: "User does not have this permission enabled in World App",
|
|
501
|
+
["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
|
|
502
|
+
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
// helpers/send-webview-event.ts
|
|
506
|
+
var sendWebviewEvent = (payload) => {
|
|
507
|
+
if (window.webkit) {
|
|
508
|
+
window.webkit?.messageHandlers?.minikit?.postMessage?.(payload);
|
|
509
|
+
} else if (window.Android) {
|
|
510
|
+
window.Android.postMessage?.(JSON.stringify(payload));
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
// types/responses.ts
|
|
515
|
+
var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
516
|
+
ResponseEvent2["MiniAppVerifyAction"] = "miniapp-verify-action";
|
|
517
|
+
ResponseEvent2["MiniAppPayment"] = "miniapp-payment";
|
|
518
|
+
ResponseEvent2["MiniAppWalletAuth"] = "miniapp-wallet-auth";
|
|
519
|
+
ResponseEvent2["MiniAppSendTransaction"] = "miniapp-send-transaction";
|
|
520
|
+
ResponseEvent2["MiniAppSignMessage"] = "miniapp-sign-message";
|
|
521
|
+
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
522
|
+
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
523
|
+
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
524
|
+
return ResponseEvent2;
|
|
525
|
+
})(ResponseEvent || {});
|
|
526
|
+
|
|
473
527
|
// minikit.ts
|
|
474
528
|
var sendMiniKitEvent = (payload) => {
|
|
475
529
|
sendWebviewEvent(payload);
|
|
@@ -487,12 +541,8 @@ var _MiniKit = class _MiniKit {
|
|
|
487
541
|
const wrappedHandler = (payload) => {
|
|
488
542
|
if (payload.status === "success") {
|
|
489
543
|
_MiniKit.walletAddress = payload.address;
|
|
490
|
-
|
|
491
|
-
_MiniKit.user =
|
|
492
|
-
username: queryResponse.username,
|
|
493
|
-
profilePictureUrl: queryResponse.profilePictureUrl,
|
|
494
|
-
walletAddress: payload.address
|
|
495
|
-
};
|
|
544
|
+
_MiniKit.getUserByAddress(payload.address).then((user) => {
|
|
545
|
+
_MiniKit.user = user;
|
|
496
546
|
});
|
|
497
547
|
}
|
|
498
548
|
originalHandler(payload);
|
|
@@ -601,7 +651,8 @@ _MiniKit.commandVersion = {
|
|
|
601
651
|
["send-transaction" /* SendTransaction */]: 1,
|
|
602
652
|
["sign-message" /* SignMessage */]: 1,
|
|
603
653
|
["sign-typed-data" /* SignTypedData */]: 1,
|
|
604
|
-
["share-contacts" /* ShareContacts */]: 1
|
|
654
|
+
["share-contacts" /* ShareContacts */]: 1,
|
|
655
|
+
["request-permission" /* RequestPermission */]: 1
|
|
605
656
|
};
|
|
606
657
|
_MiniKit.isCommandAvailable = {
|
|
607
658
|
["verify" /* Verify */]: false,
|
|
@@ -610,7 +661,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
610
661
|
["send-transaction" /* SendTransaction */]: false,
|
|
611
662
|
["sign-message" /* SignMessage */]: false,
|
|
612
663
|
["sign-typed-data" /* SignTypedData */]: false,
|
|
613
|
-
["share-contacts" /* ShareContacts */]: false
|
|
664
|
+
["share-contacts" /* ShareContacts */]: false,
|
|
665
|
+
["request-permission" /* RequestPermission */]: false
|
|
614
666
|
};
|
|
615
667
|
_MiniKit.listeners = {
|
|
616
668
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -626,11 +678,24 @@ _MiniKit.listeners = {
|
|
|
626
678
|
["miniapp-sign-typed-data" /* MiniAppSignTypedData */]: () => {
|
|
627
679
|
},
|
|
628
680
|
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
681
|
+
},
|
|
682
|
+
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
629
683
|
}
|
|
630
684
|
};
|
|
631
685
|
_MiniKit.appId = null;
|
|
686
|
+
/**
|
|
687
|
+
* @deprecated you should use MiniKit.user.walletAddress instead
|
|
688
|
+
*/
|
|
632
689
|
_MiniKit.walletAddress = null;
|
|
633
690
|
_MiniKit.user = null;
|
|
691
|
+
_MiniKit.getUserByAddress = async (address) => {
|
|
692
|
+
const userProfile = await getUserProfile(address);
|
|
693
|
+
return {
|
|
694
|
+
walletAddress: address,
|
|
695
|
+
username: userProfile.username,
|
|
696
|
+
profilePictureUrl: userProfile.profilePictureUrl
|
|
697
|
+
};
|
|
698
|
+
};
|
|
634
699
|
_MiniKit.commands = {
|
|
635
700
|
verify: (payload) => {
|
|
636
701
|
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["verify" /* Verify */]) {
|
|
@@ -704,7 +769,7 @@ _MiniKit.commands = {
|
|
|
704
769
|
statement: payload.statement ?? void 0,
|
|
705
770
|
uri: window.location.href,
|
|
706
771
|
version: 1,
|
|
707
|
-
chain_id:
|
|
772
|
+
chain_id: 480,
|
|
708
773
|
nonce: payload.nonce,
|
|
709
774
|
issued_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
710
775
|
expiration_time: payload.expirationTime?.toISOString() ?? void 0,
|
|
@@ -726,6 +791,12 @@ _MiniKit.commands = {
|
|
|
726
791
|
);
|
|
727
792
|
return null;
|
|
728
793
|
}
|
|
794
|
+
if (!validateSendTransactionPayload(payload).isValid) {
|
|
795
|
+
console.error(
|
|
796
|
+
"Invalid sendTransaction payload - some object properties are not strings"
|
|
797
|
+
);
|
|
798
|
+
return null;
|
|
799
|
+
}
|
|
729
800
|
sendMiniKitEvent({
|
|
730
801
|
command: "send-transaction" /* SendTransaction */,
|
|
731
802
|
version: 1,
|
|
@@ -774,6 +845,20 @@ _MiniKit.commands = {
|
|
|
774
845
|
payload
|
|
775
846
|
});
|
|
776
847
|
return payload;
|
|
848
|
+
},
|
|
849
|
+
requestPermission: (payload) => {
|
|
850
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["request-permission" /* RequestPermission */]) {
|
|
851
|
+
console.error(
|
|
852
|
+
"'requestPermission' command is unavailable. Check MiniKit.install() or update the app version"
|
|
853
|
+
);
|
|
854
|
+
return null;
|
|
855
|
+
}
|
|
856
|
+
sendMiniKitEvent({
|
|
857
|
+
command: "request-permission" /* RequestPermission */,
|
|
858
|
+
version: 1,
|
|
859
|
+
payload
|
|
860
|
+
});
|
|
861
|
+
return payload;
|
|
777
862
|
}
|
|
778
863
|
};
|
|
779
864
|
/**
|
|
@@ -884,6 +969,20 @@ _MiniKit.commandsAsync = {
|
|
|
884
969
|
reject(error);
|
|
885
970
|
}
|
|
886
971
|
});
|
|
972
|
+
},
|
|
973
|
+
requestPermission: async (payload) => {
|
|
974
|
+
return new Promise(async (resolve, reject) => {
|
|
975
|
+
try {
|
|
976
|
+
const response = await _MiniKit.awaitCommand(
|
|
977
|
+
"miniapp-request-permission" /* MiniAppRequestPermission */,
|
|
978
|
+
"request-permission" /* RequestPermission */,
|
|
979
|
+
() => _MiniKit.commands.requestPermission(payload)
|
|
980
|
+
);
|
|
981
|
+
resolve(response);
|
|
982
|
+
} catch (error) {
|
|
983
|
+
reject(error);
|
|
984
|
+
}
|
|
985
|
+
});
|
|
887
986
|
}
|
|
888
987
|
};
|
|
889
988
|
var MiniKit = _MiniKit;
|
|
@@ -891,6 +990,58 @@ var MiniKit = _MiniKit;
|
|
|
891
990
|
// index.ts
|
|
892
991
|
var import_idkit_core4 = require("@worldcoin/idkit-core");
|
|
893
992
|
var import_backend = require("@worldcoin/idkit-core/backend");
|
|
993
|
+
|
|
994
|
+
// helpers/address-book/index.ts
|
|
995
|
+
var import_viem2 = require("viem");
|
|
996
|
+
var import_chains2 = require("viem/chains");
|
|
997
|
+
var worldIdAddressBookContractAddress = "0x57b930D551e677CC36e2fA036Ae2fe8FdaE0330D";
|
|
998
|
+
var addressVerifiedUntilAbi = [
|
|
999
|
+
{
|
|
1000
|
+
inputs: [
|
|
1001
|
+
{
|
|
1002
|
+
internalType: "address",
|
|
1003
|
+
name: "",
|
|
1004
|
+
type: "address"
|
|
1005
|
+
}
|
|
1006
|
+
],
|
|
1007
|
+
name: "addressVerifiedUntil",
|
|
1008
|
+
outputs: [
|
|
1009
|
+
{
|
|
1010
|
+
internalType: "uint256",
|
|
1011
|
+
name: "",
|
|
1012
|
+
type: "uint256"
|
|
1013
|
+
}
|
|
1014
|
+
],
|
|
1015
|
+
stateMutability: "view",
|
|
1016
|
+
type: "function"
|
|
1017
|
+
}
|
|
1018
|
+
];
|
|
1019
|
+
var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
1020
|
+
const publicClient = (0, import_viem2.createPublicClient)({
|
|
1021
|
+
chain: import_chains2.worldchain,
|
|
1022
|
+
transport: (0, import_viem2.http)(
|
|
1023
|
+
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
1024
|
+
)
|
|
1025
|
+
});
|
|
1026
|
+
try {
|
|
1027
|
+
const verifiedUntilResponse = await publicClient.readContract({
|
|
1028
|
+
address: worldIdAddressBookContractAddress,
|
|
1029
|
+
abi: addressVerifiedUntilAbi,
|
|
1030
|
+
functionName: "addressVerifiedUntil",
|
|
1031
|
+
args: [walletAddress]
|
|
1032
|
+
});
|
|
1033
|
+
const verifiedUntil = Number(verifiedUntilResponse.toString());
|
|
1034
|
+
if (!Number.isFinite(verifiedUntil)) {
|
|
1035
|
+
console.warn("Invalid verifiedUntil value:", verifiedUntil);
|
|
1036
|
+
return false;
|
|
1037
|
+
}
|
|
1038
|
+
const currentTime = Math.floor(Date.now() / 1e3);
|
|
1039
|
+
return verifiedUntil > currentTime;
|
|
1040
|
+
} catch (error) {
|
|
1041
|
+
console.error("Error verifying user:", error);
|
|
1042
|
+
return false;
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
894
1045
|
// Annotate the CommonJS export names for ESM import in node:
|
|
895
1046
|
0 && (module.exports = {
|
|
896
1047
|
Command,
|
|
@@ -901,6 +1052,9 @@ var import_backend = require("@worldcoin/idkit-core/backend");
|
|
|
901
1052
|
PaymentErrorCodes,
|
|
902
1053
|
PaymentErrorMessage,
|
|
903
1054
|
PaymentValidationErrors,
|
|
1055
|
+
Permission,
|
|
1056
|
+
RequestPermissionErrorCodes,
|
|
1057
|
+
RequestPermissionErrorMessage,
|
|
904
1058
|
ResponseEvent,
|
|
905
1059
|
SAFE_CONTRACT_ABI,
|
|
906
1060
|
SendTransactionErrorCodes,
|
|
@@ -918,6 +1072,7 @@ var import_backend = require("@worldcoin/idkit-core/backend");
|
|
|
918
1072
|
VerificationLevel,
|
|
919
1073
|
WalletAuthErrorCodes,
|
|
920
1074
|
WalletAuthErrorMessage,
|
|
1075
|
+
getIsUserVerified,
|
|
921
1076
|
parseSiweMessage,
|
|
922
1077
|
tokenToDecimals,
|
|
923
1078
|
verifyCloudProof,
|