@worldcoin/minikit-js 1.6.0 → 1.7.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 +100 -29
- package/build/index.d.cts +40 -16
- package/build/index.d.ts +40 -16
- package/build/index.js +98 -29
- package/package.json +3 -3
package/build/index.cjs
CHANGED
|
@@ -21,6 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var core_exports = {};
|
|
22
22
|
__export(core_exports, {
|
|
23
23
|
Command: () => Command,
|
|
24
|
+
GetPermissionsErrorCodes: () => GetPermissionsErrorCodes,
|
|
25
|
+
GetPermissionsErrorMessage: () => GetPermissionsErrorMessage,
|
|
24
26
|
MiniKit: () => MiniKit,
|
|
25
27
|
MiniKitInstallErrorCodes: () => MiniKitInstallErrorCodes,
|
|
26
28
|
MiniKitInstallErrorMessage: () => MiniKitInstallErrorMessage,
|
|
@@ -319,30 +321,44 @@ var validateWalletAuthCommandInput = (params) => {
|
|
|
319
321
|
var isValidHex = (str) => {
|
|
320
322
|
return /^0x[0-9A-Fa-f]+$/.test(str);
|
|
321
323
|
};
|
|
322
|
-
var
|
|
323
|
-
if (typeof payload === "string"
|
|
324
|
+
var processPayload = (payload) => {
|
|
325
|
+
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
326
|
+
return payload;
|
|
327
|
+
}
|
|
328
|
+
if (typeof payload === "number") {
|
|
329
|
+
return String(payload);
|
|
330
|
+
}
|
|
324
331
|
if (Array.isArray(payload)) {
|
|
325
|
-
|
|
326
|
-
return { isValid };
|
|
332
|
+
return payload.map((value) => processPayload(value));
|
|
327
333
|
}
|
|
328
|
-
if (typeof payload === "object"
|
|
329
|
-
|
|
330
|
-
|
|
334
|
+
if (typeof payload === "object") {
|
|
335
|
+
const result = { ...payload };
|
|
336
|
+
if ("value" in result && result.value !== void 0) {
|
|
337
|
+
if (typeof result.value !== "string") {
|
|
338
|
+
result.value = String(result.value);
|
|
339
|
+
}
|
|
340
|
+
if (!isValidHex(result.value)) {
|
|
331
341
|
console.error(
|
|
332
342
|
"Transaction value must be a valid hex string",
|
|
333
|
-
|
|
343
|
+
result.value
|
|
344
|
+
);
|
|
345
|
+
throw new Error(
|
|
346
|
+
`Transaction value must be a valid hex string: ${result.value}`
|
|
334
347
|
);
|
|
335
|
-
return { isValid: false };
|
|
336
348
|
}
|
|
337
349
|
}
|
|
338
|
-
const
|
|
339
|
-
(
|
|
340
|
-
|
|
341
|
-
|
|
350
|
+
for (const key in result) {
|
|
351
|
+
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
352
|
+
result[key] = processPayload(result[key]);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return result;
|
|
342
356
|
}
|
|
343
|
-
return
|
|
357
|
+
return payload;
|
|
358
|
+
};
|
|
359
|
+
var validateSendTransactionPayload = (payload) => {
|
|
360
|
+
return processPayload(payload);
|
|
344
361
|
};
|
|
345
|
-
var validateSendTransactionPayload = (payload) => validate(payload);
|
|
346
362
|
|
|
347
363
|
// helpers/usernames/index.ts
|
|
348
364
|
var getUserProfile = async (address) => {
|
|
@@ -369,6 +385,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
369
385
|
Command2["SignTypedData"] = "sign-typed-data";
|
|
370
386
|
Command2["ShareContacts"] = "share-contacts";
|
|
371
387
|
Command2["RequestPermission"] = "request-permission";
|
|
388
|
+
Command2["GetPermissions"] = "get-permissions";
|
|
372
389
|
return Command2;
|
|
373
390
|
})(Command || {});
|
|
374
391
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
@@ -380,7 +397,7 @@ var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
|
380
397
|
var import_idkit_core = require("@worldcoin/idkit-core");
|
|
381
398
|
var import_idkit_core2 = require("@worldcoin/idkit-core");
|
|
382
399
|
var VerificationErrorMessage = {
|
|
383
|
-
[import_idkit_core.AppErrorCodes.VerificationRejected]: "You
|
|
400
|
+
[import_idkit_core.AppErrorCodes.VerificationRejected]: "You've cancelled the request in World App.",
|
|
384
401
|
[import_idkit_core.AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
385
402
|
[import_idkit_core.AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
386
403
|
[import_idkit_core.AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
@@ -404,7 +421,7 @@ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
|
404
421
|
})(PaymentErrorCodes || {});
|
|
405
422
|
var PaymentErrorMessage = {
|
|
406
423
|
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
407
|
-
["payment_rejected" /* PaymentRejected */]: "You
|
|
424
|
+
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
408
425
|
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
409
426
|
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
410
427
|
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
@@ -439,6 +456,9 @@ var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) =>
|
|
|
439
456
|
SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
440
457
|
SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
441
458
|
SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
459
|
+
SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
|
|
460
|
+
SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
|
|
461
|
+
SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
|
|
442
462
|
return SendTransactionErrorCodes2;
|
|
443
463
|
})(SendTransactionErrorCodes || {});
|
|
444
464
|
var SendTransactionErrorMessage = {
|
|
@@ -450,7 +470,10 @@ var SendTransactionErrorMessage = {
|
|
|
450
470
|
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
451
471
|
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
452
472
|
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
453
|
-
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
473
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
|
|
474
|
+
["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
|
|
475
|
+
["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
|
|
476
|
+
["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
|
|
454
477
|
};
|
|
455
478
|
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
456
479
|
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
@@ -474,7 +497,16 @@ var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
|
474
497
|
SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
475
498
|
return SignTypedDataErrorCodes2;
|
|
476
499
|
})(SignTypedDataErrorCodes || {});
|
|
477
|
-
var SignTypedDataErrorMessage =
|
|
500
|
+
var SignTypedDataErrorMessage = {
|
|
501
|
+
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
502
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
503
|
+
["input_error" /* InputError */]: "Invalid payload.",
|
|
504
|
+
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
505
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
506
|
+
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
507
|
+
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
508
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
509
|
+
};
|
|
478
510
|
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
479
511
|
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
480
512
|
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
@@ -516,6 +548,13 @@ var RequestPermissionErrorMessage = {
|
|
|
516
548
|
["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
|
|
517
549
|
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
518
550
|
};
|
|
551
|
+
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
552
|
+
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
553
|
+
return GetPermissionsErrorCodes2;
|
|
554
|
+
})(GetPermissionsErrorCodes || {});
|
|
555
|
+
var GetPermissionsErrorMessage = {
|
|
556
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
557
|
+
};
|
|
519
558
|
|
|
520
559
|
// helpers/send-webview-event.ts
|
|
521
560
|
var sendWebviewEvent = (payload) => {
|
|
@@ -536,6 +575,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
536
575
|
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
537
576
|
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
538
577
|
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
578
|
+
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
539
579
|
return ResponseEvent2;
|
|
540
580
|
})(ResponseEvent || {});
|
|
541
581
|
|
|
@@ -667,7 +707,8 @@ _MiniKit.commandVersion = {
|
|
|
667
707
|
["sign-message" /* SignMessage */]: 1,
|
|
668
708
|
["sign-typed-data" /* SignTypedData */]: 1,
|
|
669
709
|
["share-contacts" /* ShareContacts */]: 1,
|
|
670
|
-
["request-permission" /* RequestPermission */]: 1
|
|
710
|
+
["request-permission" /* RequestPermission */]: 1,
|
|
711
|
+
["get-permissions" /* GetPermissions */]: 1
|
|
671
712
|
};
|
|
672
713
|
_MiniKit.isCommandAvailable = {
|
|
673
714
|
["verify" /* Verify */]: false,
|
|
@@ -677,7 +718,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
677
718
|
["sign-message" /* SignMessage */]: false,
|
|
678
719
|
["sign-typed-data" /* SignTypedData */]: false,
|
|
679
720
|
["share-contacts" /* ShareContacts */]: false,
|
|
680
|
-
["request-permission" /* RequestPermission */]: false
|
|
721
|
+
["request-permission" /* RequestPermission */]: false,
|
|
722
|
+
["get-permissions" /* GetPermissions */]: false
|
|
681
723
|
};
|
|
682
724
|
_MiniKit.listeners = {
|
|
683
725
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -695,6 +737,8 @@ _MiniKit.listeners = {
|
|
|
695
737
|
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
696
738
|
},
|
|
697
739
|
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
740
|
+
},
|
|
741
|
+
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
698
742
|
}
|
|
699
743
|
};
|
|
700
744
|
_MiniKit.appId = null;
|
|
@@ -806,18 +850,13 @@ _MiniKit.commands = {
|
|
|
806
850
|
);
|
|
807
851
|
return null;
|
|
808
852
|
}
|
|
809
|
-
|
|
810
|
-
console.error(
|
|
811
|
-
"Invalid sendTransaction payload - some object properties are not strings"
|
|
812
|
-
);
|
|
813
|
-
return null;
|
|
814
|
-
}
|
|
853
|
+
const validatedPayload = validateSendTransactionPayload(payload);
|
|
815
854
|
sendMiniKitEvent({
|
|
816
855
|
command: "send-transaction" /* SendTransaction */,
|
|
817
856
|
version: 1,
|
|
818
|
-
payload
|
|
857
|
+
payload: validatedPayload
|
|
819
858
|
});
|
|
820
|
-
return
|
|
859
|
+
return validatedPayload;
|
|
821
860
|
},
|
|
822
861
|
signMessage: (payload) => {
|
|
823
862
|
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-message" /* SignMessage */]) {
|
|
@@ -874,6 +913,22 @@ _MiniKit.commands = {
|
|
|
874
913
|
payload
|
|
875
914
|
});
|
|
876
915
|
return payload;
|
|
916
|
+
},
|
|
917
|
+
getPermissions: () => {
|
|
918
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["get-permissions" /* GetPermissions */]) {
|
|
919
|
+
console.error(
|
|
920
|
+
"'getPermissions' command is unavailable. Check MiniKit.install() or update the app version"
|
|
921
|
+
);
|
|
922
|
+
return null;
|
|
923
|
+
}
|
|
924
|
+
sendMiniKitEvent({
|
|
925
|
+
command: "get-permissions" /* GetPermissions */,
|
|
926
|
+
version: 1,
|
|
927
|
+
payload: {}
|
|
928
|
+
});
|
|
929
|
+
return {
|
|
930
|
+
status: "sent"
|
|
931
|
+
};
|
|
877
932
|
}
|
|
878
933
|
};
|
|
879
934
|
/**
|
|
@@ -998,6 +1053,20 @@ _MiniKit.commandsAsync = {
|
|
|
998
1053
|
reject(error);
|
|
999
1054
|
}
|
|
1000
1055
|
});
|
|
1056
|
+
},
|
|
1057
|
+
getPermissions: async () => {
|
|
1058
|
+
return new Promise(async (resolve, reject) => {
|
|
1059
|
+
try {
|
|
1060
|
+
const response = await _MiniKit.awaitCommand(
|
|
1061
|
+
"miniapp-get-permissions" /* MiniAppGetPermissions */,
|
|
1062
|
+
"get-permissions" /* GetPermissions */,
|
|
1063
|
+
() => _MiniKit.commands.getPermissions()
|
|
1064
|
+
);
|
|
1065
|
+
resolve(response);
|
|
1066
|
+
} catch (error) {
|
|
1067
|
+
reject(error);
|
|
1068
|
+
}
|
|
1069
|
+
});
|
|
1001
1070
|
}
|
|
1002
1071
|
};
|
|
1003
1072
|
var MiniKit = _MiniKit;
|
|
@@ -1060,6 +1129,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
1060
1129
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1061
1130
|
0 && (module.exports = {
|
|
1062
1131
|
Command,
|
|
1132
|
+
GetPermissionsErrorCodes,
|
|
1133
|
+
GetPermissionsErrorMessage,
|
|
1063
1134
|
MiniKit,
|
|
1064
1135
|
MiniKitInstallErrorCodes,
|
|
1065
1136
|
MiniKitInstallErrorMessage,
|
package/build/index.d.cts
CHANGED
|
@@ -40,19 +40,12 @@ declare enum SendTransactionErrorCodes {
|
|
|
40
40
|
GenericError = "generic_error",
|
|
41
41
|
DisallowedOperation = "disallowed_operation",
|
|
42
42
|
InvalidContract = "invalid_contract",
|
|
43
|
-
MaliciousOperation = "malicious_operation"
|
|
43
|
+
MaliciousOperation = "malicious_operation",
|
|
44
|
+
DailyTxLimitReached = "daily_tx_limit_reached",
|
|
45
|
+
PermittedAmountExceedsSlippage = "permitted_amount_exceeds_slippage",
|
|
46
|
+
PermittedAmountNotFound = "permitted_amount_not_found"
|
|
44
47
|
}
|
|
45
|
-
declare const SendTransactionErrorMessage:
|
|
46
|
-
invalid_operation: string;
|
|
47
|
-
user_rejected: string;
|
|
48
|
-
input_error: string;
|
|
49
|
-
simulation_failed: string;
|
|
50
|
-
transaction_failed: string;
|
|
51
|
-
generic_error: string;
|
|
52
|
-
disallowed_operation: string;
|
|
53
|
-
invalid_contract: string;
|
|
54
|
-
malicious_operation: string;
|
|
55
|
-
};
|
|
48
|
+
declare const SendTransactionErrorMessage: Record<SendTransactionErrorCodes, string>;
|
|
56
49
|
declare enum SignMessageErrorCodes {
|
|
57
50
|
InvalidMessage = "invalid_message",
|
|
58
51
|
UserRejected = "user_rejected",
|
|
@@ -78,7 +71,6 @@ declare const SignTypedDataErrorMessage: {
|
|
|
78
71
|
user_rejected: string;
|
|
79
72
|
input_error: string;
|
|
80
73
|
simulation_failed: string;
|
|
81
|
-
transaction_failed: string;
|
|
82
74
|
generic_error: string;
|
|
83
75
|
disallowed_operation: string;
|
|
84
76
|
invalid_contract: string;
|
|
@@ -122,6 +114,12 @@ declare const RequestPermissionErrorMessage: {
|
|
|
122
114
|
already_granted: string;
|
|
123
115
|
unsupported_permission: string;
|
|
124
116
|
};
|
|
117
|
+
declare enum GetPermissionsErrorCodes {
|
|
118
|
+
GenericError = "generic_error"
|
|
119
|
+
}
|
|
120
|
+
declare const GetPermissionsErrorMessage: {
|
|
121
|
+
generic_error: string;
|
|
122
|
+
};
|
|
125
123
|
|
|
126
124
|
declare enum Tokens {
|
|
127
125
|
USDCE = "USDCE",
|
|
@@ -162,7 +160,8 @@ declare enum Command {
|
|
|
162
160
|
SignMessage = "sign-message",
|
|
163
161
|
SignTypedData = "sign-typed-data",
|
|
164
162
|
ShareContacts = "share-contacts",
|
|
165
|
-
RequestPermission = "request-permission"
|
|
163
|
+
RequestPermission = "request-permission",
|
|
164
|
+
GetPermissions = "get-permissions"
|
|
166
165
|
}
|
|
167
166
|
type WebViewBasePayload = {
|
|
168
167
|
command: Command;
|
|
@@ -238,6 +237,8 @@ type RequestPermissionInput = {
|
|
|
238
237
|
permission: Permission;
|
|
239
238
|
};
|
|
240
239
|
type RequestPermissionPayload = RequestPermissionInput;
|
|
240
|
+
type GetPermissionsInput = {};
|
|
241
|
+
type GetPermissionsPayload = GetPermissionsInput;
|
|
241
242
|
type CommandReturnPayloadMap = {
|
|
242
243
|
[Command.Verify]: VerifyCommandPayload;
|
|
243
244
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -247,6 +248,7 @@ type CommandReturnPayloadMap = {
|
|
|
247
248
|
[Command.SignTypedData]: SignTypedDataPayload;
|
|
248
249
|
[Command.ShareContacts]: ShareContactsPayload;
|
|
249
250
|
[Command.RequestPermission]: RequestPermissionPayload;
|
|
251
|
+
[Command.GetPermissions]: GetPermissionsPayload;
|
|
250
252
|
};
|
|
251
253
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
252
254
|
|
|
@@ -258,7 +260,8 @@ declare enum ResponseEvent {
|
|
|
258
260
|
MiniAppSignMessage = "miniapp-sign-message",
|
|
259
261
|
MiniAppSignTypedData = "miniapp-sign-typed-data",
|
|
260
262
|
MiniAppShareContacts = "miniapp-share-contacts",
|
|
261
|
-
MiniAppRequestPermission = "miniapp-request-permission"
|
|
263
|
+
MiniAppRequestPermission = "miniapp-request-permission",
|
|
264
|
+
MiniAppGetPermissions = "miniapp-get-permissions"
|
|
262
265
|
}
|
|
263
266
|
type MiniAppVerifyActionSuccessPayload = {
|
|
264
267
|
status: 'success';
|
|
@@ -313,12 +316,14 @@ type MiniAppSendTransactionSuccessPayload = {
|
|
|
313
316
|
chain: Network;
|
|
314
317
|
timestamp: string;
|
|
315
318
|
version: number;
|
|
319
|
+
mini_app_id?: string;
|
|
316
320
|
};
|
|
317
321
|
type MiniAppSendTransactionErrorPayload = {
|
|
318
322
|
status: 'error';
|
|
319
323
|
error_code: SendTransactionErrorCodes;
|
|
320
324
|
details?: Record<string, any>;
|
|
321
325
|
version: number;
|
|
326
|
+
mini_app_id?: string;
|
|
322
327
|
};
|
|
323
328
|
type MiniAppSendTransactionPayload = MiniAppSendTransactionSuccessPayload | MiniAppSendTransactionErrorPayload;
|
|
324
329
|
type MiniAppSignMessageSuccessPayload = {
|
|
@@ -377,6 +382,22 @@ type MiniAppRequestPermissionErrorPayload = {
|
|
|
377
382
|
version: number;
|
|
378
383
|
};
|
|
379
384
|
type MiniAppRequestPermissionPayload = MiniAppRequestPermissionSuccessPayload | MiniAppRequestPermissionErrorPayload;
|
|
385
|
+
type PermissionSettings = {
|
|
386
|
+
[K in Permission]?: any;
|
|
387
|
+
};
|
|
388
|
+
type MiniAppGetPermissionsSuccessPayload = {
|
|
389
|
+
status: 'success';
|
|
390
|
+
permissions: PermissionSettings;
|
|
391
|
+
version: number;
|
|
392
|
+
timestamp: string;
|
|
393
|
+
};
|
|
394
|
+
type MiniAppGetPermissionsErrorPayload = {
|
|
395
|
+
status: 'error';
|
|
396
|
+
error_code: GetPermissionsErrorCodes;
|
|
397
|
+
details: string;
|
|
398
|
+
version: number;
|
|
399
|
+
};
|
|
400
|
+
type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
|
|
380
401
|
type EventPayloadMap = {
|
|
381
402
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
382
403
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -386,6 +407,7 @@ type EventPayloadMap = {
|
|
|
386
407
|
[ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
|
|
387
408
|
[ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
|
|
388
409
|
[ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
|
|
410
|
+
[ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
|
|
389
411
|
};
|
|
390
412
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
391
413
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -425,6 +447,7 @@ declare class MiniKit {
|
|
|
425
447
|
signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
|
|
426
448
|
shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
|
|
427
449
|
requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
|
|
450
|
+
getPermissions: () => GetPermissionsPayload | null;
|
|
428
451
|
};
|
|
429
452
|
/**
|
|
430
453
|
* This object contains async versions of all the commands.
|
|
@@ -445,6 +468,7 @@ declare class MiniKit {
|
|
|
445
468
|
signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
|
|
446
469
|
shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
|
|
447
470
|
requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
|
|
471
|
+
getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
|
|
448
472
|
};
|
|
449
473
|
}
|
|
450
474
|
|
|
@@ -488,4 +512,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
488
512
|
|
|
489
513
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
490
514
|
|
|
491
|
-
export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, Permission, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
|
515
|
+
export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, Permission, type PermissionSettings, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
package/build/index.d.ts
CHANGED
|
@@ -40,19 +40,12 @@ declare enum SendTransactionErrorCodes {
|
|
|
40
40
|
GenericError = "generic_error",
|
|
41
41
|
DisallowedOperation = "disallowed_operation",
|
|
42
42
|
InvalidContract = "invalid_contract",
|
|
43
|
-
MaliciousOperation = "malicious_operation"
|
|
43
|
+
MaliciousOperation = "malicious_operation",
|
|
44
|
+
DailyTxLimitReached = "daily_tx_limit_reached",
|
|
45
|
+
PermittedAmountExceedsSlippage = "permitted_amount_exceeds_slippage",
|
|
46
|
+
PermittedAmountNotFound = "permitted_amount_not_found"
|
|
44
47
|
}
|
|
45
|
-
declare const SendTransactionErrorMessage:
|
|
46
|
-
invalid_operation: string;
|
|
47
|
-
user_rejected: string;
|
|
48
|
-
input_error: string;
|
|
49
|
-
simulation_failed: string;
|
|
50
|
-
transaction_failed: string;
|
|
51
|
-
generic_error: string;
|
|
52
|
-
disallowed_operation: string;
|
|
53
|
-
invalid_contract: string;
|
|
54
|
-
malicious_operation: string;
|
|
55
|
-
};
|
|
48
|
+
declare const SendTransactionErrorMessage: Record<SendTransactionErrorCodes, string>;
|
|
56
49
|
declare enum SignMessageErrorCodes {
|
|
57
50
|
InvalidMessage = "invalid_message",
|
|
58
51
|
UserRejected = "user_rejected",
|
|
@@ -78,7 +71,6 @@ declare const SignTypedDataErrorMessage: {
|
|
|
78
71
|
user_rejected: string;
|
|
79
72
|
input_error: string;
|
|
80
73
|
simulation_failed: string;
|
|
81
|
-
transaction_failed: string;
|
|
82
74
|
generic_error: string;
|
|
83
75
|
disallowed_operation: string;
|
|
84
76
|
invalid_contract: string;
|
|
@@ -122,6 +114,12 @@ declare const RequestPermissionErrorMessage: {
|
|
|
122
114
|
already_granted: string;
|
|
123
115
|
unsupported_permission: string;
|
|
124
116
|
};
|
|
117
|
+
declare enum GetPermissionsErrorCodes {
|
|
118
|
+
GenericError = "generic_error"
|
|
119
|
+
}
|
|
120
|
+
declare const GetPermissionsErrorMessage: {
|
|
121
|
+
generic_error: string;
|
|
122
|
+
};
|
|
125
123
|
|
|
126
124
|
declare enum Tokens {
|
|
127
125
|
USDCE = "USDCE",
|
|
@@ -162,7 +160,8 @@ declare enum Command {
|
|
|
162
160
|
SignMessage = "sign-message",
|
|
163
161
|
SignTypedData = "sign-typed-data",
|
|
164
162
|
ShareContacts = "share-contacts",
|
|
165
|
-
RequestPermission = "request-permission"
|
|
163
|
+
RequestPermission = "request-permission",
|
|
164
|
+
GetPermissions = "get-permissions"
|
|
166
165
|
}
|
|
167
166
|
type WebViewBasePayload = {
|
|
168
167
|
command: Command;
|
|
@@ -238,6 +237,8 @@ type RequestPermissionInput = {
|
|
|
238
237
|
permission: Permission;
|
|
239
238
|
};
|
|
240
239
|
type RequestPermissionPayload = RequestPermissionInput;
|
|
240
|
+
type GetPermissionsInput = {};
|
|
241
|
+
type GetPermissionsPayload = GetPermissionsInput;
|
|
241
242
|
type CommandReturnPayloadMap = {
|
|
242
243
|
[Command.Verify]: VerifyCommandPayload;
|
|
243
244
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -247,6 +248,7 @@ type CommandReturnPayloadMap = {
|
|
|
247
248
|
[Command.SignTypedData]: SignTypedDataPayload;
|
|
248
249
|
[Command.ShareContacts]: ShareContactsPayload;
|
|
249
250
|
[Command.RequestPermission]: RequestPermissionPayload;
|
|
251
|
+
[Command.GetPermissions]: GetPermissionsPayload;
|
|
250
252
|
};
|
|
251
253
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
252
254
|
|
|
@@ -258,7 +260,8 @@ declare enum ResponseEvent {
|
|
|
258
260
|
MiniAppSignMessage = "miniapp-sign-message",
|
|
259
261
|
MiniAppSignTypedData = "miniapp-sign-typed-data",
|
|
260
262
|
MiniAppShareContacts = "miniapp-share-contacts",
|
|
261
|
-
MiniAppRequestPermission = "miniapp-request-permission"
|
|
263
|
+
MiniAppRequestPermission = "miniapp-request-permission",
|
|
264
|
+
MiniAppGetPermissions = "miniapp-get-permissions"
|
|
262
265
|
}
|
|
263
266
|
type MiniAppVerifyActionSuccessPayload = {
|
|
264
267
|
status: 'success';
|
|
@@ -313,12 +316,14 @@ type MiniAppSendTransactionSuccessPayload = {
|
|
|
313
316
|
chain: Network;
|
|
314
317
|
timestamp: string;
|
|
315
318
|
version: number;
|
|
319
|
+
mini_app_id?: string;
|
|
316
320
|
};
|
|
317
321
|
type MiniAppSendTransactionErrorPayload = {
|
|
318
322
|
status: 'error';
|
|
319
323
|
error_code: SendTransactionErrorCodes;
|
|
320
324
|
details?: Record<string, any>;
|
|
321
325
|
version: number;
|
|
326
|
+
mini_app_id?: string;
|
|
322
327
|
};
|
|
323
328
|
type MiniAppSendTransactionPayload = MiniAppSendTransactionSuccessPayload | MiniAppSendTransactionErrorPayload;
|
|
324
329
|
type MiniAppSignMessageSuccessPayload = {
|
|
@@ -377,6 +382,22 @@ type MiniAppRequestPermissionErrorPayload = {
|
|
|
377
382
|
version: number;
|
|
378
383
|
};
|
|
379
384
|
type MiniAppRequestPermissionPayload = MiniAppRequestPermissionSuccessPayload | MiniAppRequestPermissionErrorPayload;
|
|
385
|
+
type PermissionSettings = {
|
|
386
|
+
[K in Permission]?: any;
|
|
387
|
+
};
|
|
388
|
+
type MiniAppGetPermissionsSuccessPayload = {
|
|
389
|
+
status: 'success';
|
|
390
|
+
permissions: PermissionSettings;
|
|
391
|
+
version: number;
|
|
392
|
+
timestamp: string;
|
|
393
|
+
};
|
|
394
|
+
type MiniAppGetPermissionsErrorPayload = {
|
|
395
|
+
status: 'error';
|
|
396
|
+
error_code: GetPermissionsErrorCodes;
|
|
397
|
+
details: string;
|
|
398
|
+
version: number;
|
|
399
|
+
};
|
|
400
|
+
type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
|
|
380
401
|
type EventPayloadMap = {
|
|
381
402
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
382
403
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -386,6 +407,7 @@ type EventPayloadMap = {
|
|
|
386
407
|
[ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
|
|
387
408
|
[ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
|
|
388
409
|
[ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
|
|
410
|
+
[ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
|
|
389
411
|
};
|
|
390
412
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
391
413
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -425,6 +447,7 @@ declare class MiniKit {
|
|
|
425
447
|
signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload | null;
|
|
426
448
|
shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
|
|
427
449
|
requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
|
|
450
|
+
getPermissions: () => GetPermissionsPayload | null;
|
|
428
451
|
};
|
|
429
452
|
/**
|
|
430
453
|
* This object contains async versions of all the commands.
|
|
@@ -445,6 +468,7 @@ declare class MiniKit {
|
|
|
445
468
|
signTypedData: (payload: SignTypedDataInput) => AsyncHandlerReturn<SignTypedDataPayload | null, MiniAppSignTypedDataPayload>;
|
|
446
469
|
shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
|
|
447
470
|
requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
|
|
471
|
+
getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
|
|
448
472
|
};
|
|
449
473
|
}
|
|
450
474
|
|
|
@@ -488,4 +512,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
488
512
|
|
|
489
513
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
490
514
|
|
|
491
|
-
export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, Permission, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
|
515
|
+
export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type EventHandler, type EventPayload, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppRequestPermissionErrorPayload, type MiniAppRequestPermissionPayload, type MiniAppRequestPermissionSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppShareContactsErrorPayload, type MiniAppShareContactsPayload, type MiniAppShareContactsSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, Permission, type PermissionSettings, RequestPermissionErrorCodes, RequestPermissionErrorMessage, type RequestPermissionInput, type RequestPermissionPayload, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
package/build/index.js
CHANGED
|
@@ -267,30 +267,44 @@ var validateWalletAuthCommandInput = (params) => {
|
|
|
267
267
|
var isValidHex = (str) => {
|
|
268
268
|
return /^0x[0-9A-Fa-f]+$/.test(str);
|
|
269
269
|
};
|
|
270
|
-
var
|
|
271
|
-
if (typeof payload === "string"
|
|
270
|
+
var processPayload = (payload) => {
|
|
271
|
+
if (typeof payload === "boolean" || typeof payload === "string" || payload === null || payload === void 0) {
|
|
272
|
+
return payload;
|
|
273
|
+
}
|
|
274
|
+
if (typeof payload === "number") {
|
|
275
|
+
return String(payload);
|
|
276
|
+
}
|
|
272
277
|
if (Array.isArray(payload)) {
|
|
273
|
-
|
|
274
|
-
return { isValid };
|
|
278
|
+
return payload.map((value) => processPayload(value));
|
|
275
279
|
}
|
|
276
|
-
if (typeof payload === "object"
|
|
277
|
-
|
|
278
|
-
|
|
280
|
+
if (typeof payload === "object") {
|
|
281
|
+
const result = { ...payload };
|
|
282
|
+
if ("value" in result && result.value !== void 0) {
|
|
283
|
+
if (typeof result.value !== "string") {
|
|
284
|
+
result.value = String(result.value);
|
|
285
|
+
}
|
|
286
|
+
if (!isValidHex(result.value)) {
|
|
279
287
|
console.error(
|
|
280
288
|
"Transaction value must be a valid hex string",
|
|
281
|
-
|
|
289
|
+
result.value
|
|
290
|
+
);
|
|
291
|
+
throw new Error(
|
|
292
|
+
`Transaction value must be a valid hex string: ${result.value}`
|
|
282
293
|
);
|
|
283
|
-
return { isValid: false };
|
|
284
294
|
}
|
|
285
295
|
}
|
|
286
|
-
const
|
|
287
|
-
(
|
|
288
|
-
|
|
289
|
-
|
|
296
|
+
for (const key in result) {
|
|
297
|
+
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
298
|
+
result[key] = processPayload(result[key]);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return result;
|
|
290
302
|
}
|
|
291
|
-
return
|
|
303
|
+
return payload;
|
|
304
|
+
};
|
|
305
|
+
var validateSendTransactionPayload = (payload) => {
|
|
306
|
+
return processPayload(payload);
|
|
292
307
|
};
|
|
293
|
-
var validateSendTransactionPayload = (payload) => validate(payload);
|
|
294
308
|
|
|
295
309
|
// helpers/usernames/index.ts
|
|
296
310
|
var getUserProfile = async (address) => {
|
|
@@ -317,6 +331,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
317
331
|
Command2["SignTypedData"] = "sign-typed-data";
|
|
318
332
|
Command2["ShareContacts"] = "share-contacts";
|
|
319
333
|
Command2["RequestPermission"] = "request-permission";
|
|
334
|
+
Command2["GetPermissions"] = "get-permissions";
|
|
320
335
|
return Command2;
|
|
321
336
|
})(Command || {});
|
|
322
337
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
@@ -328,7 +343,7 @@ var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
|
328
343
|
import { AppErrorCodes } from "@worldcoin/idkit-core";
|
|
329
344
|
import { AppErrorCodes as AppErrorCodes2 } from "@worldcoin/idkit-core";
|
|
330
345
|
var VerificationErrorMessage = {
|
|
331
|
-
[AppErrorCodes.VerificationRejected]: "You
|
|
346
|
+
[AppErrorCodes.VerificationRejected]: "You've cancelled the request in World App.",
|
|
332
347
|
[AppErrorCodes.MaxVerificationsReached]: "You have already verified the maximum number of times for this action.",
|
|
333
348
|
[AppErrorCodes.CredentialUnavailable]: "It seems you do not have the verification level required by this app.",
|
|
334
349
|
[AppErrorCodes.MalformedRequest]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
@@ -352,7 +367,7 @@ var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
|
352
367
|
})(PaymentErrorCodes || {});
|
|
353
368
|
var PaymentErrorMessage = {
|
|
354
369
|
["input_error" /* InputError */]: "There was a problem with this request. Please try again or contact the app owner.",
|
|
355
|
-
["payment_rejected" /* PaymentRejected */]: "You
|
|
370
|
+
["payment_rejected" /* PaymentRejected */]: "You've cancelled the payment in World App.",
|
|
356
371
|
["invalid_receiver" /* InvalidReceiver */]: "The receiver address is invalid. Please contact the app owner.",
|
|
357
372
|
["insufficient_balance" /* InsufficientBalance */]: "You do not have enough balance to complete this transaction.",
|
|
358
373
|
["transaction_failed" /* TransactionFailed */]: "The transaction failed. Please try again.",
|
|
@@ -387,6 +402,9 @@ var SendTransactionErrorCodes = /* @__PURE__ */ ((SendTransactionErrorCodes2) =>
|
|
|
387
402
|
SendTransactionErrorCodes2["DisallowedOperation"] = "disallowed_operation";
|
|
388
403
|
SendTransactionErrorCodes2["InvalidContract"] = "invalid_contract";
|
|
389
404
|
SendTransactionErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
405
|
+
SendTransactionErrorCodes2["DailyTxLimitReached"] = "daily_tx_limit_reached";
|
|
406
|
+
SendTransactionErrorCodes2["PermittedAmountExceedsSlippage"] = "permitted_amount_exceeds_slippage";
|
|
407
|
+
SendTransactionErrorCodes2["PermittedAmountNotFound"] = "permitted_amount_not_found";
|
|
390
408
|
return SendTransactionErrorCodes2;
|
|
391
409
|
})(SendTransactionErrorCodes || {});
|
|
392
410
|
var SendTransactionErrorMessage = {
|
|
@@ -398,7 +416,10 @@ var SendTransactionErrorMessage = {
|
|
|
398
416
|
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
399
417
|
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
400
418
|
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
401
|
-
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
419
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious.",
|
|
420
|
+
["daily_tx_limit_reached" /* DailyTxLimitReached */]: "Daily transaction limit reached. Max 100 transactions per day. Wait until the next day.",
|
|
421
|
+
["permitted_amount_exceeds_slippage" /* PermittedAmountExceedsSlippage */]: "Permitted amount exceeds slippage. You must spend at least 90% of the permitted amount.",
|
|
422
|
+
["permitted_amount_not_found" /* PermittedAmountNotFound */]: "Permitted amount not found in permit2 payload."
|
|
402
423
|
};
|
|
403
424
|
var SignMessageErrorCodes = /* @__PURE__ */ ((SignMessageErrorCodes2) => {
|
|
404
425
|
SignMessageErrorCodes2["InvalidMessage"] = "invalid_message";
|
|
@@ -422,7 +443,16 @@ var SignTypedDataErrorCodes = /* @__PURE__ */ ((SignTypedDataErrorCodes2) => {
|
|
|
422
443
|
SignTypedDataErrorCodes2["MaliciousOperation"] = "malicious_operation";
|
|
423
444
|
return SignTypedDataErrorCodes2;
|
|
424
445
|
})(SignTypedDataErrorCodes || {});
|
|
425
|
-
var SignTypedDataErrorMessage =
|
|
446
|
+
var SignTypedDataErrorMessage = {
|
|
447
|
+
["invalid_operation" /* InvalidOperation */]: "Transaction included an operation that was invalid",
|
|
448
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
449
|
+
["input_error" /* InputError */]: "Invalid payload.",
|
|
450
|
+
["simulation_failed" /* SimulationFailed */]: "The transaction simulation failed.",
|
|
451
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again.",
|
|
452
|
+
["disallowed_operation" /* DisallowedOperation */]: "The operation requested is not allowed. Please refer to the docs.",
|
|
453
|
+
["invalid_contract" /* InvalidContract */]: "The contract address is not allowed for your application. Please check your developer portal configurations",
|
|
454
|
+
["malicious_operation" /* MaliciousOperation */]: "The operation requested is considered malicious."
|
|
455
|
+
};
|
|
426
456
|
var MiniKitInstallErrorCodes = /* @__PURE__ */ ((MiniKitInstallErrorCodes2) => {
|
|
427
457
|
MiniKitInstallErrorCodes2["Unknown"] = "unknown";
|
|
428
458
|
MiniKitInstallErrorCodes2["AlreadyInstalled"] = "already_installed";
|
|
@@ -464,6 +494,13 @@ var RequestPermissionErrorMessage = {
|
|
|
464
494
|
["already_granted" /* AlreadyGranted */]: "If the user has already granted this mini app permission",
|
|
465
495
|
["unsupported_permission" /* UnsupportedPermission */]: "The permission requested is not supported by this mini app"
|
|
466
496
|
};
|
|
497
|
+
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
498
|
+
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
499
|
+
return GetPermissionsErrorCodes2;
|
|
500
|
+
})(GetPermissionsErrorCodes || {});
|
|
501
|
+
var GetPermissionsErrorMessage = {
|
|
502
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
503
|
+
};
|
|
467
504
|
|
|
468
505
|
// helpers/send-webview-event.ts
|
|
469
506
|
var sendWebviewEvent = (payload) => {
|
|
@@ -484,6 +521,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
484
521
|
ResponseEvent2["MiniAppSignTypedData"] = "miniapp-sign-typed-data";
|
|
485
522
|
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
486
523
|
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
524
|
+
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
487
525
|
return ResponseEvent2;
|
|
488
526
|
})(ResponseEvent || {});
|
|
489
527
|
|
|
@@ -615,7 +653,8 @@ _MiniKit.commandVersion = {
|
|
|
615
653
|
["sign-message" /* SignMessage */]: 1,
|
|
616
654
|
["sign-typed-data" /* SignTypedData */]: 1,
|
|
617
655
|
["share-contacts" /* ShareContacts */]: 1,
|
|
618
|
-
["request-permission" /* RequestPermission */]: 1
|
|
656
|
+
["request-permission" /* RequestPermission */]: 1,
|
|
657
|
+
["get-permissions" /* GetPermissions */]: 1
|
|
619
658
|
};
|
|
620
659
|
_MiniKit.isCommandAvailable = {
|
|
621
660
|
["verify" /* Verify */]: false,
|
|
@@ -625,7 +664,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
625
664
|
["sign-message" /* SignMessage */]: false,
|
|
626
665
|
["sign-typed-data" /* SignTypedData */]: false,
|
|
627
666
|
["share-contacts" /* ShareContacts */]: false,
|
|
628
|
-
["request-permission" /* RequestPermission */]: false
|
|
667
|
+
["request-permission" /* RequestPermission */]: false,
|
|
668
|
+
["get-permissions" /* GetPermissions */]: false
|
|
629
669
|
};
|
|
630
670
|
_MiniKit.listeners = {
|
|
631
671
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -643,6 +683,8 @@ _MiniKit.listeners = {
|
|
|
643
683
|
["miniapp-share-contacts" /* MiniAppShareContacts */]: () => {
|
|
644
684
|
},
|
|
645
685
|
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
686
|
+
},
|
|
687
|
+
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
646
688
|
}
|
|
647
689
|
};
|
|
648
690
|
_MiniKit.appId = null;
|
|
@@ -754,18 +796,13 @@ _MiniKit.commands = {
|
|
|
754
796
|
);
|
|
755
797
|
return null;
|
|
756
798
|
}
|
|
757
|
-
|
|
758
|
-
console.error(
|
|
759
|
-
"Invalid sendTransaction payload - some object properties are not strings"
|
|
760
|
-
);
|
|
761
|
-
return null;
|
|
762
|
-
}
|
|
799
|
+
const validatedPayload = validateSendTransactionPayload(payload);
|
|
763
800
|
sendMiniKitEvent({
|
|
764
801
|
command: "send-transaction" /* SendTransaction */,
|
|
765
802
|
version: 1,
|
|
766
|
-
payload
|
|
803
|
+
payload: validatedPayload
|
|
767
804
|
});
|
|
768
|
-
return
|
|
805
|
+
return validatedPayload;
|
|
769
806
|
},
|
|
770
807
|
signMessage: (payload) => {
|
|
771
808
|
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["sign-message" /* SignMessage */]) {
|
|
@@ -822,6 +859,22 @@ _MiniKit.commands = {
|
|
|
822
859
|
payload
|
|
823
860
|
});
|
|
824
861
|
return payload;
|
|
862
|
+
},
|
|
863
|
+
getPermissions: () => {
|
|
864
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["get-permissions" /* GetPermissions */]) {
|
|
865
|
+
console.error(
|
|
866
|
+
"'getPermissions' command is unavailable. Check MiniKit.install() or update the app version"
|
|
867
|
+
);
|
|
868
|
+
return null;
|
|
869
|
+
}
|
|
870
|
+
sendMiniKitEvent({
|
|
871
|
+
command: "get-permissions" /* GetPermissions */,
|
|
872
|
+
version: 1,
|
|
873
|
+
payload: {}
|
|
874
|
+
});
|
|
875
|
+
return {
|
|
876
|
+
status: "sent"
|
|
877
|
+
};
|
|
825
878
|
}
|
|
826
879
|
};
|
|
827
880
|
/**
|
|
@@ -946,6 +999,20 @@ _MiniKit.commandsAsync = {
|
|
|
946
999
|
reject(error);
|
|
947
1000
|
}
|
|
948
1001
|
});
|
|
1002
|
+
},
|
|
1003
|
+
getPermissions: async () => {
|
|
1004
|
+
return new Promise(async (resolve, reject) => {
|
|
1005
|
+
try {
|
|
1006
|
+
const response = await _MiniKit.awaitCommand(
|
|
1007
|
+
"miniapp-get-permissions" /* MiniAppGetPermissions */,
|
|
1008
|
+
"get-permissions" /* GetPermissions */,
|
|
1009
|
+
() => _MiniKit.commands.getPermissions()
|
|
1010
|
+
);
|
|
1011
|
+
resolve(response);
|
|
1012
|
+
} catch (error) {
|
|
1013
|
+
reject(error);
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
949
1016
|
}
|
|
950
1017
|
};
|
|
951
1018
|
var MiniKit = _MiniKit;
|
|
@@ -1009,6 +1076,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
1009
1076
|
};
|
|
1010
1077
|
export {
|
|
1011
1078
|
Command,
|
|
1079
|
+
GetPermissionsErrorCodes,
|
|
1080
|
+
GetPermissionsErrorMessage,
|
|
1012
1081
|
MiniKit,
|
|
1013
1082
|
MiniKitInstallErrorCodes,
|
|
1014
1083
|
MiniKitInstallErrorMessage,
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"ts-node": "^10.9.2",
|
|
17
17
|
"tsup": "^8.0.2",
|
|
18
18
|
"typescript": "^5.4.5",
|
|
19
|
-
"viem": "
|
|
19
|
+
"viem": "2.23.5"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">= 16"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"main": "index.ts",
|
|
47
47
|
"name": "@worldcoin/minikit-js",
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"viem": "
|
|
49
|
+
"viem": "2.23.5"
|
|
50
50
|
},
|
|
51
51
|
"private": false,
|
|
52
52
|
"type": "module",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
]
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
"version": "1.
|
|
62
|
+
"version": "1.7.0",
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "tsup",
|
|
65
65
|
"dev": "tsup --watch",
|