@worldcoin/minikit-js 1.9.4 → 1.9.5
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/{chunk-VOZXVH3R.js → chunk-HO7P24JI.js} +119 -43
- package/build/index.cjs +119 -43
- package/build/index.d.cts +53 -33
- package/build/index.d.ts +53 -33
- package/build/index.js +1 -1
- package/build/minikit-provider.cjs +117 -42
- package/build/minikit-provider.js +1 -1
- package/index.ts +1 -1
- package/package.json +1 -1
|
@@ -325,6 +325,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
325
325
|
Command2["RequestPermission"] = "request-permission";
|
|
326
326
|
Command2["GetPermissions"] = "get-permissions";
|
|
327
327
|
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
328
|
+
Command2["Share"] = "share";
|
|
328
329
|
return Command2;
|
|
329
330
|
})(Command || {});
|
|
330
331
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
@@ -530,7 +531,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
530
531
|
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
531
532
|
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
532
533
|
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
533
|
-
ResponseEvent2["
|
|
534
|
+
ResponseEvent2["MiniAppShare"] = "miniapp-share";
|
|
534
535
|
return ResponseEvent2;
|
|
535
536
|
})(ResponseEvent || {});
|
|
536
537
|
|
|
@@ -593,6 +594,72 @@ var compressAndPadProof = async (proof, rpcUrl) => {
|
|
|
593
594
|
}
|
|
594
595
|
};
|
|
595
596
|
|
|
597
|
+
// helpers/share/index.ts
|
|
598
|
+
var MAX_FILES = 10;
|
|
599
|
+
var MAX_TOTAL_SIZE_MB = 50;
|
|
600
|
+
var MAX_TOTAL_SIZE_BYTES = MAX_TOTAL_SIZE_MB * 1024 * 1024;
|
|
601
|
+
var processFile = async (file) => {
|
|
602
|
+
const buffer = await file.arrayBuffer();
|
|
603
|
+
const uint8Array = new Uint8Array(buffer);
|
|
604
|
+
let binaryString = "";
|
|
605
|
+
const K_CHUNK_SIZE = 32768;
|
|
606
|
+
for (let i = 0; i < uint8Array.length; i += K_CHUNK_SIZE) {
|
|
607
|
+
const chunk = uint8Array.subarray(
|
|
608
|
+
i,
|
|
609
|
+
Math.min(i + K_CHUNK_SIZE, uint8Array.length)
|
|
610
|
+
);
|
|
611
|
+
binaryString += String.fromCharCode.apply(
|
|
612
|
+
null,
|
|
613
|
+
Array.from(chunk)
|
|
614
|
+
// Convert Uint8Array chunk to number[]
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
const base64Data = btoa(binaryString);
|
|
618
|
+
return {
|
|
619
|
+
name: file.name,
|
|
620
|
+
type: file.type,
|
|
621
|
+
data: base64Data
|
|
622
|
+
};
|
|
623
|
+
};
|
|
624
|
+
var formatShareInput = async (input) => {
|
|
625
|
+
if (!input.files) {
|
|
626
|
+
return {
|
|
627
|
+
title: input.title,
|
|
628
|
+
text: input.text,
|
|
629
|
+
url: input.url
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
if (!Array.isArray(input.files)) {
|
|
633
|
+
throw new Error('The "files" property must be an array.');
|
|
634
|
+
}
|
|
635
|
+
if (input.files.length === 0) {
|
|
636
|
+
} else {
|
|
637
|
+
if (input.files.length > MAX_FILES) {
|
|
638
|
+
throw new Error(`Cannot share more than ${MAX_FILES} files.`);
|
|
639
|
+
}
|
|
640
|
+
let totalSize = 0;
|
|
641
|
+
for (const file of input.files) {
|
|
642
|
+
if (!(file instanceof File)) {
|
|
643
|
+
throw new Error(
|
|
644
|
+
`Each item in the 'files' array must be a File object. Received: ${typeof file}`
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
totalSize += file.size;
|
|
648
|
+
}
|
|
649
|
+
if (totalSize > MAX_TOTAL_SIZE_BYTES) {
|
|
650
|
+
throw new Error(`Total file size cannot exceed ${MAX_TOTAL_SIZE_MB}MB.`);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
const fileProcessingPromises = input.files.map((file) => processFile(file));
|
|
654
|
+
const processedFiles = await Promise.all(fileProcessingPromises);
|
|
655
|
+
return {
|
|
656
|
+
files: processedFiles,
|
|
657
|
+
title: input.title,
|
|
658
|
+
text: input.text,
|
|
659
|
+
url: input.url
|
|
660
|
+
};
|
|
661
|
+
};
|
|
662
|
+
|
|
596
663
|
// helpers/siwe/validate-wallet-auth-command-input.ts
|
|
597
664
|
var validateWalletAuthCommandInput = (params) => {
|
|
598
665
|
if (!params.nonce) {
|
|
@@ -827,6 +894,7 @@ var _MiniKit = class _MiniKit {
|
|
|
827
894
|
_MiniKit.user.optedIntoOptionalAnalytics = window.WorldApp.is_optional_analytics;
|
|
828
895
|
_MiniKit.user.deviceOS = window.WorldApp.device_os;
|
|
829
896
|
_MiniKit.user.worldAppVersion = window.WorldApp.world_app_version;
|
|
897
|
+
_MiniKit.deviceProperties.safeAreaInsets = window.WorldApp.safe_area_insets;
|
|
830
898
|
try {
|
|
831
899
|
window.MiniKit = _MiniKit;
|
|
832
900
|
this.sendInit();
|
|
@@ -872,8 +940,8 @@ _MiniKit.miniKitCommandVersion = {
|
|
|
872
940
|
["share-contacts" /* ShareContacts */]: 1,
|
|
873
941
|
["request-permission" /* RequestPermission */]: 1,
|
|
874
942
|
["get-permissions" /* GetPermissions */]: 1,
|
|
875
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
876
|
-
|
|
943
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
944
|
+
["share" /* Share */]: 1
|
|
877
945
|
};
|
|
878
946
|
_MiniKit.isCommandAvailable = {
|
|
879
947
|
["verify" /* Verify */]: false,
|
|
@@ -885,8 +953,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
885
953
|
["share-contacts" /* ShareContacts */]: false,
|
|
886
954
|
["request-permission" /* RequestPermission */]: false,
|
|
887
955
|
["get-permissions" /* GetPermissions */]: false,
|
|
888
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
889
|
-
|
|
956
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
957
|
+
["share" /* Share */]: false
|
|
890
958
|
};
|
|
891
959
|
_MiniKit.listeners = {
|
|
892
960
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -909,12 +977,13 @@ _MiniKit.listeners = {
|
|
|
909
977
|
},
|
|
910
978
|
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
911
979
|
},
|
|
912
|
-
["miniapp-share
|
|
980
|
+
["miniapp-share" /* MiniAppShare */]: () => {
|
|
913
981
|
}
|
|
914
982
|
};
|
|
915
983
|
_MiniKit.appId = null;
|
|
916
984
|
_MiniKit.user = {};
|
|
917
985
|
_MiniKit.isReady = false;
|
|
986
|
+
_MiniKit.deviceProperties = {};
|
|
918
987
|
_MiniKit.getUserByAddress = async (address) => {
|
|
919
988
|
const userProfile = await getUserProfile(
|
|
920
989
|
address ?? _MiniKit.user.walletAddress
|
|
@@ -1080,7 +1149,7 @@ _MiniKit.commands = {
|
|
|
1080
1149
|
return payload;
|
|
1081
1150
|
},
|
|
1082
1151
|
shareContacts: (payload) => {
|
|
1083
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["
|
|
1152
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share-contacts" /* ShareContacts */]) {
|
|
1084
1153
|
console.error(
|
|
1085
1154
|
"'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1086
1155
|
);
|
|
@@ -1136,24 +1205,33 @@ _MiniKit.commands = {
|
|
|
1136
1205
|
payload
|
|
1137
1206
|
});
|
|
1138
1207
|
return payload;
|
|
1208
|
+
},
|
|
1209
|
+
// We return share input here because the payload is formatted asynchronously
|
|
1210
|
+
share: (payload) => {
|
|
1211
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share" /* Share */]) {
|
|
1212
|
+
console.error(
|
|
1213
|
+
"'share' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1214
|
+
);
|
|
1215
|
+
return null;
|
|
1216
|
+
}
|
|
1217
|
+
if (_MiniKit.user.deviceOS === "ios") {
|
|
1218
|
+
navigator.share(payload);
|
|
1219
|
+
} else {
|
|
1220
|
+
formatShareInput(payload).then((formattedResult) => {
|
|
1221
|
+
sendMiniKitEvent({
|
|
1222
|
+
command: "share" /* Share */,
|
|
1223
|
+
version: _MiniKit.miniKitCommandVersion["share" /* Share */],
|
|
1224
|
+
payload: formattedResult
|
|
1225
|
+
});
|
|
1226
|
+
}).catch((error) => {
|
|
1227
|
+
console.error("Failed to format share input", error);
|
|
1228
|
+
});
|
|
1229
|
+
_MiniKit.subscribe("miniapp-share" /* MiniAppShare */, (payload2) => {
|
|
1230
|
+
console.log("Share Response", payload2);
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
return payload;
|
|
1139
1234
|
}
|
|
1140
|
-
// shareFiles: (payload: ShareFilesInput): ShareFilesPayload | null => {
|
|
1141
|
-
// if (
|
|
1142
|
-
// typeof window === 'undefined' ||
|
|
1143
|
-
// !this.isCommandAvailable[Command.ShareFiles]
|
|
1144
|
-
// ) {
|
|
1145
|
-
// console.error(
|
|
1146
|
-
// "'shareFiles' command is unavailable. Check MiniKit.install() or update the app version",
|
|
1147
|
-
// );
|
|
1148
|
-
// return null;
|
|
1149
|
-
// }
|
|
1150
|
-
// sendMiniKitEvent<WebViewBasePayload>({
|
|
1151
|
-
// command: Command.ShareFiles,
|
|
1152
|
-
// version: this.miniKitCommandVersion[Command.ShareFiles],
|
|
1153
|
-
// payload,
|
|
1154
|
-
// });
|
|
1155
|
-
// return payload;
|
|
1156
|
-
// },
|
|
1157
1235
|
};
|
|
1158
1236
|
/**
|
|
1159
1237
|
* This object contains async versions of all the commands.
|
|
@@ -1310,26 +1388,24 @@ _MiniKit.commandsAsync = {
|
|
|
1310
1388
|
reject(error);
|
|
1311
1389
|
}
|
|
1312
1390
|
});
|
|
1391
|
+
},
|
|
1392
|
+
share: async (payload) => {
|
|
1393
|
+
return new Promise(async (resolve, reject) => {
|
|
1394
|
+
try {
|
|
1395
|
+
const response = await _MiniKit.awaitCommand(
|
|
1396
|
+
"miniapp-share" /* MiniAppShare */,
|
|
1397
|
+
"share" /* Share */,
|
|
1398
|
+
() => _MiniKit.commands.share(payload)
|
|
1399
|
+
);
|
|
1400
|
+
resolve({
|
|
1401
|
+
commandPayload: response.commandPayload,
|
|
1402
|
+
finalPayload: response.finalPayload
|
|
1403
|
+
});
|
|
1404
|
+
} catch (error) {
|
|
1405
|
+
reject(error);
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1313
1408
|
}
|
|
1314
|
-
// shareFiles: async (
|
|
1315
|
-
// payload: ShareFilesInput,
|
|
1316
|
-
// ): AsyncHandlerReturn<
|
|
1317
|
-
// ShareFilesPayload | null,
|
|
1318
|
-
// MiniAppShareFilesPayload
|
|
1319
|
-
// > => {
|
|
1320
|
-
// return new Promise(async (resolve, reject) => {
|
|
1321
|
-
// try {
|
|
1322
|
-
// const response = await MiniKit.awaitCommand(
|
|
1323
|
-
// ResponseEvent.MiniAppShareFiles,
|
|
1324
|
-
// Command.ShareFiles,
|
|
1325
|
-
// () => this.commands.shareFiles(payload),
|
|
1326
|
-
// );
|
|
1327
|
-
// resolve(response);
|
|
1328
|
-
// } catch (error) {
|
|
1329
|
-
// reject(error);
|
|
1330
|
-
// }
|
|
1331
|
-
// });
|
|
1332
|
-
// },
|
|
1333
1409
|
};
|
|
1334
1410
|
var MiniKit = _MiniKit;
|
|
1335
1411
|
|
package/build/index.cjs
CHANGED
|
@@ -161,6 +161,72 @@ var compressAndPadProof = async (proof, rpcUrl) => {
|
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
// helpers/share/index.ts
|
|
165
|
+
var MAX_FILES = 10;
|
|
166
|
+
var MAX_TOTAL_SIZE_MB = 50;
|
|
167
|
+
var MAX_TOTAL_SIZE_BYTES = MAX_TOTAL_SIZE_MB * 1024 * 1024;
|
|
168
|
+
var processFile = async (file) => {
|
|
169
|
+
const buffer = await file.arrayBuffer();
|
|
170
|
+
const uint8Array = new Uint8Array(buffer);
|
|
171
|
+
let binaryString = "";
|
|
172
|
+
const K_CHUNK_SIZE = 32768;
|
|
173
|
+
for (let i = 0; i < uint8Array.length; i += K_CHUNK_SIZE) {
|
|
174
|
+
const chunk = uint8Array.subarray(
|
|
175
|
+
i,
|
|
176
|
+
Math.min(i + K_CHUNK_SIZE, uint8Array.length)
|
|
177
|
+
);
|
|
178
|
+
binaryString += String.fromCharCode.apply(
|
|
179
|
+
null,
|
|
180
|
+
Array.from(chunk)
|
|
181
|
+
// Convert Uint8Array chunk to number[]
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
const base64Data = btoa(binaryString);
|
|
185
|
+
return {
|
|
186
|
+
name: file.name,
|
|
187
|
+
type: file.type,
|
|
188
|
+
data: base64Data
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
var formatShareInput = async (input) => {
|
|
192
|
+
if (!input.files) {
|
|
193
|
+
return {
|
|
194
|
+
title: input.title,
|
|
195
|
+
text: input.text,
|
|
196
|
+
url: input.url
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (!Array.isArray(input.files)) {
|
|
200
|
+
throw new Error('The "files" property must be an array.');
|
|
201
|
+
}
|
|
202
|
+
if (input.files.length === 0) {
|
|
203
|
+
} else {
|
|
204
|
+
if (input.files.length > MAX_FILES) {
|
|
205
|
+
throw new Error(`Cannot share more than ${MAX_FILES} files.`);
|
|
206
|
+
}
|
|
207
|
+
let totalSize = 0;
|
|
208
|
+
for (const file of input.files) {
|
|
209
|
+
if (!(file instanceof File)) {
|
|
210
|
+
throw new Error(
|
|
211
|
+
`Each item in the 'files' array must be a File object. Received: ${typeof file}`
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
totalSize += file.size;
|
|
215
|
+
}
|
|
216
|
+
if (totalSize > MAX_TOTAL_SIZE_BYTES) {
|
|
217
|
+
throw new Error(`Total file size cannot exceed ${MAX_TOTAL_SIZE_MB}MB.`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const fileProcessingPromises = input.files.map((file) => processFile(file));
|
|
221
|
+
const processedFiles = await Promise.all(fileProcessingPromises);
|
|
222
|
+
return {
|
|
223
|
+
files: processedFiles,
|
|
224
|
+
title: input.title,
|
|
225
|
+
text: input.text,
|
|
226
|
+
url: input.url
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
|
|
164
230
|
// helpers/siwe/siwe.ts
|
|
165
231
|
var import_viem2 = require("viem");
|
|
166
232
|
var import_chains2 = require("viem/chains");
|
|
@@ -538,6 +604,7 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
538
604
|
Command2["RequestPermission"] = "request-permission";
|
|
539
605
|
Command2["GetPermissions"] = "get-permissions";
|
|
540
606
|
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
607
|
+
Command2["Share"] = "share";
|
|
541
608
|
return Command2;
|
|
542
609
|
})(Command || {});
|
|
543
610
|
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
@@ -752,7 +819,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
752
819
|
ResponseEvent2["MiniAppRequestPermission"] = "miniapp-request-permission";
|
|
753
820
|
ResponseEvent2["MiniAppGetPermissions"] = "miniapp-get-permissions";
|
|
754
821
|
ResponseEvent2["MiniAppSendHapticFeedback"] = "miniapp-send-haptic-feedback";
|
|
755
|
-
ResponseEvent2["
|
|
822
|
+
ResponseEvent2["MiniAppShare"] = "miniapp-share";
|
|
756
823
|
return ResponseEvent2;
|
|
757
824
|
})(ResponseEvent || {});
|
|
758
825
|
|
|
@@ -879,6 +946,7 @@ var _MiniKit = class _MiniKit {
|
|
|
879
946
|
_MiniKit.user.optedIntoOptionalAnalytics = window.WorldApp.is_optional_analytics;
|
|
880
947
|
_MiniKit.user.deviceOS = window.WorldApp.device_os;
|
|
881
948
|
_MiniKit.user.worldAppVersion = window.WorldApp.world_app_version;
|
|
949
|
+
_MiniKit.deviceProperties.safeAreaInsets = window.WorldApp.safe_area_insets;
|
|
882
950
|
try {
|
|
883
951
|
window.MiniKit = _MiniKit;
|
|
884
952
|
this.sendInit();
|
|
@@ -924,8 +992,8 @@ _MiniKit.miniKitCommandVersion = {
|
|
|
924
992
|
["share-contacts" /* ShareContacts */]: 1,
|
|
925
993
|
["request-permission" /* RequestPermission */]: 1,
|
|
926
994
|
["get-permissions" /* GetPermissions */]: 1,
|
|
927
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
928
|
-
|
|
995
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
996
|
+
["share" /* Share */]: 1
|
|
929
997
|
};
|
|
930
998
|
_MiniKit.isCommandAvailable = {
|
|
931
999
|
["verify" /* Verify */]: false,
|
|
@@ -937,8 +1005,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
937
1005
|
["share-contacts" /* ShareContacts */]: false,
|
|
938
1006
|
["request-permission" /* RequestPermission */]: false,
|
|
939
1007
|
["get-permissions" /* GetPermissions */]: false,
|
|
940
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
941
|
-
|
|
1008
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
1009
|
+
["share" /* Share */]: false
|
|
942
1010
|
};
|
|
943
1011
|
_MiniKit.listeners = {
|
|
944
1012
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -961,12 +1029,13 @@ _MiniKit.listeners = {
|
|
|
961
1029
|
},
|
|
962
1030
|
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
963
1031
|
},
|
|
964
|
-
["miniapp-share
|
|
1032
|
+
["miniapp-share" /* MiniAppShare */]: () => {
|
|
965
1033
|
}
|
|
966
1034
|
};
|
|
967
1035
|
_MiniKit.appId = null;
|
|
968
1036
|
_MiniKit.user = {};
|
|
969
1037
|
_MiniKit.isReady = false;
|
|
1038
|
+
_MiniKit.deviceProperties = {};
|
|
970
1039
|
_MiniKit.getUserByAddress = async (address) => {
|
|
971
1040
|
const userProfile = await getUserProfile(
|
|
972
1041
|
address ?? _MiniKit.user.walletAddress
|
|
@@ -1132,7 +1201,7 @@ _MiniKit.commands = {
|
|
|
1132
1201
|
return payload;
|
|
1133
1202
|
},
|
|
1134
1203
|
shareContacts: (payload) => {
|
|
1135
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["
|
|
1204
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share-contacts" /* ShareContacts */]) {
|
|
1136
1205
|
console.error(
|
|
1137
1206
|
"'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1138
1207
|
);
|
|
@@ -1188,24 +1257,33 @@ _MiniKit.commands = {
|
|
|
1188
1257
|
payload
|
|
1189
1258
|
});
|
|
1190
1259
|
return payload;
|
|
1260
|
+
},
|
|
1261
|
+
// We return share input here because the payload is formatted asynchronously
|
|
1262
|
+
share: (payload) => {
|
|
1263
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share" /* Share */]) {
|
|
1264
|
+
console.error(
|
|
1265
|
+
"'share' command is unavailable. Check MiniKit.install() or update the app version"
|
|
1266
|
+
);
|
|
1267
|
+
return null;
|
|
1268
|
+
}
|
|
1269
|
+
if (_MiniKit.user.deviceOS === "ios") {
|
|
1270
|
+
navigator.share(payload);
|
|
1271
|
+
} else {
|
|
1272
|
+
formatShareInput(payload).then((formattedResult) => {
|
|
1273
|
+
sendMiniKitEvent({
|
|
1274
|
+
command: "share" /* Share */,
|
|
1275
|
+
version: _MiniKit.miniKitCommandVersion["share" /* Share */],
|
|
1276
|
+
payload: formattedResult
|
|
1277
|
+
});
|
|
1278
|
+
}).catch((error) => {
|
|
1279
|
+
console.error("Failed to format share input", error);
|
|
1280
|
+
});
|
|
1281
|
+
_MiniKit.subscribe("miniapp-share" /* MiniAppShare */, (payload2) => {
|
|
1282
|
+
console.log("Share Response", payload2);
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
return payload;
|
|
1191
1286
|
}
|
|
1192
|
-
// shareFiles: (payload: ShareFilesInput): ShareFilesPayload | null => {
|
|
1193
|
-
// if (
|
|
1194
|
-
// typeof window === 'undefined' ||
|
|
1195
|
-
// !this.isCommandAvailable[Command.ShareFiles]
|
|
1196
|
-
// ) {
|
|
1197
|
-
// console.error(
|
|
1198
|
-
// "'shareFiles' command is unavailable. Check MiniKit.install() or update the app version",
|
|
1199
|
-
// );
|
|
1200
|
-
// return null;
|
|
1201
|
-
// }
|
|
1202
|
-
// sendMiniKitEvent<WebViewBasePayload>({
|
|
1203
|
-
// command: Command.ShareFiles,
|
|
1204
|
-
// version: this.miniKitCommandVersion[Command.ShareFiles],
|
|
1205
|
-
// payload,
|
|
1206
|
-
// });
|
|
1207
|
-
// return payload;
|
|
1208
|
-
// },
|
|
1209
1287
|
};
|
|
1210
1288
|
/**
|
|
1211
1289
|
* This object contains async versions of all the commands.
|
|
@@ -1362,26 +1440,24 @@ _MiniKit.commandsAsync = {
|
|
|
1362
1440
|
reject(error);
|
|
1363
1441
|
}
|
|
1364
1442
|
});
|
|
1443
|
+
},
|
|
1444
|
+
share: async (payload) => {
|
|
1445
|
+
return new Promise(async (resolve, reject) => {
|
|
1446
|
+
try {
|
|
1447
|
+
const response = await _MiniKit.awaitCommand(
|
|
1448
|
+
"miniapp-share" /* MiniAppShare */,
|
|
1449
|
+
"share" /* Share */,
|
|
1450
|
+
() => _MiniKit.commands.share(payload)
|
|
1451
|
+
);
|
|
1452
|
+
resolve({
|
|
1453
|
+
commandPayload: response.commandPayload,
|
|
1454
|
+
finalPayload: response.finalPayload
|
|
1455
|
+
});
|
|
1456
|
+
} catch (error) {
|
|
1457
|
+
reject(error);
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1365
1460
|
}
|
|
1366
|
-
// shareFiles: async (
|
|
1367
|
-
// payload: ShareFilesInput,
|
|
1368
|
-
// ): AsyncHandlerReturn<
|
|
1369
|
-
// ShareFilesPayload | null,
|
|
1370
|
-
// MiniAppShareFilesPayload
|
|
1371
|
-
// > => {
|
|
1372
|
-
// return new Promise(async (resolve, reject) => {
|
|
1373
|
-
// try {
|
|
1374
|
-
// const response = await MiniKit.awaitCommand(
|
|
1375
|
-
// ResponseEvent.MiniAppShareFiles,
|
|
1376
|
-
// Command.ShareFiles,
|
|
1377
|
-
// () => this.commands.shareFiles(payload),
|
|
1378
|
-
// );
|
|
1379
|
-
// resolve(response);
|
|
1380
|
-
// } catch (error) {
|
|
1381
|
-
// reject(error);
|
|
1382
|
-
// }
|
|
1383
|
-
// });
|
|
1384
|
-
// },
|
|
1385
1461
|
};
|
|
1386
1462
|
var MiniKit = _MiniKit;
|
|
1387
1463
|
|
package/build/index.d.cts
CHANGED
|
@@ -181,7 +181,8 @@ declare enum Command {
|
|
|
181
181
|
ShareContacts = "share-contacts",
|
|
182
182
|
RequestPermission = "request-permission",
|
|
183
183
|
GetPermissions = "get-permissions",
|
|
184
|
-
SendHapticFeedback = "send-haptic-feedback"
|
|
184
|
+
SendHapticFeedback = "send-haptic-feedback",
|
|
185
|
+
Share = "share"
|
|
185
186
|
}
|
|
186
187
|
type WebViewBasePayload = {
|
|
187
188
|
command: Command;
|
|
@@ -273,15 +274,22 @@ type SendHapticFeedbackInput = {
|
|
|
273
274
|
style: 'light' | 'medium' | 'heavy';
|
|
274
275
|
};
|
|
275
276
|
type SendHapticFeedbackPayload = SendHapticFeedbackInput;
|
|
276
|
-
type
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
type ShareInput = {
|
|
278
|
+
files?: File[];
|
|
279
|
+
title?: string;
|
|
280
|
+
text?: string;
|
|
281
|
+
url?: string;
|
|
282
|
+
};
|
|
283
|
+
type SharePayload = {
|
|
284
|
+
files?: Array<{
|
|
285
|
+
name: string;
|
|
286
|
+
type: string;
|
|
287
|
+
data: string;
|
|
288
|
+
}>;
|
|
289
|
+
title?: string;
|
|
290
|
+
text?: string;
|
|
291
|
+
url?: string;
|
|
279
292
|
};
|
|
280
|
-
type ShareFilesInput = {
|
|
281
|
-
files: ShareFile[];
|
|
282
|
-
mime_type: string;
|
|
283
|
-
};
|
|
284
|
-
type ShareFilesPayload = ShareFilesInput;
|
|
285
293
|
type CommandReturnPayloadMap = {
|
|
286
294
|
[Command.Verify]: VerifyCommandPayload;
|
|
287
295
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -293,9 +301,36 @@ type CommandReturnPayloadMap = {
|
|
|
293
301
|
[Command.RequestPermission]: RequestPermissionPayload;
|
|
294
302
|
[Command.GetPermissions]: GetPermissionsPayload;
|
|
295
303
|
[Command.SendHapticFeedback]: SendHapticFeedbackPayload;
|
|
304
|
+
[Command.Share]: SharePayload;
|
|
296
305
|
};
|
|
297
306
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
298
307
|
|
|
308
|
+
type User = {
|
|
309
|
+
walletAddress?: string;
|
|
310
|
+
username?: string;
|
|
311
|
+
profilePictureUrl?: string;
|
|
312
|
+
permissions?: {
|
|
313
|
+
notifications: boolean;
|
|
314
|
+
contacts: boolean;
|
|
315
|
+
};
|
|
316
|
+
optedIntoOptionalAnalytics?: boolean;
|
|
317
|
+
worldAppVersion?: number;
|
|
318
|
+
deviceOS?: string;
|
|
319
|
+
};
|
|
320
|
+
type DeviceProperties = {
|
|
321
|
+
safeAreaInsets?: {
|
|
322
|
+
top: number;
|
|
323
|
+
right: number;
|
|
324
|
+
bottom: number;
|
|
325
|
+
left: number;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
type UserNameService = {
|
|
329
|
+
walletAddress: string;
|
|
330
|
+
username?: string;
|
|
331
|
+
profilePictureUrl?: string;
|
|
332
|
+
};
|
|
333
|
+
|
|
299
334
|
declare enum ResponseEvent {
|
|
300
335
|
MiniAppVerifyAction = "miniapp-verify-action",
|
|
301
336
|
MiniAppPayment = "miniapp-payment",
|
|
@@ -307,7 +342,7 @@ declare enum ResponseEvent {
|
|
|
307
342
|
MiniAppRequestPermission = "miniapp-request-permission",
|
|
308
343
|
MiniAppGetPermissions = "miniapp-get-permissions",
|
|
309
344
|
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
|
|
310
|
-
|
|
345
|
+
MiniAppShare = "miniapp-share"
|
|
311
346
|
}
|
|
312
347
|
type MiniAppVerifyActionSuccessPayload = {
|
|
313
348
|
status: 'success';
|
|
@@ -455,18 +490,18 @@ type MiniAppSendHapticFeedbackErrorPayload = {
|
|
|
455
490
|
version: number;
|
|
456
491
|
};
|
|
457
492
|
type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
|
|
458
|
-
type
|
|
493
|
+
type MiniAppShareSuccessPayload = {
|
|
459
494
|
status: 'success';
|
|
460
495
|
shared_files_count: number;
|
|
461
496
|
version: number;
|
|
462
497
|
timestamp: string;
|
|
463
498
|
};
|
|
464
|
-
type
|
|
499
|
+
type MiniAppShareErrorPayload = {
|
|
465
500
|
status: 'error';
|
|
466
501
|
error_code: ShareFilesErrorCodes;
|
|
467
502
|
version: number;
|
|
468
503
|
};
|
|
469
|
-
type
|
|
504
|
+
type MiniAppSharePayload = MiniAppShareSuccessPayload | MiniAppShareErrorPayload;
|
|
470
505
|
type EventPayloadMap = {
|
|
471
506
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
472
507
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -478,29 +513,11 @@ type EventPayloadMap = {
|
|
|
478
513
|
[ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
|
|
479
514
|
[ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
|
|
480
515
|
[ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
|
|
481
|
-
[ResponseEvent.
|
|
516
|
+
[ResponseEvent.MiniAppShare]: MiniAppSharePayload;
|
|
482
517
|
};
|
|
483
518
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
484
519
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
485
520
|
|
|
486
|
-
type User = {
|
|
487
|
-
walletAddress?: string;
|
|
488
|
-
username?: string;
|
|
489
|
-
profilePictureUrl?: string;
|
|
490
|
-
permissions?: {
|
|
491
|
-
notifications: boolean;
|
|
492
|
-
contacts: boolean;
|
|
493
|
-
};
|
|
494
|
-
optedIntoOptionalAnalytics?: boolean;
|
|
495
|
-
worldAppVersion?: number;
|
|
496
|
-
deviceOS?: string;
|
|
497
|
-
};
|
|
498
|
-
type UserNameService = {
|
|
499
|
-
walletAddress: string;
|
|
500
|
-
username?: string;
|
|
501
|
-
profilePictureUrl?: string;
|
|
502
|
-
};
|
|
503
|
-
|
|
504
521
|
declare class MiniKit {
|
|
505
522
|
private static readonly MINIKIT_VERSION;
|
|
506
523
|
private static readonly miniKitCommandVersion;
|
|
@@ -509,6 +526,7 @@ declare class MiniKit {
|
|
|
509
526
|
static appId: string | null;
|
|
510
527
|
static user: User;
|
|
511
528
|
private static isReady;
|
|
529
|
+
static deviceProperties: DeviceProperties;
|
|
512
530
|
private static sendInit;
|
|
513
531
|
static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
|
|
514
532
|
static unsubscribe(event: ResponseEvent): void;
|
|
@@ -531,6 +549,7 @@ declare class MiniKit {
|
|
|
531
549
|
requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
|
|
532
550
|
getPermissions: () => GetPermissionsPayload | null;
|
|
533
551
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
552
|
+
share: (payload: ShareInput) => ShareInput | null;
|
|
534
553
|
};
|
|
535
554
|
/**
|
|
536
555
|
* This object contains async versions of all the commands.
|
|
@@ -553,6 +572,7 @@ declare class MiniKit {
|
|
|
553
572
|
requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
|
|
554
573
|
getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
|
|
555
574
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
575
|
+
share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
|
|
556
576
|
};
|
|
557
577
|
}
|
|
558
578
|
|
|
@@ -581,4 +601,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
581
601
|
|
|
582
602
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
583
603
|
|
|
584
|
-
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
|
|
604
|
+
export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type DeviceProperties, 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 MiniAppShareErrorPayload, type MiniAppSharePayload, type MiniAppShareSuccessPayload, 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, SendHapticFeedbackErrorCodes, SendHapticFeedbackErrorMessage, type SendHapticFeedbackInput, type SendHapticFeedbackPayload, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, ShareFilesErrorCodes, ShareFilesErrorMessage, type ShareInput, type SharePayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, type User, type UserNameService, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
package/build/index.d.ts
CHANGED
|
@@ -181,7 +181,8 @@ declare enum Command {
|
|
|
181
181
|
ShareContacts = "share-contacts",
|
|
182
182
|
RequestPermission = "request-permission",
|
|
183
183
|
GetPermissions = "get-permissions",
|
|
184
|
-
SendHapticFeedback = "send-haptic-feedback"
|
|
184
|
+
SendHapticFeedback = "send-haptic-feedback",
|
|
185
|
+
Share = "share"
|
|
185
186
|
}
|
|
186
187
|
type WebViewBasePayload = {
|
|
187
188
|
command: Command;
|
|
@@ -273,15 +274,22 @@ type SendHapticFeedbackInput = {
|
|
|
273
274
|
style: 'light' | 'medium' | 'heavy';
|
|
274
275
|
};
|
|
275
276
|
type SendHapticFeedbackPayload = SendHapticFeedbackInput;
|
|
276
|
-
type
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
type ShareInput = {
|
|
278
|
+
files?: File[];
|
|
279
|
+
title?: string;
|
|
280
|
+
text?: string;
|
|
281
|
+
url?: string;
|
|
282
|
+
};
|
|
283
|
+
type SharePayload = {
|
|
284
|
+
files?: Array<{
|
|
285
|
+
name: string;
|
|
286
|
+
type: string;
|
|
287
|
+
data: string;
|
|
288
|
+
}>;
|
|
289
|
+
title?: string;
|
|
290
|
+
text?: string;
|
|
291
|
+
url?: string;
|
|
279
292
|
};
|
|
280
|
-
type ShareFilesInput = {
|
|
281
|
-
files: ShareFile[];
|
|
282
|
-
mime_type: string;
|
|
283
|
-
};
|
|
284
|
-
type ShareFilesPayload = ShareFilesInput;
|
|
285
293
|
type CommandReturnPayloadMap = {
|
|
286
294
|
[Command.Verify]: VerifyCommandPayload;
|
|
287
295
|
[Command.Pay]: PayCommandPayload;
|
|
@@ -293,9 +301,36 @@ type CommandReturnPayloadMap = {
|
|
|
293
301
|
[Command.RequestPermission]: RequestPermissionPayload;
|
|
294
302
|
[Command.GetPermissions]: GetPermissionsPayload;
|
|
295
303
|
[Command.SendHapticFeedback]: SendHapticFeedbackPayload;
|
|
304
|
+
[Command.Share]: SharePayload;
|
|
296
305
|
};
|
|
297
306
|
type CommandReturnPayload<T extends Command> = T extends keyof CommandReturnPayloadMap ? CommandReturnPayloadMap[T] : never;
|
|
298
307
|
|
|
308
|
+
type User = {
|
|
309
|
+
walletAddress?: string;
|
|
310
|
+
username?: string;
|
|
311
|
+
profilePictureUrl?: string;
|
|
312
|
+
permissions?: {
|
|
313
|
+
notifications: boolean;
|
|
314
|
+
contacts: boolean;
|
|
315
|
+
};
|
|
316
|
+
optedIntoOptionalAnalytics?: boolean;
|
|
317
|
+
worldAppVersion?: number;
|
|
318
|
+
deviceOS?: string;
|
|
319
|
+
};
|
|
320
|
+
type DeviceProperties = {
|
|
321
|
+
safeAreaInsets?: {
|
|
322
|
+
top: number;
|
|
323
|
+
right: number;
|
|
324
|
+
bottom: number;
|
|
325
|
+
left: number;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
type UserNameService = {
|
|
329
|
+
walletAddress: string;
|
|
330
|
+
username?: string;
|
|
331
|
+
profilePictureUrl?: string;
|
|
332
|
+
};
|
|
333
|
+
|
|
299
334
|
declare enum ResponseEvent {
|
|
300
335
|
MiniAppVerifyAction = "miniapp-verify-action",
|
|
301
336
|
MiniAppPayment = "miniapp-payment",
|
|
@@ -307,7 +342,7 @@ declare enum ResponseEvent {
|
|
|
307
342
|
MiniAppRequestPermission = "miniapp-request-permission",
|
|
308
343
|
MiniAppGetPermissions = "miniapp-get-permissions",
|
|
309
344
|
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
|
|
310
|
-
|
|
345
|
+
MiniAppShare = "miniapp-share"
|
|
311
346
|
}
|
|
312
347
|
type MiniAppVerifyActionSuccessPayload = {
|
|
313
348
|
status: 'success';
|
|
@@ -455,18 +490,18 @@ type MiniAppSendHapticFeedbackErrorPayload = {
|
|
|
455
490
|
version: number;
|
|
456
491
|
};
|
|
457
492
|
type MiniAppSendHapticFeedbackPayload = MiniAppSendHapticFeedbackSuccessPayload | MiniAppSendHapticFeedbackErrorPayload;
|
|
458
|
-
type
|
|
493
|
+
type MiniAppShareSuccessPayload = {
|
|
459
494
|
status: 'success';
|
|
460
495
|
shared_files_count: number;
|
|
461
496
|
version: number;
|
|
462
497
|
timestamp: string;
|
|
463
498
|
};
|
|
464
|
-
type
|
|
499
|
+
type MiniAppShareErrorPayload = {
|
|
465
500
|
status: 'error';
|
|
466
501
|
error_code: ShareFilesErrorCodes;
|
|
467
502
|
version: number;
|
|
468
503
|
};
|
|
469
|
-
type
|
|
504
|
+
type MiniAppSharePayload = MiniAppShareSuccessPayload | MiniAppShareErrorPayload;
|
|
470
505
|
type EventPayloadMap = {
|
|
471
506
|
[ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
|
|
472
507
|
[ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
|
|
@@ -478,29 +513,11 @@ type EventPayloadMap = {
|
|
|
478
513
|
[ResponseEvent.MiniAppRequestPermission]: MiniAppRequestPermissionPayload;
|
|
479
514
|
[ResponseEvent.MiniAppGetPermissions]: MiniAppGetPermissionsPayload;
|
|
480
515
|
[ResponseEvent.MiniAppSendHapticFeedback]: MiniAppSendHapticFeedbackPayload;
|
|
481
|
-
[ResponseEvent.
|
|
516
|
+
[ResponseEvent.MiniAppShare]: MiniAppSharePayload;
|
|
482
517
|
};
|
|
483
518
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
|
|
484
519
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
485
520
|
|
|
486
|
-
type User = {
|
|
487
|
-
walletAddress?: string;
|
|
488
|
-
username?: string;
|
|
489
|
-
profilePictureUrl?: string;
|
|
490
|
-
permissions?: {
|
|
491
|
-
notifications: boolean;
|
|
492
|
-
contacts: boolean;
|
|
493
|
-
};
|
|
494
|
-
optedIntoOptionalAnalytics?: boolean;
|
|
495
|
-
worldAppVersion?: number;
|
|
496
|
-
deviceOS?: string;
|
|
497
|
-
};
|
|
498
|
-
type UserNameService = {
|
|
499
|
-
walletAddress: string;
|
|
500
|
-
username?: string;
|
|
501
|
-
profilePictureUrl?: string;
|
|
502
|
-
};
|
|
503
|
-
|
|
504
521
|
declare class MiniKit {
|
|
505
522
|
private static readonly MINIKIT_VERSION;
|
|
506
523
|
private static readonly miniKitCommandVersion;
|
|
@@ -509,6 +526,7 @@ declare class MiniKit {
|
|
|
509
526
|
static appId: string | null;
|
|
510
527
|
static user: User;
|
|
511
528
|
private static isReady;
|
|
529
|
+
static deviceProperties: DeviceProperties;
|
|
512
530
|
private static sendInit;
|
|
513
531
|
static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
|
|
514
532
|
static unsubscribe(event: ResponseEvent): void;
|
|
@@ -531,6 +549,7 @@ declare class MiniKit {
|
|
|
531
549
|
requestPermission: (payload: RequestPermissionInput) => RequestPermissionPayload | null;
|
|
532
550
|
getPermissions: () => GetPermissionsPayload | null;
|
|
533
551
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
552
|
+
share: (payload: ShareInput) => ShareInput | null;
|
|
534
553
|
};
|
|
535
554
|
/**
|
|
536
555
|
* This object contains async versions of all the commands.
|
|
@@ -553,6 +572,7 @@ declare class MiniKit {
|
|
|
553
572
|
requestPermission: (payload: RequestPermissionInput) => AsyncHandlerReturn<RequestPermissionPayload | null, MiniAppRequestPermissionPayload>;
|
|
554
573
|
getPermissions: () => AsyncHandlerReturn<GetPermissionsPayload | null, MiniAppGetPermissionsPayload>;
|
|
555
574
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
575
|
+
share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
|
|
556
576
|
};
|
|
557
577
|
}
|
|
558
578
|
|
|
@@ -581,4 +601,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
581
601
|
|
|
582
602
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
583
603
|
|
|
584
|
-
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
|
|
604
|
+
export { type AsyncHandlerReturn, Command, type CommandReturnPayload, type Contact, type DeviceProperties, 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 MiniAppShareErrorPayload, type MiniAppSharePayload, type MiniAppShareSuccessPayload, 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, SendHapticFeedbackErrorCodes, SendHapticFeedbackErrorMessage, type SendHapticFeedbackInput, type SendHapticFeedbackPayload, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, ShareContactsErrorCodes, ShareContactsErrorMessage, type ShareContactsInput, type ShareContactsPayload, ShareFilesErrorCodes, ShareFilesErrorMessage, type ShareInput, type SharePayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, type User, type UserNameService, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, getIsUserVerified, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
package/build/index.js
CHANGED
|
@@ -99,6 +99,72 @@ var compressAndPadProof = async (proof, rpcUrl) => {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
+
// helpers/share/index.ts
|
|
103
|
+
var MAX_FILES = 10;
|
|
104
|
+
var MAX_TOTAL_SIZE_MB = 50;
|
|
105
|
+
var MAX_TOTAL_SIZE_BYTES = MAX_TOTAL_SIZE_MB * 1024 * 1024;
|
|
106
|
+
var processFile = async (file) => {
|
|
107
|
+
const buffer = await file.arrayBuffer();
|
|
108
|
+
const uint8Array = new Uint8Array(buffer);
|
|
109
|
+
let binaryString = "";
|
|
110
|
+
const K_CHUNK_SIZE = 32768;
|
|
111
|
+
for (let i = 0; i < uint8Array.length; i += K_CHUNK_SIZE) {
|
|
112
|
+
const chunk = uint8Array.subarray(
|
|
113
|
+
i,
|
|
114
|
+
Math.min(i + K_CHUNK_SIZE, uint8Array.length)
|
|
115
|
+
);
|
|
116
|
+
binaryString += String.fromCharCode.apply(
|
|
117
|
+
null,
|
|
118
|
+
Array.from(chunk)
|
|
119
|
+
// Convert Uint8Array chunk to number[]
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
const base64Data = btoa(binaryString);
|
|
123
|
+
return {
|
|
124
|
+
name: file.name,
|
|
125
|
+
type: file.type,
|
|
126
|
+
data: base64Data
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
var formatShareInput = async (input) => {
|
|
130
|
+
if (!input.files) {
|
|
131
|
+
return {
|
|
132
|
+
title: input.title,
|
|
133
|
+
text: input.text,
|
|
134
|
+
url: input.url
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (!Array.isArray(input.files)) {
|
|
138
|
+
throw new Error('The "files" property must be an array.');
|
|
139
|
+
}
|
|
140
|
+
if (input.files.length === 0) {
|
|
141
|
+
} else {
|
|
142
|
+
if (input.files.length > MAX_FILES) {
|
|
143
|
+
throw new Error(`Cannot share more than ${MAX_FILES} files.`);
|
|
144
|
+
}
|
|
145
|
+
let totalSize = 0;
|
|
146
|
+
for (const file of input.files) {
|
|
147
|
+
if (!(file instanceof File)) {
|
|
148
|
+
throw new Error(
|
|
149
|
+
`Each item in the 'files' array must be a File object. Received: ${typeof file}`
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
totalSize += file.size;
|
|
153
|
+
}
|
|
154
|
+
if (totalSize > MAX_TOTAL_SIZE_BYTES) {
|
|
155
|
+
throw new Error(`Total file size cannot exceed ${MAX_TOTAL_SIZE_MB}MB.`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const fileProcessingPromises = input.files.map((file) => processFile(file));
|
|
159
|
+
const processedFiles = await Promise.all(fileProcessingPromises);
|
|
160
|
+
return {
|
|
161
|
+
files: processedFiles,
|
|
162
|
+
title: input.title,
|
|
163
|
+
text: input.text,
|
|
164
|
+
url: input.url
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
|
|
102
168
|
// helpers/siwe/siwe.ts
|
|
103
169
|
var import_viem2 = require("viem");
|
|
104
170
|
var import_chains2 = require("viem/chains");
|
|
@@ -406,6 +472,7 @@ var _MiniKit = class _MiniKit {
|
|
|
406
472
|
_MiniKit.user.optedIntoOptionalAnalytics = window.WorldApp.is_optional_analytics;
|
|
407
473
|
_MiniKit.user.deviceOS = window.WorldApp.device_os;
|
|
408
474
|
_MiniKit.user.worldAppVersion = window.WorldApp.world_app_version;
|
|
475
|
+
_MiniKit.deviceProperties.safeAreaInsets = window.WorldApp.safe_area_insets;
|
|
409
476
|
try {
|
|
410
477
|
window.MiniKit = _MiniKit;
|
|
411
478
|
this.sendInit();
|
|
@@ -451,8 +518,8 @@ _MiniKit.miniKitCommandVersion = {
|
|
|
451
518
|
["share-contacts" /* ShareContacts */]: 1,
|
|
452
519
|
["request-permission" /* RequestPermission */]: 1,
|
|
453
520
|
["get-permissions" /* GetPermissions */]: 1,
|
|
454
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: 1
|
|
455
|
-
|
|
521
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
522
|
+
["share" /* Share */]: 1
|
|
456
523
|
};
|
|
457
524
|
_MiniKit.isCommandAvailable = {
|
|
458
525
|
["verify" /* Verify */]: false,
|
|
@@ -464,8 +531,8 @@ _MiniKit.isCommandAvailable = {
|
|
|
464
531
|
["share-contacts" /* ShareContacts */]: false,
|
|
465
532
|
["request-permission" /* RequestPermission */]: false,
|
|
466
533
|
["get-permissions" /* GetPermissions */]: false,
|
|
467
|
-
["send-haptic-feedback" /* SendHapticFeedback */]: false
|
|
468
|
-
|
|
534
|
+
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
535
|
+
["share" /* Share */]: false
|
|
469
536
|
};
|
|
470
537
|
_MiniKit.listeners = {
|
|
471
538
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
@@ -488,12 +555,13 @@ _MiniKit.listeners = {
|
|
|
488
555
|
},
|
|
489
556
|
["miniapp-send-haptic-feedback" /* MiniAppSendHapticFeedback */]: () => {
|
|
490
557
|
},
|
|
491
|
-
["miniapp-share
|
|
558
|
+
["miniapp-share" /* MiniAppShare */]: () => {
|
|
492
559
|
}
|
|
493
560
|
};
|
|
494
561
|
_MiniKit.appId = null;
|
|
495
562
|
_MiniKit.user = {};
|
|
496
563
|
_MiniKit.isReady = false;
|
|
564
|
+
_MiniKit.deviceProperties = {};
|
|
497
565
|
_MiniKit.getUserByAddress = async (address) => {
|
|
498
566
|
const userProfile = await getUserProfile(
|
|
499
567
|
address ?? _MiniKit.user.walletAddress
|
|
@@ -659,7 +727,7 @@ _MiniKit.commands = {
|
|
|
659
727
|
return payload;
|
|
660
728
|
},
|
|
661
729
|
shareContacts: (payload) => {
|
|
662
|
-
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["
|
|
730
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share-contacts" /* ShareContacts */]) {
|
|
663
731
|
console.error(
|
|
664
732
|
"'shareContacts' command is unavailable. Check MiniKit.install() or update the app version"
|
|
665
733
|
);
|
|
@@ -715,24 +783,33 @@ _MiniKit.commands = {
|
|
|
715
783
|
payload
|
|
716
784
|
});
|
|
717
785
|
return payload;
|
|
786
|
+
},
|
|
787
|
+
// We return share input here because the payload is formatted asynchronously
|
|
788
|
+
share: (payload) => {
|
|
789
|
+
if (typeof window === "undefined" || !_MiniKit.isCommandAvailable["share" /* Share */]) {
|
|
790
|
+
console.error(
|
|
791
|
+
"'share' command is unavailable. Check MiniKit.install() or update the app version"
|
|
792
|
+
);
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
795
|
+
if (_MiniKit.user.deviceOS === "ios") {
|
|
796
|
+
navigator.share(payload);
|
|
797
|
+
} else {
|
|
798
|
+
formatShareInput(payload).then((formattedResult) => {
|
|
799
|
+
sendMiniKitEvent({
|
|
800
|
+
command: "share" /* Share */,
|
|
801
|
+
version: _MiniKit.miniKitCommandVersion["share" /* Share */],
|
|
802
|
+
payload: formattedResult
|
|
803
|
+
});
|
|
804
|
+
}).catch((error) => {
|
|
805
|
+
console.error("Failed to format share input", error);
|
|
806
|
+
});
|
|
807
|
+
_MiniKit.subscribe("miniapp-share" /* MiniAppShare */, (payload2) => {
|
|
808
|
+
console.log("Share Response", payload2);
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
return payload;
|
|
718
812
|
}
|
|
719
|
-
// shareFiles: (payload: ShareFilesInput): ShareFilesPayload | null => {
|
|
720
|
-
// if (
|
|
721
|
-
// typeof window === 'undefined' ||
|
|
722
|
-
// !this.isCommandAvailable[Command.ShareFiles]
|
|
723
|
-
// ) {
|
|
724
|
-
// console.error(
|
|
725
|
-
// "'shareFiles' command is unavailable. Check MiniKit.install() or update the app version",
|
|
726
|
-
// );
|
|
727
|
-
// return null;
|
|
728
|
-
// }
|
|
729
|
-
// sendMiniKitEvent<WebViewBasePayload>({
|
|
730
|
-
// command: Command.ShareFiles,
|
|
731
|
-
// version: this.miniKitCommandVersion[Command.ShareFiles],
|
|
732
|
-
// payload,
|
|
733
|
-
// });
|
|
734
|
-
// return payload;
|
|
735
|
-
// },
|
|
736
813
|
};
|
|
737
814
|
/**
|
|
738
815
|
* This object contains async versions of all the commands.
|
|
@@ -889,26 +966,24 @@ _MiniKit.commandsAsync = {
|
|
|
889
966
|
reject(error);
|
|
890
967
|
}
|
|
891
968
|
});
|
|
969
|
+
},
|
|
970
|
+
share: async (payload) => {
|
|
971
|
+
return new Promise(async (resolve, reject) => {
|
|
972
|
+
try {
|
|
973
|
+
const response = await _MiniKit.awaitCommand(
|
|
974
|
+
"miniapp-share" /* MiniAppShare */,
|
|
975
|
+
"share" /* Share */,
|
|
976
|
+
() => _MiniKit.commands.share(payload)
|
|
977
|
+
);
|
|
978
|
+
resolve({
|
|
979
|
+
commandPayload: response.commandPayload,
|
|
980
|
+
finalPayload: response.finalPayload
|
|
981
|
+
});
|
|
982
|
+
} catch (error) {
|
|
983
|
+
reject(error);
|
|
984
|
+
}
|
|
985
|
+
});
|
|
892
986
|
}
|
|
893
|
-
// shareFiles: async (
|
|
894
|
-
// payload: ShareFilesInput,
|
|
895
|
-
// ): AsyncHandlerReturn<
|
|
896
|
-
// ShareFilesPayload | null,
|
|
897
|
-
// MiniAppShareFilesPayload
|
|
898
|
-
// > => {
|
|
899
|
-
// return new Promise(async (resolve, reject) => {
|
|
900
|
-
// try {
|
|
901
|
-
// const response = await MiniKit.awaitCommand(
|
|
902
|
-
// ResponseEvent.MiniAppShareFiles,
|
|
903
|
-
// Command.ShareFiles,
|
|
904
|
-
// () => this.commands.shareFiles(payload),
|
|
905
|
-
// );
|
|
906
|
-
// resolve(response);
|
|
907
|
-
// } catch (error) {
|
|
908
|
-
// reject(error);
|
|
909
|
-
// }
|
|
910
|
-
// });
|
|
911
|
-
// },
|
|
912
987
|
};
|
|
913
988
|
var MiniKit = _MiniKit;
|
|
914
989
|
|
package/index.ts
CHANGED
|
@@ -2,9 +2,9 @@ export { MiniKit } from './minikit';
|
|
|
2
2
|
|
|
3
3
|
export * from './types/commands';
|
|
4
4
|
export * from './types/errors';
|
|
5
|
+
export * from './types/init';
|
|
5
6
|
export * from './types/payment';
|
|
6
7
|
export * from './types/responses';
|
|
7
|
-
export * from './types/user';
|
|
8
8
|
export * from './types/wallet-auth';
|
|
9
9
|
|
|
10
10
|
export { tokenToDecimals } from 'helpers/payment/client';
|