@worldcoin/minikit-js 0.0.22-internal-alpha → 0.0.24-internal-alpha
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 +3 -0
- package/build/index.cjs +47 -28
- package/build/index.d.cts +5 -8
- package/build/index.d.ts +5 -8
- package/build/index.js +46 -28
- package/package.json +3 -3
package/README.md
ADDED
package/build/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ __export(src_exports, {
|
|
|
27
27
|
Network: () => Network,
|
|
28
28
|
PaymentErrorCodes: () => PaymentErrorCodes,
|
|
29
29
|
PaymentErrorMessage: () => PaymentErrorMessage,
|
|
30
|
+
PaymentValidationErrors: () => PaymentValidationErrors,
|
|
30
31
|
ResponseEvent: () => ResponseEvent,
|
|
31
32
|
SAFE_CONTRACT_ABI: () => SAFE_CONTRACT_ABI,
|
|
32
33
|
TokenDecimals: () => TokenDecimals,
|
|
@@ -246,20 +247,25 @@ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
|
246
247
|
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
247
248
|
PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
248
249
|
PaymentErrorCodes2["GenericError"] = "generic_error";
|
|
250
|
+
PaymentErrorCodes2["UserBlocked"] = "user_blocked";
|
|
249
251
|
return PaymentErrorCodes2;
|
|
250
252
|
})(PaymentErrorCodes || {});
|
|
251
|
-
var PaymentErrorMessage =
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
253
|
+
var PaymentErrorMessage = {
|
|
254
|
+
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
255
|
+
["payment_rejected" /* PaymentRejected */]: "You\u2019ve cancelled the payment in World App.",
|
|
256
|
+
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
257
|
+
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
258
|
+
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
259
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
260
|
+
["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
|
|
261
|
+
};
|
|
262
|
+
var PaymentValidationErrors = /* @__PURE__ */ ((PaymentValidationErrors2) => {
|
|
263
|
+
PaymentValidationErrors2["MalformedRequest"] = "There was a problem with this request. Please try again or contact the app owner.";
|
|
264
|
+
PaymentValidationErrors2["InvalidTokenAddress"] = "The token address is invalid. Please contact the app owner.";
|
|
265
|
+
PaymentValidationErrors2["InvalidAppId"] = "The app ID is invalid. Please contact the app owner.";
|
|
266
|
+
PaymentValidationErrors2["DuplicateReference"] = "This reference ID already exists please generate a new one and try again.";
|
|
267
|
+
return PaymentValidationErrors2;
|
|
268
|
+
})(PaymentValidationErrors || {});
|
|
263
269
|
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
264
270
|
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
265
271
|
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
@@ -353,6 +359,33 @@ var validateWalletAuthCommandInput = (params) => {
|
|
|
353
359
|
return { valid: true };
|
|
354
360
|
};
|
|
355
361
|
|
|
362
|
+
// helpers/payment/client.ts
|
|
363
|
+
var tokenToDecimals = (amount, token) => {
|
|
364
|
+
const decimals = TokenDecimals[token];
|
|
365
|
+
if (decimals === void 0) {
|
|
366
|
+
throw new Error(`Invalid token: ${token}`);
|
|
367
|
+
}
|
|
368
|
+
const factor = 10 ** decimals;
|
|
369
|
+
const result = amount * factor;
|
|
370
|
+
if (!Number.isInteger(result)) {
|
|
371
|
+
throw new Error(`The resulting amount is not a whole number: ${result}`);
|
|
372
|
+
}
|
|
373
|
+
return result;
|
|
374
|
+
};
|
|
375
|
+
var validatePaymentPayload = (payload) => {
|
|
376
|
+
if (payload.tokens.some(
|
|
377
|
+
(token) => token.symbol == "USDCE" && parseFloat(token.token_amount) < 0.1
|
|
378
|
+
)) {
|
|
379
|
+
console.error("USDCE amount should be greater than $0.1");
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
if (payload.reference.length > 36) {
|
|
383
|
+
console.error("Reference must not exceed 36 characters");
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
return true;
|
|
387
|
+
};
|
|
388
|
+
|
|
356
389
|
// minikit.ts
|
|
357
390
|
var sendMiniKitEvent = (payload) => {
|
|
358
391
|
sendWebviewEvent(payload);
|
|
@@ -463,8 +496,7 @@ _MiniKit.commands = {
|
|
|
463
496
|
);
|
|
464
497
|
return null;
|
|
465
498
|
}
|
|
466
|
-
if (payload
|
|
467
|
-
console.error("Reference must not exceed 36 characters");
|
|
499
|
+
if (!validatePaymentPayload(payload)) {
|
|
468
500
|
return null;
|
|
469
501
|
}
|
|
470
502
|
const network = "optimism" /* Optimism */;
|
|
@@ -529,20 +561,6 @@ _MiniKit.commands = {
|
|
|
529
561
|
};
|
|
530
562
|
var MiniKit = _MiniKit;
|
|
531
563
|
|
|
532
|
-
// helpers/payment/client.ts
|
|
533
|
-
var tokenToDecimals = (amount, token) => {
|
|
534
|
-
const decimals = TokenDecimals[token];
|
|
535
|
-
if (decimals === void 0) {
|
|
536
|
-
throw new Error(`Invalid token: ${token}`);
|
|
537
|
-
}
|
|
538
|
-
const factor = 10 ** decimals;
|
|
539
|
-
const result = amount * factor;
|
|
540
|
-
if (!Number.isInteger(result)) {
|
|
541
|
-
throw new Error(`The resulting amount is not a whole number: ${result}`);
|
|
542
|
-
}
|
|
543
|
-
return result;
|
|
544
|
-
};
|
|
545
|
-
|
|
546
564
|
// index.ts
|
|
547
565
|
var import_idkit_core4 = require("@worldcoin/idkit-core");
|
|
548
566
|
var import_backend = require("@worldcoin/idkit-core/backend");
|
|
@@ -555,6 +573,7 @@ var import_backend = require("@worldcoin/idkit-core/backend");
|
|
|
555
573
|
Network,
|
|
556
574
|
PaymentErrorCodes,
|
|
557
575
|
PaymentErrorMessage,
|
|
576
|
+
PaymentValidationErrors,
|
|
558
577
|
ResponseEvent,
|
|
559
578
|
SAFE_CONTRACT_ABI,
|
|
560
579
|
TokenDecimals,
|
package/build/index.d.cts
CHANGED
|
@@ -37,17 +37,14 @@ declare enum PaymentErrorCodes {
|
|
|
37
37
|
InvalidReceiver = "invalid_receiver",
|
|
38
38
|
InsufficientBalance = "insufficient_balance",
|
|
39
39
|
TransactionFailed = "transaction_failed",
|
|
40
|
-
GenericError = "generic_error"
|
|
40
|
+
GenericError = "generic_error",
|
|
41
|
+
UserBlocked = "user_blocked"
|
|
41
42
|
}
|
|
42
|
-
declare
|
|
43
|
+
declare const PaymentErrorMessage: Record<PaymentErrorCodes, string>;
|
|
44
|
+
declare enum PaymentValidationErrors {
|
|
43
45
|
MalformedRequest = "There was a problem with this request. Please try again or contact the app owner.",
|
|
44
|
-
PaymentRejected = "You\u2019ve cancelled the payment in World App.",
|
|
45
|
-
InvalidReceiver = "The receiver address is invalid. Please contact the app owner.",
|
|
46
|
-
InsufficientBalance = "You do not have enough balance to complete this transaction.",
|
|
47
|
-
TransactionFailed = "The transaction failed. Please try again.",
|
|
48
46
|
InvalidTokenAddress = "The token address is invalid. Please contact the app owner.",
|
|
49
47
|
InvalidAppId = "The app ID is invalid. Please contact the app owner.",
|
|
50
|
-
GenericError = "Something unexpected went wrong. Please try again.",
|
|
51
48
|
DuplicateReference = "This reference ID already exists please generate a new one and try again."
|
|
52
49
|
}
|
|
53
50
|
declare enum WalletAuthErrorCodes {
|
|
@@ -209,4 +206,4 @@ declare class MiniKit {
|
|
|
209
206
|
|
|
210
207
|
declare const tokenToDecimals: (amount: number, token: Tokens) => number;
|
|
211
208
|
|
|
212
|
-
export { Command, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessEventPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCode, MiniKitInstallErrorMessage, Network, type PayCommandInput, PaymentErrorCodes, PaymentErrorMessage, ResponseEvent, SAFE_CONTRACT_ABI, type SiweMessage, TokenDecimals, Tokens, VerificationErrorMessage, type VerifyCommandInput, WalletAuthErrorCodes, WalletAuthErrorMessage, generateNonce, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
|
209
|
+
export { Command, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessEventPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCode, MiniKitInstallErrorMessage, Network, type PayCommandInput, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, ResponseEvent, SAFE_CONTRACT_ABI, type SiweMessage, TokenDecimals, Tokens, VerificationErrorMessage, type VerifyCommandInput, WalletAuthErrorCodes, WalletAuthErrorMessage, generateNonce, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
package/build/index.d.ts
CHANGED
|
@@ -37,17 +37,14 @@ declare enum PaymentErrorCodes {
|
|
|
37
37
|
InvalidReceiver = "invalid_receiver",
|
|
38
38
|
InsufficientBalance = "insufficient_balance",
|
|
39
39
|
TransactionFailed = "transaction_failed",
|
|
40
|
-
GenericError = "generic_error"
|
|
40
|
+
GenericError = "generic_error",
|
|
41
|
+
UserBlocked = "user_blocked"
|
|
41
42
|
}
|
|
42
|
-
declare
|
|
43
|
+
declare const PaymentErrorMessage: Record<PaymentErrorCodes, string>;
|
|
44
|
+
declare enum PaymentValidationErrors {
|
|
43
45
|
MalformedRequest = "There was a problem with this request. Please try again or contact the app owner.",
|
|
44
|
-
PaymentRejected = "You\u2019ve cancelled the payment in World App.",
|
|
45
|
-
InvalidReceiver = "The receiver address is invalid. Please contact the app owner.",
|
|
46
|
-
InsufficientBalance = "You do not have enough balance to complete this transaction.",
|
|
47
|
-
TransactionFailed = "The transaction failed. Please try again.",
|
|
48
46
|
InvalidTokenAddress = "The token address is invalid. Please contact the app owner.",
|
|
49
47
|
InvalidAppId = "The app ID is invalid. Please contact the app owner.",
|
|
50
|
-
GenericError = "Something unexpected went wrong. Please try again.",
|
|
51
48
|
DuplicateReference = "This reference ID already exists please generate a new one and try again."
|
|
52
49
|
}
|
|
53
50
|
declare enum WalletAuthErrorCodes {
|
|
@@ -209,4 +206,4 @@ declare class MiniKit {
|
|
|
209
206
|
|
|
210
207
|
declare const tokenToDecimals: (amount: number, token: Tokens) => number;
|
|
211
208
|
|
|
212
|
-
export { Command, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessEventPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCode, MiniKitInstallErrorMessage, Network, type PayCommandInput, PaymentErrorCodes, PaymentErrorMessage, ResponseEvent, SAFE_CONTRACT_ABI, type SiweMessage, TokenDecimals, Tokens, VerificationErrorMessage, type VerifyCommandInput, WalletAuthErrorCodes, WalletAuthErrorMessage, generateNonce, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
|
209
|
+
export { Command, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessEventPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCode, MiniKitInstallErrorMessage, Network, type PayCommandInput, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, ResponseEvent, SAFE_CONTRACT_ABI, type SiweMessage, TokenDecimals, Tokens, VerificationErrorMessage, type VerifyCommandInput, WalletAuthErrorCodes, WalletAuthErrorMessage, generateNonce, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
package/build/index.js
CHANGED
|
@@ -200,20 +200,25 @@ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
|
200
200
|
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
201
201
|
PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
202
202
|
PaymentErrorCodes2["GenericError"] = "generic_error";
|
|
203
|
+
PaymentErrorCodes2["UserBlocked"] = "user_blocked";
|
|
203
204
|
return PaymentErrorCodes2;
|
|
204
205
|
})(PaymentErrorCodes || {});
|
|
205
|
-
var PaymentErrorMessage =
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
206
|
+
var PaymentErrorMessage = {
|
|
207
|
+
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
208
|
+
["payment_rejected" /* PaymentRejected */]: "You\u2019ve cancelled the payment in World App.",
|
|
209
|
+
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
210
|
+
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
211
|
+
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
212
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
213
|
+
["user_blocked" /* UserBlocked */]: "User's region is blocked from making payments."
|
|
214
|
+
};
|
|
215
|
+
var PaymentValidationErrors = /* @__PURE__ */ ((PaymentValidationErrors2) => {
|
|
216
|
+
PaymentValidationErrors2["MalformedRequest"] = "There was a problem with this request. Please try again or contact the app owner.";
|
|
217
|
+
PaymentValidationErrors2["InvalidTokenAddress"] = "The token address is invalid. Please contact the app owner.";
|
|
218
|
+
PaymentValidationErrors2["InvalidAppId"] = "The app ID is invalid. Please contact the app owner.";
|
|
219
|
+
PaymentValidationErrors2["DuplicateReference"] = "This reference ID already exists please generate a new one and try again.";
|
|
220
|
+
return PaymentValidationErrors2;
|
|
221
|
+
})(PaymentValidationErrors || {});
|
|
217
222
|
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
218
223
|
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
219
224
|
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
@@ -307,6 +312,33 @@ var validateWalletAuthCommandInput = (params) => {
|
|
|
307
312
|
return { valid: true };
|
|
308
313
|
};
|
|
309
314
|
|
|
315
|
+
// helpers/payment/client.ts
|
|
316
|
+
var tokenToDecimals = (amount, token) => {
|
|
317
|
+
const decimals = TokenDecimals[token];
|
|
318
|
+
if (decimals === void 0) {
|
|
319
|
+
throw new Error(`Invalid token: ${token}`);
|
|
320
|
+
}
|
|
321
|
+
const factor = 10 ** decimals;
|
|
322
|
+
const result = amount * factor;
|
|
323
|
+
if (!Number.isInteger(result)) {
|
|
324
|
+
throw new Error(`The resulting amount is not a whole number: ${result}`);
|
|
325
|
+
}
|
|
326
|
+
return result;
|
|
327
|
+
};
|
|
328
|
+
var validatePaymentPayload = (payload) => {
|
|
329
|
+
if (payload.tokens.some(
|
|
330
|
+
(token) => token.symbol == "USDCE" && parseFloat(token.token_amount) < 0.1
|
|
331
|
+
)) {
|
|
332
|
+
console.error("USDCE amount should be greater than $0.1");
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
if (payload.reference.length > 36) {
|
|
336
|
+
console.error("Reference must not exceed 36 characters");
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
return true;
|
|
340
|
+
};
|
|
341
|
+
|
|
310
342
|
// minikit.ts
|
|
311
343
|
var sendMiniKitEvent = (payload) => {
|
|
312
344
|
sendWebviewEvent(payload);
|
|
@@ -417,8 +449,7 @@ _MiniKit.commands = {
|
|
|
417
449
|
);
|
|
418
450
|
return null;
|
|
419
451
|
}
|
|
420
|
-
if (payload
|
|
421
|
-
console.error("Reference must not exceed 36 characters");
|
|
452
|
+
if (!validatePaymentPayload(payload)) {
|
|
422
453
|
return null;
|
|
423
454
|
}
|
|
424
455
|
const network = "optimism" /* Optimism */;
|
|
@@ -483,20 +514,6 @@ _MiniKit.commands = {
|
|
|
483
514
|
};
|
|
484
515
|
var MiniKit = _MiniKit;
|
|
485
516
|
|
|
486
|
-
// helpers/payment/client.ts
|
|
487
|
-
var tokenToDecimals = (amount, token) => {
|
|
488
|
-
const decimals = TokenDecimals[token];
|
|
489
|
-
if (decimals === void 0) {
|
|
490
|
-
throw new Error(`Invalid token: ${token}`);
|
|
491
|
-
}
|
|
492
|
-
const factor = 10 ** decimals;
|
|
493
|
-
const result = amount * factor;
|
|
494
|
-
if (!Number.isInteger(result)) {
|
|
495
|
-
throw new Error(`The resulting amount is not a whole number: ${result}`);
|
|
496
|
-
}
|
|
497
|
-
return result;
|
|
498
|
-
};
|
|
499
|
-
|
|
500
517
|
// index.ts
|
|
501
518
|
import { VerificationLevel as VerificationLevel2 } from "@worldcoin/idkit-core";
|
|
502
519
|
import {
|
|
@@ -510,6 +527,7 @@ export {
|
|
|
510
527
|
Network,
|
|
511
528
|
PaymentErrorCodes,
|
|
512
529
|
PaymentErrorMessage,
|
|
530
|
+
PaymentValidationErrors,
|
|
513
531
|
ResponseEvent,
|
|
514
532
|
SAFE_CONTRACT_ABI,
|
|
515
533
|
TokenDecimals,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worldcoin/minikit-js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24-internal-alpha",
|
|
4
4
|
"homepage": "https://docs.worldcoin.org/id/minikit",
|
|
5
5
|
"description": "Internal Alpha: Mini-kit JS is a lightweight sdk for building mini-apps compatible with World App",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"miniapps"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@worldcoin/idkit-core": "^1.2.
|
|
28
|
+
"@worldcoin/idkit-core": "^1.2.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"typescript": "^5.4.5"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"ethers": "^
|
|
40
|
+
"ethers": "^6.0.8"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsup",
|