@worldcoin/minikit-js 1.7.0 → 1.7.1
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 +49 -2
- package/build/index.d.cts +39 -3
- package/build/index.d.ts +39 -3
- package/build/index.js +47 -2
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -35,6 +35,8 @@ __export(core_exports, {
|
|
|
35
35
|
RequestPermissionErrorMessage: () => RequestPermissionErrorMessage,
|
|
36
36
|
ResponseEvent: () => ResponseEvent,
|
|
37
37
|
SAFE_CONTRACT_ABI: () => SAFE_CONTRACT_ABI,
|
|
38
|
+
SendHapticFeedbackErrorCodes: () => SendHapticFeedbackErrorCodes,
|
|
39
|
+
SendHapticFeedbackErrorMessage: () => SendHapticFeedbackErrorMessage,
|
|
38
40
|
SendTransactionErrorCodes: () => SendTransactionErrorCodes,
|
|
39
41
|
SendTransactionErrorMessage: () => SendTransactionErrorMessage,
|
|
40
42
|
ShareContactsErrorCodes: () => ShareContactsErrorCodes,
|
|
@@ -386,6 +388,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
386
388
|
Command2["ShareContacts"] = "share-contacts";
|
|
387
389
|
Command2["RequestPermission"] = "request-permission";
|
|
388
390
|
Command2["GetPermissions"] = "get-permissions";
|
|
391
|
+
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
389
392
|
return Command2;
|
|
390
393
|
})(Command || {});
|
|
391
394
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
@@ -555,6 +558,15 @@ var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
|
555
558
|
var GetPermissionsErrorMessage = {
|
|
556
559
|
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
557
560
|
};
|
|
561
|
+
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
562
|
+
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
563
|
+
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
564
|
+
return SendHapticFeedbackErrorCodes2;
|
|
565
|
+
})(SendHapticFeedbackErrorCodes || {});
|
|
566
|
+
var SendHapticFeedbackErrorMessage = {
|
|
567
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
568
|
+
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
569
|
+
};
|
|
558
570
|
|
|
559
571
|
// helpers/send-webview-event.ts
|
|
560
572
|
var sendWebviewEvent = (payload) => {
|
|
@@ -576,6 +588,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
576
588
|
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
577
589
|
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
578
590
|
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
591
|
+
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
579
592
|
return ResponseEvent2;
|
|
580
593
|
})(ResponseEvent || {});
|
|
581
594
|
|
|
@@ -708,7 +721,8 @@ _MiniKit.commandVersion = {
|
|
|
708
721
|
["sign-typed-data" /* SignTypedData */]: 1,
|
|
709
722
|
["share-contacts" /* ShareContacts */]: 1,
|
|
710
723
|
["request-permission" /* RequestPermission */]: 1,
|
|
711
|
-
["get-permissions" /* GetPermissions */]: 1
|
|
724
|
+
["get-permissions" /* GetPermissions */]: 1,
|
|
725
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
712
726
|
};
|
|
713
727
|
_MiniKit.isCommandAvailable = {
|
|
714
728
|
["verify" /* Verify */]: false,
|
|
@@ -719,7 +733,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
719
733
|
["sign-typed-data" /* SignTypedData */]: false,
|
|
720
734
|
["share-contacts" /* ShareContacts */]: false,
|
|
721
735
|
["request-permission" /* RequestPermission */]: false,
|
|
722
|
-
["get-permissions" /* GetPermissions */]: false
|
|
736
|
+
["get-permissions" /* GetPermissions */]: false,
|
|
737
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
723
738
|
};
|
|
724
739
|
_MiniKit.listeners = {
|
|
725
740
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -739,6 +754,8 @@ _MiniKit.listeners = {
|
|
|
739
754
|
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
740
755
|
},
|
|
741
756
|
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
757
|
+
},
|
|
758
|
+
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
742
759
|
}
|
|
743
760
|
};
|
|
744
761
|
_MiniKit.appId = null;
|
|
@@ -929,6 +946,20 @@ _MiniKit.commands = {
|
|
|
929
946
|
return {
|
|
930
947
|
status: "sent"
|
|
931
948
|
};
|
|
949
|
+
},
|
|
950
|
+
sendHapticFeedback: (payload) => {
|
|
951
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-haptic-feedback" /* SendHapticFeedback */]) {
|
|
952
|
+
console.error(
|
|
953
|
+
"'sendHapticFeedback' command is unavailable. Check MiniKit.install() or update the app version"
|
|
954
|
+
);
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
sendMiniKitEvent({
|
|
958
|
+
command: "send-haptic-feedback" /* SendHapticFeedback */,
|
|
959
|
+
version: 1,
|
|
960
|
+
payload
|
|
961
|
+
});
|
|
962
|
+
return payload;
|
|
932
963
|
}
|
|
933
964
|
};
|
|
934
965
|
/**
|
|
@@ -1067,6 +1098,20 @@ _MiniKit.commandsAsync = {
|
|
|
1067
1098
|
reject(error);
|
|
1068
1099
|
}
|
|
1069
1100
|
});
|
|
1101
|
+
},
|
|
1102
|
+
sendHapticFeedback: async (payload) => {
|
|
1103
|
+
return new Promise(async (resolve, reject) => {
|
|
1104
|
+
try {
|
|
1105
|
+
const response = await _MiniKit.awaitCommand(
|
|
1106
|
+
"miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
|
|
1107
|
+
"send-haptic-feedback" /* SendHapticFeedback */,
|
|
1108
|
+
() => _MiniKit.commands.sendHapticFeedback(payload)
|
|
1109
|
+
);
|
|
1110
|
+
resolve(response);
|
|
1111
|
+
} catch (error) {
|
|
1112
|
+
reject(error);
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1070
1115
|
}
|
|
1071
1116
|
};
|
|
1072
1117
|
var MiniKit = _MiniKit;
|
|
@@ -1143,6 +1188,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
1143
1188
|
RequestPermissionErrorMessage,
|
|
1144
1189
|
ResponseEvent,
|
|
1145
1190
|
SAFE_CONTRACT_ABI,
|
|
1191
|
+
SendHapticFeedbackErrorCodes,
|
|
1192
|
+
SendHapticFeedbackErrorMessage,
|
|
1146
1193
|
SendTransactionErrorCodes,
|
|
1147
1194
|
SendTransactionErrorMessage,
|
|
1148
1195
|
ShareContactsErrorCodes,
|
package/build/index.d.cts
CHANGED
|
@@ -120,6 +120,14 @@ declare enum GetPermissionsErrorCodes {
|
|
|
120
120
|
declare const GetPermissionsErrorMessage: {
|
|
121
121
|
generic_error: string;
|
|
122
122
|
};
|
|
123
|
+
declare enum SendHapticFeedbackErrorCodes {
|
|
124
|
+
GenericError = "generic_error",
|
|
125
|
+
UserRejected = "user_rejected"
|
|
126
|
+
}
|
|
127
|
+
declare const SendHapticFeedbackErrorMessage: {
|
|
128
|
+
generic_error: string;
|
|
129
|
+
user_rejected: string;
|
|
130
|
+
};
|
|
123
131
|
|
|
124
132
|
declare enum Tokens {
|
|
125
133
|
USDCE = "USDCE",
|
|
@@ -161,7 +169,8 @@ declare enum Command {
|
|
|
161
169
|
SignTypedData = "sign-typed-data",
|
|
162
170
|
ShareContacts = "share-contacts",
|
|
163
171
|
RequestPermission = "request-permission",
|
|
164
|
-
GetPermissions = "get-permissions"
|
|
172
|
+
GetPermissions = "get-permissions",
|
|
173
|
+
SendHapticFeedback = "send-haptic-feedback"
|
|
165
174
|
}
|
|
166
175
|
type WebViewBasePayload = {
|
|
167
176
|
command: Command;
|
|
@@ -239,6 +248,17 @@ type RequestPermissionInput = {
|
|
|
239
248
|
type RequestPermissionPayload = RequestPermissionInput;
|
|
240
249
|
type GetPermissionsInput = {};
|
|
241
250
|
type GetPermissionsPayload = GetPermissionsInput;
|
|
251
|
+
type SendHapticFeedbackInput = {
|
|
252
|
+
hapticsType: 'notification';
|
|
253
|
+
style: 'error' | 'success' | 'warning';
|
|
254
|
+
} | {
|
|
255
|
+
hapticsType: 'selection-changed';
|
|
256
|
+
style?: never;
|
|
257
|
+
} | {
|
|
258
|
+
hapticsType: 'impact';
|
|
259
|
+
style: 'light' | 'medium' | 'heavy';
|
|
260
|
+
};
|
|
261
|
+
type SendHapticFeedbackPayload = SendHapticFeedbackInput;
|
|
242
262
|
type CommandReturnPayloadMap = {
|
|
243
263
|
[Command.Verify]: VerifyCommandPayload;
|
|
244
264
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -249,6 +269,7 @@ type CommandReturnPayloadMap = {
|
|
|
249
269
|
[Command.ShareContacts]: ShareContactsPayload;
|
|
250
270
|
[Command.RequestPermission]: RequestPermissionPayload;
|
|
251
271
|
[Command.GetPermissions]: GetPermissionsPayload;
|
|
272
|
+
[Command.SendHapticFeedback]: SendHapticFeedbackPayload;
|
|
252
273
|
};
|
|
253
274
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
254
275
|
|
|
@@ -261,7 +282,8 @@ declare enum ResponseEvent {
|
|
|
261
282
|
MiniAppSignTypedData = "miniapp-sign-typed-data",
|
|
262
283
|
MiniAppShareContacts = "miniapp-share-contacts",
|
|
263
284
|
MiniAppRequestPermission = "miniapp-request-permission",
|
|
264
|
-
MiniAppGetPermissions = "miniapp-get-permissions"
|
|
285
|
+
MiniAppGetPermissions = "miniapp-get-permissions",
|
|
286
|
+
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback"
|
|
265
287
|
}
|
|
266
288
|
type MiniAppVerifyActionSuccessPayload = {
|
|
267
289
|
status: 'success';
|
|
@@ -398,6 +420,17 @@ type MiniAppGetPermissionsErrorPayload = {
|
|
|
398
420
|
version: number;
|
|
399
421
|
};
|
|
400
422
|
type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
|
|
423
|
+
type MiniAppSendHapticFeedbackSuccessPayload = {
|
|
424
|
+
status: 'success';
|
|
425
|
+
version: number;
|
|
426
|
+
timestamp: string;
|
|
427
|
+
};
|
|
428
|
+
type MiniAppSendHapticFeedbackErrorPayload = {
|
|
429
|
+
status: 'error';
|
|
430
|
+
error_code: SendHapticFeedbackErrorCodes;
|
|
431
|
+
version: number;
|
|
432
|
+
};
|
|
433
|
+
type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
|
|
401
434
|
type EventPayloadMap = {
|
|
402
435
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
403
436
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -408,6 +441,7 @@ type EventPayloadMap = {
|
|
|
408
441
|
[ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
|
|
409
442
|
[ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
|
|
410
443
|
[ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
|
|
444
|
+
[ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
|
|
411
445
|
};
|
|
412
446
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
413
447
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -448,6 +482,7 @@ declare class MiniKit {
|
|
|
448
482
|
shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
|
|
449
483
|
requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
|
|
450
484
|
getPermissions: () => GetPermissionsPayload | null;
|
|
485
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
451
486
|
};
|
|
452
487
|
/**
|
|
453
488
|
* This object contains async versions of all the commands.
|
|
@@ -469,6 +504,7 @@ declare class MiniKit {
|
|
|
469
504
|
shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
|
|
470
505
|
requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
|
|
471
506
|
getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
|
|
507
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
472
508
|
};
|
|
473
509
|
}
|
|
474
510
|
|
|
@@ -512,4 +548,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
512
548
|
|
|
513
549
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
514
550
|
|
|
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 };
|
|
551
|
+
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 MiniAppSendHapticFeedbackErrorPayload, type MiniAppSendHapticFeedbackPayload, type MiniAppSendHapticFeedbackSuccessPayload, 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, SendHapticFeedbackErrorCodes, SendHapticFeedbackErrorMessage, type SendHapticFeedbackInput, type SendHapticFeedbackPayload, 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
|
@@ -120,6 +120,14 @@ declare enum GetPermissionsErrorCodes {
|
|
|
120
120
|
declare const GetPermissionsErrorMessage: {
|
|
121
121
|
generic_error: string;
|
|
122
122
|
};
|
|
123
|
+
declare enum SendHapticFeedbackErrorCodes {
|
|
124
|
+
GenericError = "generic_error",
|
|
125
|
+
UserRejected = "user_rejected"
|
|
126
|
+
}
|
|
127
|
+
declare const SendHapticFeedbackErrorMessage: {
|
|
128
|
+
generic_error: string;
|
|
129
|
+
user_rejected: string;
|
|
130
|
+
};
|
|
123
131
|
|
|
124
132
|
declare enum Tokens {
|
|
125
133
|
USDCE = "USDCE",
|
|
@@ -161,7 +169,8 @@ declare enum Command {
|
|
|
161
169
|
SignTypedData = "sign-typed-data",
|
|
162
170
|
ShareContacts = "share-contacts",
|
|
163
171
|
RequestPermission = "request-permission",
|
|
164
|
-
GetPermissions = "get-permissions"
|
|
172
|
+
GetPermissions = "get-permissions",
|
|
173
|
+
SendHapticFeedback = "send-haptic-feedback"
|
|
165
174
|
}
|
|
166
175
|
type WebViewBasePayload = {
|
|
167
176
|
command: Command;
|
|
@@ -239,6 +248,17 @@ type RequestPermissionInput = {
|
|
|
239
248
|
type RequestPermissionPayload = RequestPermissionInput;
|
|
240
249
|
type GetPermissionsInput = {};
|
|
241
250
|
type GetPermissionsPayload = GetPermissionsInput;
|
|
251
|
+
type SendHapticFeedbackInput = {
|
|
252
|
+
hapticsType: 'notification';
|
|
253
|
+
style: 'error' | 'success' | 'warning';
|
|
254
|
+
} | {
|
|
255
|
+
hapticsType: 'selection-changed';
|
|
256
|
+
style?: never;
|
|
257
|
+
} | {
|
|
258
|
+
hapticsType: 'impact';
|
|
259
|
+
style: 'light' | 'medium' | 'heavy';
|
|
260
|
+
};
|
|
261
|
+
type SendHapticFeedbackPayload = SendHapticFeedbackInput;
|
|
242
262
|
type CommandReturnPayloadMap = {
|
|
243
263
|
[Command.Verify]: VerifyCommandPayload;
|
|
244
264
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -249,6 +269,7 @@ type CommandReturnPayloadMap = {
|
|
|
249
269
|
[Command.ShareContacts]: ShareContactsPayload;
|
|
250
270
|
[Command.RequestPermission]: RequestPermissionPayload;
|
|
251
271
|
[Command.GetPermissions]: GetPermissionsPayload;
|
|
272
|
+
[Command.SendHapticFeedback]: SendHapticFeedbackPayload;
|
|
252
273
|
};
|
|
253
274
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
254
275
|
|
|
@@ -261,7 +282,8 @@ declare enum ResponseEvent {
|
|
|
261
282
|
MiniAppSignTypedData = "miniapp-sign-typed-data",
|
|
262
283
|
MiniAppShareContacts = "miniapp-share-contacts",
|
|
263
284
|
MiniAppRequestPermission = "miniapp-request-permission",
|
|
264
|
-
MiniAppGetPermissions = "miniapp-get-permissions"
|
|
285
|
+
MiniAppGetPermissions = "miniapp-get-permissions",
|
|
286
|
+
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback"
|
|
265
287
|
}
|
|
266
288
|
type MiniAppVerifyActionSuccessPayload = {
|
|
267
289
|
status: 'success';
|
|
@@ -398,6 +420,17 @@ type MiniAppGetPermissionsErrorPayload = {
|
|
|
398
420
|
version: number;
|
|
399
421
|
};
|
|
400
422
|
type MiniAppGetPermissionsPayload = MiniAppGetPermissionsSuccessPayload | MiniAppGetPermissionsErrorPayload;
|
|
423
|
+
type MiniAppSendHapticFeedbackSuccessPayload = {
|
|
424
|
+
status: 'success';
|
|
425
|
+
version: number;
|
|
426
|
+
timestamp: string;
|
|
427
|
+
};
|
|
428
|
+
type MiniAppSendHapticFeedbackErrorPayload = {
|
|
429
|
+
status: 'error';
|
|
430
|
+
error_code: SendHapticFeedbackErrorCodes;
|
|
431
|
+
version: number;
|
|
432
|
+
};
|
|
433
|
+
type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
|
|
401
434
|
type EventPayloadMap = {
|
|
402
435
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
403
436
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -408,6 +441,7 @@ type EventPayloadMap = {
|
|
|
408
441
|
[ResponseEvent.MiniAppShareContacts]: MiniAppShareContactsPayload;
|
|
409
442
|
[ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
|
|
410
443
|
[ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
|
|
444
|
+
[ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
|
|
411
445
|
};
|
|
412
446
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
413
447
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -448,6 +482,7 @@ declare class MiniKit {
|
|
|
448
482
|
shareContacts: (payload: ShareContactsPayload) => ShareContactsPayload | null;
|
|
449
483
|
requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
|
|
450
484
|
getPermissions: () => GetPermissionsPayload | null;
|
|
485
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
451
486
|
};
|
|
452
487
|
/**
|
|
453
488
|
* This object contains async versions of all the commands.
|
|
@@ -469,6 +504,7 @@ declare class MiniKit {
|
|
|
469
504
|
shareContacts: (payload: ShareContactsPayload) => AsyncHandlerReturn<ShareContactsPayload | null, MiniAppShareContactsPayload>;
|
|
470
505
|
requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
|
|
471
506
|
getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
|
|
507
|
+
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
472
508
|
};
|
|
473
509
|
}
|
|
474
510
|
|
|
@@ -512,4 +548,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
512
548
|
|
|
513
549
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
514
550
|
|
|
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 };
|
|
551
|
+
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 MiniAppSendHapticFeedbackErrorPayload, type MiniAppSendHapticFeedbackPayload, type MiniAppSendHapticFeedbackSuccessPayload, 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, SendHapticFeedbackErrorCodes, SendHapticFeedbackErrorMessage, type SendHapticFeedbackInput, type SendHapticFeedbackPayload, 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
|
@@ -332,6 +332,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
332
332
|
Command2["ShareContacts"] = "share-contacts";
|
|
333
333
|
Command2["RequestPermission"] = "request-permission";
|
|
334
334
|
Command2["GetPermissions"] = "get-permissions";
|
|
335
|
+
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
335
336
|
return Command2;
|
|
336
337
|
})(Command || {});
|
|
337
338
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
@@ -501,6 +502,15 @@ var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
|
501
502
|
var GetPermissionsErrorMessage = {
|
|
502
503
|
["generic_error" /* GenericError */]: "Something unexpected went wrong. Please try again."
|
|
503
504
|
};
|
|
505
|
+
var SendHapticFeedbackErrorCodes = /* @__PURE__ */ ((SendHapticFeedbackErrorCodes2) => {
|
|
506
|
+
SendHapticFeedbackErrorCodes2["GenericError"] = "generic_error";
|
|
507
|
+
SendHapticFeedbackErrorCodes2["UserRejected"] = "user_rejected";
|
|
508
|
+
return SendHapticFeedbackErrorCodes2;
|
|
509
|
+
})(SendHapticFeedbackErrorCodes || {});
|
|
510
|
+
var SendHapticFeedbackErrorMessage = {
|
|
511
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong.",
|
|
512
|
+
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
513
|
+
};
|
|
504
514
|
|
|
505
515
|
// helpers/send-webview-event.ts
|
|
506
516
|
var sendWebviewEvent = (payload) => {
|
|
@@ -522,6 +532,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
522
532
|
ResponseEvent2["MiniAppShareContacts"] = "miniapp-share-contacts";
|
|
523
533
|
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
524
534
|
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
535
|
+
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
525
536
|
return ResponseEvent2;
|
|
526
537
|
})(ResponseEvent || {});
|
|
527
538
|
|
|
@@ -654,7 +665,8 @@ _MiniKit.commandVersion = {
|
|
|
654
665
|
["sign-typed-data" /* SignTypedData */]: 1,
|
|
655
666
|
["share-contacts" /* ShareContacts */]: 1,
|
|
656
667
|
["request-permission" /* RequestPermission */]: 1,
|
|
657
|
-
["get-permissions" /* GetPermissions */]: 1
|
|
668
|
+
["get-permissions" /* GetPermissions */]: 1,
|
|
669
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
658
670
|
};
|
|
659
671
|
_MiniKit.isCommandAvailable = {
|
|
660
672
|
["verify" /* Verify */]: false,
|
|
@@ -665,7 +677,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
665
677
|
["sign-typed-data" /* SignTypedData */]: false,
|
|
666
678
|
["share-contacts" /* ShareContacts */]: false,
|
|
667
679
|
["request-permission" /* RequestPermission */]: false,
|
|
668
|
-
["get-permissions" /* GetPermissions */]: false
|
|
680
|
+
["get-permissions" /* GetPermissions */]: false,
|
|
681
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
669
682
|
};
|
|
670
683
|
_MiniKit.listeners = {
|
|
671
684
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -685,6 +698,8 @@ _MiniKit.listeners = {
|
|
|
685
698
|
["miniapp-request-permission" /* MiniAppRequestPermission */]: () => {
|
|
686
699
|
},
|
|
687
700
|
["miniapp-get-permissions" /* MiniAppGetPermissions */]: () => {
|
|
701
|
+
},
|
|
702
|
+
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
688
703
|
}
|
|
689
704
|
};
|
|
690
705
|
_MiniKit.appId = null;
|
|
@@ -875,6 +890,20 @@ _MiniKit.commands = {
|
|
|
875
890
|
return {
|
|
876
891
|
status: "sent"
|
|
877
892
|
};
|
|
893
|
+
},
|
|
894
|
+
sendHapticFeedback: (payload) => {
|
|
895
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["send-haptic-feedback" /* SendHapticFeedback */]) {
|
|
896
|
+
console.error(
|
|
897
|
+
"'sendHapticFeedback' command is unavailable. Check MiniKit.install() or update the app version"
|
|
898
|
+
);
|
|
899
|
+
return null;
|
|
900
|
+
}
|
|
901
|
+
sendMiniKitEvent({
|
|
902
|
+
command: "send-haptic-feedback" /* SendHapticFeedback */,
|
|
903
|
+
version: 1,
|
|
904
|
+
payload
|
|
905
|
+
});
|
|
906
|
+
return payload;
|
|
878
907
|
}
|
|
879
908
|
};
|
|
880
909
|
/**
|
|
@@ -1013,6 +1042,20 @@ _MiniKit.commandsAsync = {
|
|
|
1013
1042
|
reject(error);
|
|
1014
1043
|
}
|
|
1015
1044
|
});
|
|
1045
|
+
},
|
|
1046
|
+
sendHapticFeedback: async (payload) => {
|
|
1047
|
+
return new Promise(async (resolve, reject) => {
|
|
1048
|
+
try {
|
|
1049
|
+
const response = await _MiniKit.awaitCommand(
|
|
1050
|
+
"miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */,
|
|
1051
|
+
"send-haptic-feedback" /* SendHapticFeedback */,
|
|
1052
|
+
() => _MiniKit.commands.sendHapticFeedback(payload)
|
|
1053
|
+
);
|
|
1054
|
+
resolve(response);
|
|
1055
|
+
} catch (error) {
|
|
1056
|
+
reject(error);
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
1016
1059
|
}
|
|
1017
1060
|
};
|
|
1018
1061
|
var MiniKit = _MiniKit;
|
|
@@ -1090,6 +1133,8 @@ export {
|
|
|
1090
1133
|
RequestPermissionErrorMessage,
|
|
1091
1134
|
ResponseEvent,
|
|
1092
1135
|
SAFE_CONTRACT_ABI,
|
|
1136
|
+
SendHapticFeedbackErrorCodes,
|
|
1137
|
+
SendHapticFeedbackErrorMessage,
|
|
1093
1138
|
SendTransactionErrorCodes,
|
|
1094
1139
|
SendTransactionErrorMessage,
|
|
1095
1140
|
ShareContactsErrorCodes,
|