@worldcoin/minikit-js 1.9.10 → 1.10.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/{chunk-XFGJKKI2.js → chunk-RTX3LRWR.js} +145 -9
- package/build/index.cjs +150 -9
- package/build/index.d.cts +47 -5
- package/build/index.d.ts +47 -5
- package/build/index.js +11 -1
- package/build/minikit-provider.cjs +122 -9
- package/build/minikit-provider.js +1 -1
- package/package.json +1 -1
|
@@ -21,6 +21,8 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
21
21
|
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
22
22
|
Command2["Share"] = "share";
|
|
23
23
|
Command2["Chat"] = "chat";
|
|
24
|
+
Command2["Attestation"] = "attestation";
|
|
25
|
+
Command2["CloseMiniApp"] = "close-miniapp";
|
|
24
26
|
return Command2;
|
|
25
27
|
})(Command || {});
|
|
26
28
|
var ResponseEvent = /* @__PURE__ */ ((ResponseEvent3) => {
|
|
@@ -37,6 +39,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent3) => {
|
|
|
37
39
|
ResponseEvent3["MiniAppShare"] = "miniapp-share";
|
|
38
40
|
ResponseEvent3["MiniAppMicrophone"] = "miniapp-microphone";
|
|
39
41
|
ResponseEvent3["MiniAppChat"] = "miniapp-chat";
|
|
42
|
+
ResponseEvent3["MiniAppAttestation"] = "miniapp-attestation";
|
|
40
43
|
return ResponseEvent3;
|
|
41
44
|
})(ResponseEvent || {});
|
|
42
45
|
var COMMAND_VERSIONS = {
|
|
@@ -51,7 +54,9 @@ var COMMAND_VERSIONS = {
|
|
|
51
54
|
["get-permissions" /* GetPermissions */]: 1,
|
|
52
55
|
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
53
56
|
["share" /* Share */]: 1,
|
|
54
|
-
["chat" /* Chat */]: 1
|
|
57
|
+
["chat" /* Chat */]: 1,
|
|
58
|
+
["attestation" /* Attestation */]: 1,
|
|
59
|
+
["close-miniapp" /* CloseMiniApp */]: 1
|
|
55
60
|
};
|
|
56
61
|
var commandAvailability = {
|
|
57
62
|
["verify" /* Verify */]: false,
|
|
@@ -65,7 +70,9 @@ var commandAvailability = {
|
|
|
65
70
|
["get-permissions" /* GetPermissions */]: false,
|
|
66
71
|
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
67
72
|
["share" /* Share */]: false,
|
|
68
|
-
["chat" /* Chat */]: false
|
|
73
|
+
["chat" /* Chat */]: false,
|
|
74
|
+
["attestation" /* Attestation */]: false,
|
|
75
|
+
["close-miniapp" /* CloseMiniApp */]: false
|
|
69
76
|
};
|
|
70
77
|
function isCommandAvailable(command) {
|
|
71
78
|
return commandAvailability[command];
|
|
@@ -106,6 +113,74 @@ function sendMiniKitEvent(payload) {
|
|
|
106
113
|
sendWebviewEvent(payload);
|
|
107
114
|
}
|
|
108
115
|
|
|
116
|
+
// commands/attestation.ts
|
|
117
|
+
var AttestationErrorCodes = /* @__PURE__ */ ((AttestationErrorCodes2) => {
|
|
118
|
+
AttestationErrorCodes2["Unauthorized"] = "unauthorized";
|
|
119
|
+
AttestationErrorCodes2["AttestationFailed"] = "attestation_failed";
|
|
120
|
+
AttestationErrorCodes2["IntegrityFailed"] = "integrity_failed";
|
|
121
|
+
AttestationErrorCodes2["InvalidInput"] = "invalid_input";
|
|
122
|
+
AttestationErrorCodes2["UnsupportedVersion"] = "unsupported_version";
|
|
123
|
+
return AttestationErrorCodes2;
|
|
124
|
+
})(AttestationErrorCodes || {});
|
|
125
|
+
var AttestationErrorMessage = {
|
|
126
|
+
["unauthorized" /* Unauthorized */]: "App is not whitelisted for attestation.",
|
|
127
|
+
["attestation_failed" /* AttestationFailed */]: "Failed to obtain token from attestation gateway.",
|
|
128
|
+
["integrity_failed" /* IntegrityFailed */]: "Platform integrity check failed.",
|
|
129
|
+
["invalid_input" /* InvalidInput */]: "Invalid request payload.",
|
|
130
|
+
["unsupported_version" /* UnsupportedVersion */]: "Command version is not supported."
|
|
131
|
+
};
|
|
132
|
+
function createAttestationCommand(_ctx) {
|
|
133
|
+
return (input) => {
|
|
134
|
+
if (typeof window === "undefined" || !isCommandAvailable("attestation" /* Attestation */)) {
|
|
135
|
+
console.error(
|
|
136
|
+
"'attestation' command is unavailable. Check MiniKit.install() or update the app version"
|
|
137
|
+
);
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
if (!input.requestHash || input.requestHash.length === 0) {
|
|
141
|
+
console.error("'attestation' command requires a non-empty requestHash");
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const payload = {
|
|
145
|
+
request_hash: input.requestHash
|
|
146
|
+
};
|
|
147
|
+
sendMiniKitEvent({
|
|
148
|
+
command: "attestation" /* Attestation */,
|
|
149
|
+
version: COMMAND_VERSIONS["attestation" /* Attestation */],
|
|
150
|
+
payload
|
|
151
|
+
});
|
|
152
|
+
return payload;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function createAttestationAsyncCommand(ctx, syncCommand) {
|
|
156
|
+
return async (input) => {
|
|
157
|
+
return new Promise((resolve, reject) => {
|
|
158
|
+
try {
|
|
159
|
+
const handleResponse = (response) => {
|
|
160
|
+
ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
|
|
161
|
+
resolve({ commandPayload, finalPayload: response });
|
|
162
|
+
};
|
|
163
|
+
ctx.events.subscribe(
|
|
164
|
+
"miniapp-attestation" /* MiniAppAttestation */,
|
|
165
|
+
handleResponse
|
|
166
|
+
);
|
|
167
|
+
const commandPayload = syncCommand(input);
|
|
168
|
+
if (!commandPayload) {
|
|
169
|
+
ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
|
|
170
|
+
reject(
|
|
171
|
+
new Error(
|
|
172
|
+
"'attestation' command failed: command unavailable or invalid input"
|
|
173
|
+
)
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
} catch (error) {
|
|
177
|
+
ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
|
|
178
|
+
reject(error);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
109
184
|
// commands/chat.ts
|
|
110
185
|
var ChatErrorCodes = /* @__PURE__ */ ((ChatErrorCodes2) => {
|
|
111
186
|
ChatErrorCodes2["UserRejected"] = "user_rejected";
|
|
@@ -156,6 +231,24 @@ function createChatAsyncCommand(ctx, syncCommand) {
|
|
|
156
231
|
};
|
|
157
232
|
}
|
|
158
233
|
|
|
234
|
+
// commands/close-miniapp.ts
|
|
235
|
+
function createCloseMiniAppCommand(_ctx) {
|
|
236
|
+
return () => {
|
|
237
|
+
if (typeof window === "undefined" || !isCommandAvailable("close-miniapp" /* CloseMiniApp */)) {
|
|
238
|
+
console.error(
|
|
239
|
+
"'closeMiniApp' command is unavailable. Check MiniKit.install() or update the app version"
|
|
240
|
+
);
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
sendMiniKitEvent({
|
|
244
|
+
command: "close-miniapp" /* CloseMiniApp */,
|
|
245
|
+
version: COMMAND_VERSIONS["close-miniapp" /* CloseMiniApp */],
|
|
246
|
+
payload: {}
|
|
247
|
+
});
|
|
248
|
+
return true;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
159
252
|
// commands/get-permissions.ts
|
|
160
253
|
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
161
254
|
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
@@ -848,7 +941,7 @@ function createSignTypedDataAsyncCommand(ctx, syncCommand) {
|
|
|
848
941
|
import { VerificationLevel } from "@worldcoin/idkit-core";
|
|
849
942
|
import { encodeAction, generateSignal } from "@worldcoin/idkit-core/hashing";
|
|
850
943
|
import { AppErrorCodes } from "@worldcoin/idkit-core";
|
|
851
|
-
function createVerifyCommand(
|
|
944
|
+
function createVerifyCommand(ctx) {
|
|
852
945
|
return (payload) => {
|
|
853
946
|
if (typeof window === "undefined" || !isCommandAvailable("verify" /* Verify */)) {
|
|
854
947
|
console.error(
|
|
@@ -867,6 +960,9 @@ function createVerifyCommand(_ctx) {
|
|
|
867
960
|
verification_level: payload.verification_level || VerificationLevel.Orb,
|
|
868
961
|
timestamp
|
|
869
962
|
};
|
|
963
|
+
ctx.events.setVerifyActionProcessingOptions({
|
|
964
|
+
skip_proof_compression: payload.skip_proof_compression
|
|
965
|
+
});
|
|
870
966
|
sendMiniKitEvent({
|
|
871
967
|
command: "verify" /* Verify */,
|
|
872
968
|
version: COMMAND_VERSIONS["verify" /* Verify */],
|
|
@@ -876,12 +972,22 @@ function createVerifyCommand(_ctx) {
|
|
|
876
972
|
};
|
|
877
973
|
}
|
|
878
974
|
function createVerifyAsyncCommand(ctx, syncCommand) {
|
|
975
|
+
let hasInFlightVerifyRequest = false;
|
|
879
976
|
return async (payload) => {
|
|
977
|
+
if (hasInFlightVerifyRequest) {
|
|
978
|
+
return Promise.reject(
|
|
979
|
+
new Error(
|
|
980
|
+
"A verify request is already in flight. Wait for the current request to complete before sending another."
|
|
981
|
+
)
|
|
982
|
+
);
|
|
983
|
+
}
|
|
880
984
|
return new Promise((resolve, reject) => {
|
|
881
985
|
try {
|
|
986
|
+
hasInFlightVerifyRequest = true;
|
|
882
987
|
let commandPayload = null;
|
|
883
988
|
const handleResponse = (response) => {
|
|
884
989
|
ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
|
|
990
|
+
hasInFlightVerifyRequest = false;
|
|
885
991
|
resolve({ commandPayload, finalPayload: response });
|
|
886
992
|
};
|
|
887
993
|
ctx.events.subscribe(
|
|
@@ -889,7 +995,17 @@ function createVerifyAsyncCommand(ctx, syncCommand) {
|
|
|
889
995
|
handleResponse
|
|
890
996
|
);
|
|
891
997
|
commandPayload = syncCommand(payload);
|
|
998
|
+
if (commandPayload === null) {
|
|
999
|
+
ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
|
|
1000
|
+
hasInFlightVerifyRequest = false;
|
|
1001
|
+
reject(
|
|
1002
|
+
new Error(
|
|
1003
|
+
"Failed to send verify command. Ensure MiniKit is installed and the verify command is available."
|
|
1004
|
+
)
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
892
1007
|
} catch (error) {
|
|
1008
|
+
hasInFlightVerifyRequest = false;
|
|
893
1009
|
reject(error);
|
|
894
1010
|
}
|
|
895
1011
|
});
|
|
@@ -1285,7 +1401,9 @@ function createCommands(ctx) {
|
|
|
1285
1401
|
getPermissions: createGetPermissionsCommand(ctx),
|
|
1286
1402
|
sendHapticFeedback: createSendHapticFeedbackCommand(ctx),
|
|
1287
1403
|
share: createShareCommand(ctx),
|
|
1288
|
-
chat: createChatCommand(ctx)
|
|
1404
|
+
chat: createChatCommand(ctx),
|
|
1405
|
+
attestation: createAttestationCommand(ctx),
|
|
1406
|
+
closeMiniApp: createCloseMiniAppCommand(ctx)
|
|
1289
1407
|
};
|
|
1290
1408
|
}
|
|
1291
1409
|
function createAsyncCommands(ctx, commands) {
|
|
@@ -1313,7 +1431,8 @@ function createAsyncCommands(ctx, commands) {
|
|
|
1313
1431
|
commands.sendHapticFeedback
|
|
1314
1432
|
),
|
|
1315
1433
|
share: createShareAsyncCommand(ctx, commands.share),
|
|
1316
|
-
chat: createChatAsyncCommand(ctx, commands.chat)
|
|
1434
|
+
chat: createChatAsyncCommand(ctx, commands.chat),
|
|
1435
|
+
attestation: createAttestationAsyncCommand(ctx, commands.attestation)
|
|
1317
1436
|
};
|
|
1318
1437
|
}
|
|
1319
1438
|
|
|
@@ -1462,8 +1581,11 @@ var EventManager = class {
|
|
|
1462
1581
|
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
1463
1582
|
},
|
|
1464
1583
|
["miniapp-chat" /* MiniAppChat */]: () => {
|
|
1584
|
+
},
|
|
1585
|
+
["miniapp-attestation" /* MiniAppAttestation */]: () => {
|
|
1465
1586
|
}
|
|
1466
1587
|
};
|
|
1588
|
+
this.verifyActionProcessingOptionsQueue = [];
|
|
1467
1589
|
}
|
|
1468
1590
|
subscribe(event, handler) {
|
|
1469
1591
|
this.listeners[event] = handler;
|
|
@@ -1471,6 +1593,11 @@ var EventManager = class {
|
|
|
1471
1593
|
unsubscribe(event) {
|
|
1472
1594
|
delete this.listeners[event];
|
|
1473
1595
|
}
|
|
1596
|
+
setVerifyActionProcessingOptions(options) {
|
|
1597
|
+
this.verifyActionProcessingOptionsQueue.push({
|
|
1598
|
+
skip_proof_compression: Boolean(options?.skip_proof_compression ?? false)
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1474
1601
|
trigger(event, payload) {
|
|
1475
1602
|
if (!this.listeners[event]) {
|
|
1476
1603
|
console.error(
|
|
@@ -1480,20 +1607,23 @@ var EventManager = class {
|
|
|
1480
1607
|
}
|
|
1481
1608
|
if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
1482
1609
|
const handler = this.listeners[event];
|
|
1483
|
-
this.
|
|
1610
|
+
const processingOptions = this.verifyActionProcessingOptionsQueue.shift() ?? {
|
|
1611
|
+
skip_proof_compression: false
|
|
1612
|
+
};
|
|
1484
1613
|
this.processVerifyActionPayload(
|
|
1485
1614
|
payload,
|
|
1486
|
-
handler
|
|
1615
|
+
handler,
|
|
1616
|
+
processingOptions
|
|
1487
1617
|
);
|
|
1488
1618
|
return;
|
|
1489
1619
|
}
|
|
1490
1620
|
this.listeners[event](payload);
|
|
1491
1621
|
}
|
|
1492
|
-
async processVerifyActionPayload(payload, handler) {
|
|
1622
|
+
async processVerifyActionPayload(payload, handler, processingOptions) {
|
|
1493
1623
|
if (payload.status === "error" && payload.error_code === "user_rejected") {
|
|
1494
1624
|
payload.error_code = AppErrorCodes4.VerificationRejected;
|
|
1495
1625
|
}
|
|
1496
|
-
if (payload.status === "success") {
|
|
1626
|
+
if (payload.status === "success" && !processingOptions.skip_proof_compression) {
|
|
1497
1627
|
if ("verifications" in payload) {
|
|
1498
1628
|
const orbVerification = payload.verifications.find(
|
|
1499
1629
|
(v) => v.verification_level === VerificationLevel2.Orb
|
|
@@ -1565,6 +1695,7 @@ var MiniKitState = class {
|
|
|
1565
1695
|
initFromWorldApp(worldApp) {
|
|
1566
1696
|
if (!worldApp) return;
|
|
1567
1697
|
this.user.optedIntoOptionalAnalytics = worldApp.is_optional_analytics;
|
|
1698
|
+
this.user.preferredCurrency = worldApp.preferred_currency;
|
|
1568
1699
|
this.user.deviceOS = worldApp.device_os;
|
|
1569
1700
|
this.user.worldAppVersion = worldApp.world_app_version;
|
|
1570
1701
|
this.deviceProperties.safeAreaInsets = worldApp.safe_area_insets;
|
|
@@ -1887,10 +2018,15 @@ export {
|
|
|
1887
2018
|
setCommandAvailable,
|
|
1888
2019
|
validateCommands,
|
|
1889
2020
|
sendMiniKitEvent,
|
|
2021
|
+
AttestationErrorCodes,
|
|
2022
|
+
AttestationErrorMessage,
|
|
2023
|
+
createAttestationCommand,
|
|
2024
|
+
createAttestationAsyncCommand,
|
|
1890
2025
|
ChatErrorCodes,
|
|
1891
2026
|
ChatErrorMessage,
|
|
1892
2027
|
createChatCommand,
|
|
1893
2028
|
createChatAsyncCommand,
|
|
2029
|
+
createCloseMiniAppCommand,
|
|
1894
2030
|
GetPermissionsErrorCodes,
|
|
1895
2031
|
GetPermissionsErrorMessage,
|
|
1896
2032
|
Permission,
|
package/build/index.cjs
CHANGED
|
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// index.ts
|
|
21
21
|
var core_exports = {};
|
|
22
22
|
__export(core_exports, {
|
|
23
|
+
AttestationErrorCodes: () => AttestationErrorCodes,
|
|
24
|
+
AttestationErrorMessage: () => AttestationErrorMessage,
|
|
23
25
|
COMMAND_VERSIONS: () => COMMAND_VERSIONS,
|
|
24
26
|
ChatErrorCodes: () => ChatErrorCodes,
|
|
25
27
|
ChatErrorMessage: () => ChatErrorMessage,
|
|
@@ -56,8 +58,11 @@ __export(core_exports, {
|
|
|
56
58
|
WalletAuthErrorCodes: () => WalletAuthErrorCodes,
|
|
57
59
|
WalletAuthErrorMessage: () => WalletAuthErrorMessage,
|
|
58
60
|
createAsyncCommands: () => createAsyncCommands,
|
|
61
|
+
createAttestationAsyncCommand: () => createAttestationAsyncCommand,
|
|
62
|
+
createAttestationCommand: () => createAttestationCommand,
|
|
59
63
|
createChatAsyncCommand: () => createChatAsyncCommand,
|
|
60
64
|
createChatCommand: () => createChatCommand,
|
|
65
|
+
createCloseMiniAppCommand: () => createCloseMiniAppCommand,
|
|
61
66
|
createCommands: () => createCommands,
|
|
62
67
|
createGetPermissionsAsyncCommand: () => createGetPermissionsAsyncCommand,
|
|
63
68
|
createGetPermissionsCommand: () => createGetPermissionsCommand,
|
|
@@ -117,6 +122,8 @@ var Command = /* @__PURE__ */ ((Command2) => {
|
|
|
117
122
|
Command2["SendHapticFeedback"] = "send-haptic-feedback";
|
|
118
123
|
Command2["Share"] = "share";
|
|
119
124
|
Command2["Chat"] = "chat";
|
|
125
|
+
Command2["Attestation"] = "attestation";
|
|
126
|
+
Command2["CloseMiniApp"] = "close-miniapp";
|
|
120
127
|
return Command2;
|
|
121
128
|
})(Command || {});
|
|
122
129
|
var ResponseEvent = /* @__PURE__ */ ((ResponseEvent3) => {
|
|
@@ -133,6 +140,7 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent3) => {
|
|
|
133
140
|
ResponseEvent3["MiniAppShare"] = "miniapp-share";
|
|
134
141
|
ResponseEvent3["MiniAppMicrophone"] = "miniapp-microphone";
|
|
135
142
|
ResponseEvent3["MiniAppChat"] = "miniapp-chat";
|
|
143
|
+
ResponseEvent3["MiniAppAttestation"] = "miniapp-attestation";
|
|
136
144
|
return ResponseEvent3;
|
|
137
145
|
})(ResponseEvent || {});
|
|
138
146
|
var COMMAND_VERSIONS = {
|
|
@@ -147,7 +155,9 @@ var COMMAND_VERSIONS = {
|
|
|
147
155
|
["get-permissions" /* GetPermissions */]: 1,
|
|
148
156
|
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
149
157
|
["share" /* Share */]: 1,
|
|
150
|
-
["chat" /* Chat */]: 1
|
|
158
|
+
["chat" /* Chat */]: 1,
|
|
159
|
+
["attestation" /* Attestation */]: 1,
|
|
160
|
+
["close-miniapp" /* CloseMiniApp */]: 1
|
|
151
161
|
};
|
|
152
162
|
var commandAvailability = {
|
|
153
163
|
["verify" /* Verify */]: false,
|
|
@@ -161,7 +171,9 @@ var commandAvailability = {
|
|
|
161
171
|
["get-permissions" /* GetPermissions */]: false,
|
|
162
172
|
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
163
173
|
["share" /* Share */]: false,
|
|
164
|
-
["chat" /* Chat */]: false
|
|
174
|
+
["chat" /* Chat */]: false,
|
|
175
|
+
["attestation" /* Attestation */]: false,
|
|
176
|
+
["close-miniapp" /* CloseMiniApp */]: false
|
|
165
177
|
};
|
|
166
178
|
function isCommandAvailable(command) {
|
|
167
179
|
return commandAvailability[command];
|
|
@@ -202,6 +214,74 @@ function sendMiniKitEvent(payload) {
|
|
|
202
214
|
sendWebviewEvent(payload);
|
|
203
215
|
}
|
|
204
216
|
|
|
217
|
+
// commands/attestation.ts
|
|
218
|
+
var AttestationErrorCodes = /* @__PURE__ */ ((AttestationErrorCodes2) => {
|
|
219
|
+
AttestationErrorCodes2["Unauthorized"] = "unauthorized";
|
|
220
|
+
AttestationErrorCodes2["AttestationFailed"] = "attestation_failed";
|
|
221
|
+
AttestationErrorCodes2["IntegrityFailed"] = "integrity_failed";
|
|
222
|
+
AttestationErrorCodes2["InvalidInput"] = "invalid_input";
|
|
223
|
+
AttestationErrorCodes2["UnsupportedVersion"] = "unsupported_version";
|
|
224
|
+
return AttestationErrorCodes2;
|
|
225
|
+
})(AttestationErrorCodes || {});
|
|
226
|
+
var AttestationErrorMessage = {
|
|
227
|
+
["unauthorized" /* Unauthorized */]: "App is not whitelisted for attestation.",
|
|
228
|
+
["attestation_failed" /* AttestationFailed */]: "Failed to obtain token from attestation gateway.",
|
|
229
|
+
["integrity_failed" /* IntegrityFailed */]: "Platform integrity check failed.",
|
|
230
|
+
["invalid_input" /* InvalidInput */]: "Invalid request payload.",
|
|
231
|
+
["unsupported_version" /* UnsupportedVersion */]: "Command version is not supported."
|
|
232
|
+
};
|
|
233
|
+
function createAttestationCommand(_ctx) {
|
|
234
|
+
return (input) => {
|
|
235
|
+
if (typeof window === "undefined" || !isCommandAvailable("attestation" /* Attestation */)) {
|
|
236
|
+
console.error(
|
|
237
|
+
"'attestation' command is unavailable. Check MiniKit.install() or update the app version"
|
|
238
|
+
);
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
if (!input.requestHash || input.requestHash.length === 0) {
|
|
242
|
+
console.error("'attestation' command requires a non-empty requestHash");
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
const payload = {
|
|
246
|
+
request_hash: input.requestHash
|
|
247
|
+
};
|
|
248
|
+
sendMiniKitEvent({
|
|
249
|
+
command: "attestation" /* Attestation */,
|
|
250
|
+
version: COMMAND_VERSIONS["attestation" /* Attestation */],
|
|
251
|
+
payload
|
|
252
|
+
});
|
|
253
|
+
return payload;
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
function createAttestationAsyncCommand(ctx, syncCommand) {
|
|
257
|
+
return async (input) => {
|
|
258
|
+
return new Promise((resolve, reject) => {
|
|
259
|
+
try {
|
|
260
|
+
const handleResponse = (response) => {
|
|
261
|
+
ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
|
|
262
|
+
resolve({ commandPayload, finalPayload: response });
|
|
263
|
+
};
|
|
264
|
+
ctx.events.subscribe(
|
|
265
|
+
"miniapp-attestation" /* MiniAppAttestation */,
|
|
266
|
+
handleResponse
|
|
267
|
+
);
|
|
268
|
+
const commandPayload = syncCommand(input);
|
|
269
|
+
if (!commandPayload) {
|
|
270
|
+
ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
|
|
271
|
+
reject(
|
|
272
|
+
new Error(
|
|
273
|
+
"'attestation' command failed: command unavailable or invalid input"
|
|
274
|
+
)
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
} catch (error) {
|
|
278
|
+
ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
|
|
279
|
+
reject(error);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
205
285
|
// commands/chat.ts
|
|
206
286
|
var ChatErrorCodes = /* @__PURE__ */ ((ChatErrorCodes2) => {
|
|
207
287
|
ChatErrorCodes2["UserRejected"] = "user_rejected";
|
|
@@ -252,6 +332,24 @@ function createChatAsyncCommand(ctx, syncCommand) {
|
|
|
252
332
|
};
|
|
253
333
|
}
|
|
254
334
|
|
|
335
|
+
// commands/close-miniapp.ts
|
|
336
|
+
function createCloseMiniAppCommand(_ctx) {
|
|
337
|
+
return () => {
|
|
338
|
+
if (typeof window === "undefined" || !isCommandAvailable("close-miniapp" /* CloseMiniApp */)) {
|
|
339
|
+
console.error(
|
|
340
|
+
"'closeMiniApp' command is unavailable. Check MiniKit.install() or update the app version"
|
|
341
|
+
);
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
sendMiniKitEvent({
|
|
345
|
+
command: "close-miniapp" /* CloseMiniApp */,
|
|
346
|
+
version: COMMAND_VERSIONS["close-miniapp" /* CloseMiniApp */],
|
|
347
|
+
payload: {}
|
|
348
|
+
});
|
|
349
|
+
return true;
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
255
353
|
// commands/get-permissions.ts
|
|
256
354
|
var GetPermissionsErrorCodes = /* @__PURE__ */ ((GetPermissionsErrorCodes2) => {
|
|
257
355
|
GetPermissionsErrorCodes2["GenericError"] = "generic_error";
|
|
@@ -944,7 +1042,7 @@ function createSignTypedDataAsyncCommand(ctx, syncCommand) {
|
|
|
944
1042
|
var import_idkit_core = require("@worldcoin/idkit-core");
|
|
945
1043
|
var import_hashing = require("@worldcoin/idkit-core/hashing");
|
|
946
1044
|
var import_idkit_core2 = require("@worldcoin/idkit-core");
|
|
947
|
-
function createVerifyCommand(
|
|
1045
|
+
function createVerifyCommand(ctx) {
|
|
948
1046
|
return (payload) => {
|
|
949
1047
|
if (typeof window === "undefined" || !isCommandAvailable("verify" /* Verify */)) {
|
|
950
1048
|
console.error(
|
|
@@ -963,6 +1061,9 @@ function createVerifyCommand(_ctx) {
|
|
|
963
1061
|
verification_level: payload.verification_level || import_idkit_core.VerificationLevel.Orb,
|
|
964
1062
|
timestamp
|
|
965
1063
|
};
|
|
1064
|
+
ctx.events.setVerifyActionProcessingOptions({
|
|
1065
|
+
skip_proof_compression: payload.skip_proof_compression
|
|
1066
|
+
});
|
|
966
1067
|
sendMiniKitEvent({
|
|
967
1068
|
command: "verify" /* Verify */,
|
|
968
1069
|
version: COMMAND_VERSIONS["verify" /* Verify */],
|
|
@@ -972,12 +1073,22 @@ function createVerifyCommand(_ctx) {
|
|
|
972
1073
|
};
|
|
973
1074
|
}
|
|
974
1075
|
function createVerifyAsyncCommand(ctx, syncCommand) {
|
|
1076
|
+
let hasInFlightVerifyRequest = false;
|
|
975
1077
|
return async (payload) => {
|
|
1078
|
+
if (hasInFlightVerifyRequest) {
|
|
1079
|
+
return Promise.reject(
|
|
1080
|
+
new Error(
|
|
1081
|
+
"A verify request is already in flight. Wait for the current request to complete before sending another."
|
|
1082
|
+
)
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
976
1085
|
return new Promise((resolve, reject) => {
|
|
977
1086
|
try {
|
|
1087
|
+
hasInFlightVerifyRequest = true;
|
|
978
1088
|
let commandPayload = null;
|
|
979
1089
|
const handleResponse = (response) => {
|
|
980
1090
|
ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
|
|
1091
|
+
hasInFlightVerifyRequest = false;
|
|
981
1092
|
resolve({ commandPayload, finalPayload: response });
|
|
982
1093
|
};
|
|
983
1094
|
ctx.events.subscribe(
|
|
@@ -985,7 +1096,17 @@ function createVerifyAsyncCommand(ctx, syncCommand) {
|
|
|
985
1096
|
handleResponse
|
|
986
1097
|
);
|
|
987
1098
|
commandPayload = syncCommand(payload);
|
|
1099
|
+
if (commandPayload === null) {
|
|
1100
|
+
ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
|
|
1101
|
+
hasInFlightVerifyRequest = false;
|
|
1102
|
+
reject(
|
|
1103
|
+
new Error(
|
|
1104
|
+
"Failed to send verify command. Ensure MiniKit is installed and the verify command is available."
|
|
1105
|
+
)
|
|
1106
|
+
);
|
|
1107
|
+
}
|
|
988
1108
|
} catch (error) {
|
|
1109
|
+
hasInFlightVerifyRequest = false;
|
|
989
1110
|
reject(error);
|
|
990
1111
|
}
|
|
991
1112
|
});
|
|
@@ -1375,7 +1496,9 @@ function createCommands(ctx) {
|
|
|
1375
1496
|
getPermissions: createGetPermissionsCommand(ctx),
|
|
1376
1497
|
sendHapticFeedback: createSendHapticFeedbackCommand(ctx),
|
|
1377
1498
|
share: createShareCommand(ctx),
|
|
1378
|
-
chat: createChatCommand(ctx)
|
|
1499
|
+
chat: createChatCommand(ctx),
|
|
1500
|
+
attestation: createAttestationCommand(ctx),
|
|
1501
|
+
closeMiniApp: createCloseMiniAppCommand(ctx)
|
|
1379
1502
|
};
|
|
1380
1503
|
}
|
|
1381
1504
|
function createAsyncCommands(ctx, commands) {
|
|
@@ -1403,7 +1526,8 @@ function createAsyncCommands(ctx, commands) {
|
|
|
1403
1526
|
commands.sendHapticFeedback
|
|
1404
1527
|
),
|
|
1405
1528
|
share: createShareAsyncCommand(ctx, commands.share),
|
|
1406
|
-
chat: createChatAsyncCommand(ctx, commands.chat)
|
|
1529
|
+
chat: createChatAsyncCommand(ctx, commands.chat),
|
|
1530
|
+
attestation: createAttestationAsyncCommand(ctx, commands.attestation)
|
|
1407
1531
|
};
|
|
1408
1532
|
}
|
|
1409
1533
|
|
|
@@ -1489,8 +1613,11 @@ var EventManager = class {
|
|
|
1489
1613
|
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
1490
1614
|
},
|
|
1491
1615
|
["miniapp-chat" /* MiniAppChat */]: () => {
|
|
1616
|
+
},
|
|
1617
|
+
["miniapp-attestation" /* MiniAppAttestation */]: () => {
|
|
1492
1618
|
}
|
|
1493
1619
|
};
|
|
1620
|
+
this.verifyActionProcessingOptionsQueue = [];
|
|
1494
1621
|
}
|
|
1495
1622
|
subscribe(event, handler) {
|
|
1496
1623
|
this.listeners[event] = handler;
|
|
@@ -1498,6 +1625,11 @@ var EventManager = class {
|
|
|
1498
1625
|
unsubscribe(event) {
|
|
1499
1626
|
delete this.listeners[event];
|
|
1500
1627
|
}
|
|
1628
|
+
setVerifyActionProcessingOptions(options) {
|
|
1629
|
+
this.verifyActionProcessingOptionsQueue.push({
|
|
1630
|
+
skip_proof_compression: Boolean(options?.skip_proof_compression ?? false)
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1501
1633
|
trigger(event, payload) {
|
|
1502
1634
|
if (!this.listeners[event]) {
|
|
1503
1635
|
console.error(
|
|
@@ -1507,20 +1639,23 @@ var EventManager = class {
|
|
|
1507
1639
|
}
|
|
1508
1640
|
if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
1509
1641
|
const handler = this.listeners[event];
|
|
1510
|
-
this.
|
|
1642
|
+
const processingOptions = this.verifyActionProcessingOptionsQueue.shift() ?? {
|
|
1643
|
+
skip_proof_compression: false
|
|
1644
|
+
};
|
|
1511
1645
|
this.processVerifyActionPayload(
|
|
1512
1646
|
payload,
|
|
1513
|
-
handler
|
|
1647
|
+
handler,
|
|
1648
|
+
processingOptions
|
|
1514
1649
|
);
|
|
1515
1650
|
return;
|
|
1516
1651
|
}
|
|
1517
1652
|
this.listeners[event](payload);
|
|
1518
1653
|
}
|
|
1519
|
-
async processVerifyActionPayload(payload, handler) {
|
|
1654
|
+
async processVerifyActionPayload(payload, handler, processingOptions) {
|
|
1520
1655
|
if (payload.status === "error" && payload.error_code === "user_rejected") {
|
|
1521
1656
|
payload.error_code = import_idkit_core3.AppErrorCodes.VerificationRejected;
|
|
1522
1657
|
}
|
|
1523
|
-
if (payload.status === "success") {
|
|
1658
|
+
if (payload.status === "success" && !processingOptions.skip_proof_compression) {
|
|
1524
1659
|
if ("verifications" in payload) {
|
|
1525
1660
|
const orbVerification = payload.verifications.find(
|
|
1526
1661
|
(v) => v.verification_level === import_idkit_core3.VerificationLevel.Orb
|
|
@@ -1618,6 +1753,7 @@ var MiniKitState = class {
|
|
|
1618
1753
|
initFromWorldApp(worldApp) {
|
|
1619
1754
|
if (!worldApp) return;
|
|
1620
1755
|
this.user.optedIntoOptionalAnalytics = worldApp.is_optional_analytics;
|
|
1756
|
+
this.user.preferredCurrency = worldApp.preferred_currency;
|
|
1621
1757
|
this.user.deviceOS = worldApp.device_os;
|
|
1622
1758
|
this.user.worldAppVersion = worldApp.world_app_version;
|
|
1623
1759
|
this.deviceProperties.safeAreaInsets = worldApp.safe_area_insets;
|
|
@@ -2021,6 +2157,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
2021
2157
|
};
|
|
2022
2158
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2023
2159
|
0 && (module.exports = {
|
|
2160
|
+
AttestationErrorCodes,
|
|
2161
|
+
AttestationErrorMessage,
|
|
2024
2162
|
COMMAND_VERSIONS,
|
|
2025
2163
|
ChatErrorCodes,
|
|
2026
2164
|
ChatErrorMessage,
|
|
@@ -2057,8 +2195,11 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
2057
2195
|
WalletAuthErrorCodes,
|
|
2058
2196
|
WalletAuthErrorMessage,
|
|
2059
2197
|
createAsyncCommands,
|
|
2198
|
+
createAttestationAsyncCommand,
|
|
2199
|
+
createAttestationCommand,
|
|
2060
2200
|
createChatAsyncCommand,
|
|
2061
2201
|
createChatCommand,
|
|
2202
|
+
createCloseMiniAppCommand,
|
|
2062
2203
|
createCommands,
|
|
2063
2204
|
createGetPermissionsAsyncCommand,
|
|
2064
2205
|
createGetPermissionsCommand,
|
package/build/index.d.cts
CHANGED
|
@@ -13,6 +13,7 @@ type User = {
|
|
|
13
13
|
contacts: boolean;
|
|
14
14
|
};
|
|
15
15
|
optedIntoOptionalAnalytics?: boolean;
|
|
16
|
+
preferredCurrency?: string;
|
|
16
17
|
/** @deprecated Moved to DeviceProperties */
|
|
17
18
|
worldAppVersion?: number;
|
|
18
19
|
/** @deprecated Moved to DeviceProperties */
|
|
@@ -50,8 +51,12 @@ type EventPayload<T extends ResponseEvent = ResponseEvent> = any;
|
|
|
50
51
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
51
52
|
declare class EventManager {
|
|
52
53
|
private listeners;
|
|
54
|
+
private verifyActionProcessingOptionsQueue;
|
|
53
55
|
subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
|
|
54
56
|
unsubscribe(event: ResponseEvent): void;
|
|
57
|
+
setVerifyActionProcessingOptions(options?: {
|
|
58
|
+
skip_proof_compression?: boolean;
|
|
59
|
+
}): void;
|
|
55
60
|
trigger(event: ResponseEvent, payload: EventPayload): void;
|
|
56
61
|
private processVerifyActionPayload;
|
|
57
62
|
private compressProofSafely;
|
|
@@ -96,7 +101,9 @@ declare enum Command {
|
|
|
96
101
|
GetPermissions = "get-permissions",
|
|
97
102
|
SendHapticFeedback = "send-haptic-feedback",
|
|
98
103
|
Share = "share",
|
|
99
|
-
Chat = "chat"
|
|
104
|
+
Chat = "chat",
|
|
105
|
+
Attestation = "attestation",
|
|
106
|
+
CloseMiniApp = "close-miniapp"
|
|
100
107
|
}
|
|
101
108
|
declare enum ResponseEvent {
|
|
102
109
|
MiniAppVerifyAction = "miniapp-verify-action",
|
|
@@ -111,7 +118,8 @@ declare enum ResponseEvent {
|
|
|
111
118
|
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
|
|
112
119
|
MiniAppShare = "miniapp-share",
|
|
113
120
|
MiniAppMicrophone = "miniapp-microphone",
|
|
114
|
-
MiniAppChat = "miniapp-chat"
|
|
121
|
+
MiniAppChat = "miniapp-chat",
|
|
122
|
+
MiniAppAttestation = "miniapp-attestation"
|
|
115
123
|
}
|
|
116
124
|
declare const COMMAND_VERSIONS: Record<Command, number>;
|
|
117
125
|
declare function isCommandAvailable(command: Command): boolean;
|
|
@@ -149,6 +157,34 @@ type MiniKitInstallReturnType = {
|
|
|
149
157
|
};
|
|
150
158
|
declare function sendMiniKitEvent<T extends WebViewBasePayload = WebViewBasePayload>(payload: T): void;
|
|
151
159
|
|
|
160
|
+
type AttestationInput = {
|
|
161
|
+
/**
|
|
162
|
+
* Hex-encoded hash of the request to be attested.
|
|
163
|
+
* Hash must be generated per hashing spec documented in MiniKit docs.
|
|
164
|
+
*/
|
|
165
|
+
requestHash: string;
|
|
166
|
+
};
|
|
167
|
+
type AttestationPayload = {
|
|
168
|
+
request_hash: string;
|
|
169
|
+
};
|
|
170
|
+
declare enum AttestationErrorCodes {
|
|
171
|
+
Unauthorized = "unauthorized",
|
|
172
|
+
AttestationFailed = "attestation_failed",
|
|
173
|
+
IntegrityFailed = "integrity_failed",
|
|
174
|
+
InvalidInput = "invalid_input",
|
|
175
|
+
UnsupportedVersion = "unsupported_version"
|
|
176
|
+
}
|
|
177
|
+
declare const AttestationErrorMessage: Record<AttestationErrorCodes, string>;
|
|
178
|
+
type MiniAppAttestationSuccessPayload = MiniAppBaseSuccessPayload & {
|
|
179
|
+
token: string;
|
|
180
|
+
};
|
|
181
|
+
type MiniAppAttestationErrorPayload = MiniAppBaseErrorPayload<AttestationErrorCodes> & {
|
|
182
|
+
description: string;
|
|
183
|
+
};
|
|
184
|
+
type MiniAppAttestationPayload = MiniAppAttestationSuccessPayload | MiniAppAttestationErrorPayload;
|
|
185
|
+
declare function createAttestationCommand(_ctx: CommandContext): (input: AttestationInput) => AttestationPayload | null;
|
|
186
|
+
declare function createAttestationAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createAttestationCommand>): (input: AttestationInput) => AsyncHandlerReturn<AttestationPayload | null, MiniAppAttestationPayload>;
|
|
187
|
+
|
|
152
188
|
type ChatPayload = {
|
|
153
189
|
to?: string[];
|
|
154
190
|
message: string;
|
|
@@ -527,8 +563,9 @@ type VerifyCommandInput = {
|
|
|
527
563
|
action: IDKitConfig['action'];
|
|
528
564
|
signal?: IDKitConfig['signal'];
|
|
529
565
|
verification_level?: VerificationLevel | [VerificationLevel, ...VerificationLevel[]];
|
|
566
|
+
skip_proof_compression?: boolean;
|
|
530
567
|
};
|
|
531
|
-
type VerifyCommandPayload = VerifyCommandInput & {
|
|
568
|
+
type VerifyCommandPayload = Omit<VerifyCommandInput, 'skip_proof_compression'> & {
|
|
532
569
|
timestamp: string;
|
|
533
570
|
};
|
|
534
571
|
|
|
@@ -544,9 +581,11 @@ type MiniAppVerifyActionMultiSuccessPayload = MiniAppBaseSuccessPayload & {
|
|
|
544
581
|
};
|
|
545
582
|
type MiniAppVerifyActionErrorPayload = MiniAppBaseErrorPayload<string>;
|
|
546
583
|
type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionMultiSuccessPayload | MiniAppVerifyActionErrorPayload;
|
|
547
|
-
declare function createVerifyCommand(
|
|
584
|
+
declare function createVerifyCommand(ctx: CommandContext): (payload: VerifyCommandInput) => VerifyCommandPayload | null;
|
|
548
585
|
declare function createVerifyAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createVerifyCommand>): (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
|
|
549
586
|
|
|
587
|
+
declare function createCloseMiniAppCommand(_ctx: CommandContext): () => boolean;
|
|
588
|
+
|
|
550
589
|
declare function createCommands(ctx: CommandContext): {
|
|
551
590
|
verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
|
|
552
591
|
pay: (payload: PayCommandInput) => PayCommandPayload | null;
|
|
@@ -560,6 +599,8 @@ declare function createCommands(ctx: CommandContext): {
|
|
|
560
599
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
561
600
|
share: (payload: ShareInput) => ShareInput | null;
|
|
562
601
|
chat: (payload: ChatPayload) => ChatPayload | null;
|
|
602
|
+
attestation: (input: AttestationInput) => AttestationPayload | null;
|
|
603
|
+
closeMiniApp: () => boolean;
|
|
563
604
|
};
|
|
564
605
|
type Commands = ReturnType<typeof createCommands>;
|
|
565
606
|
declare function createAsyncCommands(ctx: CommandContext, commands: Commands): {
|
|
@@ -575,6 +616,7 @@ declare function createAsyncCommands(ctx: CommandContext, commands: Commands): {
|
|
|
575
616
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
576
617
|
share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
|
|
577
618
|
chat: (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
|
|
619
|
+
attestation: (input: AttestationInput) => AsyncHandlerReturn<AttestationPayload | null, MiniAppAttestationPayload>;
|
|
578
620
|
};
|
|
579
621
|
type AsyncCommands = ReturnType<typeof createAsyncCommands>;
|
|
580
622
|
|
|
@@ -638,4 +680,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
638
680
|
|
|
639
681
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
640
682
|
|
|
641
|
-
export { type AsyncCommands, type AsyncHandlerReturn, COMMAND_VERSIONS, ChatErrorCodes, ChatErrorMessage, type ChatPayload, Command, type CommandContext, type Commands, type Contact, type ContractFunctionArgs, type ContractFunctionName, type DeviceProperties, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppBaseErrorPayload, type MiniAppBaseSuccessPayload, type MiniAppChatErrorPayload, type MiniAppChatPayload, type MiniAppChatSuccessPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, MiniAppLaunchLocation, type MiniAppLocation, 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 MiniAppVerifyActionMultiSuccessPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload$1 as MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, Permission, type PermissionSettings, type Permit2, 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 Transaction, type User, type UserNameService, type VerificationResult, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, createAsyncCommands, createChatAsyncCommand, createChatCommand, createCommands, createGetPermissionsAsyncCommand, createGetPermissionsCommand, createPayAsyncCommand, createPayCommand, createRequestPermissionAsyncCommand, createRequestPermissionCommand, createSendHapticFeedbackAsyncCommand, createSendHapticFeedbackCommand, createSendTransactionAsyncCommand, createSendTransactionCommand, createShareAsyncCommand, createShareCommand, createShareContactsAsyncCommand, createShareContactsCommand, createSignMessageAsyncCommand, createSignMessageCommand, createSignTypedDataAsyncCommand, createSignTypedDataCommand, createVerifyAsyncCommand, createVerifyCommand, createWalletAuthAsyncCommand, createWalletAuthCommand, getIsUserVerified, isCommandAvailable, mapWorldAppLaunchLocation, parseSiweMessage, sendMiniKitEvent, setCommandAvailable, tokenToDecimals, validateCommands, verifySiweMessage };
|
|
683
|
+
export { type AsyncCommands, type AsyncHandlerReturn, AttestationErrorCodes, AttestationErrorMessage, type AttestationInput, type AttestationPayload, COMMAND_VERSIONS, ChatErrorCodes, ChatErrorMessage, type ChatPayload, Command, type CommandContext, type Commands, type Contact, type ContractFunctionArgs, type ContractFunctionName, type DeviceProperties, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppAttestationErrorPayload, type MiniAppAttestationPayload, type MiniAppAttestationSuccessPayload, type MiniAppBaseErrorPayload, type MiniAppBaseSuccessPayload, type MiniAppChatErrorPayload, type MiniAppChatPayload, type MiniAppChatSuccessPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, MiniAppLaunchLocation, type MiniAppLocation, 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 MiniAppVerifyActionMultiSuccessPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload$1 as MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, Permission, type PermissionSettings, type Permit2, 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 Transaction, type User, type UserNameService, type VerificationResult, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, createAsyncCommands, createAttestationAsyncCommand, createAttestationCommand, createChatAsyncCommand, createChatCommand, createCloseMiniAppCommand, createCommands, createGetPermissionsAsyncCommand, createGetPermissionsCommand, createPayAsyncCommand, createPayCommand, createRequestPermissionAsyncCommand, createRequestPermissionCommand, createSendHapticFeedbackAsyncCommand, createSendHapticFeedbackCommand, createSendTransactionAsyncCommand, createSendTransactionCommand, createShareAsyncCommand, createShareCommand, createShareContactsAsyncCommand, createShareContactsCommand, createSignMessageAsyncCommand, createSignMessageCommand, createSignTypedDataAsyncCommand, createSignTypedDataCommand, createVerifyAsyncCommand, createVerifyCommand, createWalletAuthAsyncCommand, createWalletAuthCommand, getIsUserVerified, isCommandAvailable, mapWorldAppLaunchLocation, parseSiweMessage, sendMiniKitEvent, setCommandAvailable, tokenToDecimals, validateCommands, verifySiweMessage };
|
package/build/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ type User = {
|
|
|
13
13
|
contacts: boolean;
|
|
14
14
|
};
|
|
15
15
|
optedIntoOptionalAnalytics?: boolean;
|
|
16
|
+
preferredCurrency?: string;
|
|
16
17
|
/** @deprecated Moved to DeviceProperties */
|
|
17
18
|
worldAppVersion?: number;
|
|
18
19
|
/** @deprecated Moved to DeviceProperties */
|
|
@@ -50,8 +51,12 @@ type EventPayload<T extends ResponseEvent = ResponseEvent> = any;
|
|
|
50
51
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
51
52
|
declare class EventManager {
|
|
52
53
|
private listeners;
|
|
54
|
+
private verifyActionProcessingOptionsQueue;
|
|
53
55
|
subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
|
|
54
56
|
unsubscribe(event: ResponseEvent): void;
|
|
57
|
+
setVerifyActionProcessingOptions(options?: {
|
|
58
|
+
skip_proof_compression?: boolean;
|
|
59
|
+
}): void;
|
|
55
60
|
trigger(event: ResponseEvent, payload: EventPayload): void;
|
|
56
61
|
private processVerifyActionPayload;
|
|
57
62
|
private compressProofSafely;
|
|
@@ -96,7 +101,9 @@ declare enum Command {
|
|
|
96
101
|
GetPermissions = "get-permissions",
|
|
97
102
|
SendHapticFeedback = "send-haptic-feedback",
|
|
98
103
|
Share = "share",
|
|
99
|
-
Chat = "chat"
|
|
104
|
+
Chat = "chat",
|
|
105
|
+
Attestation = "attestation",
|
|
106
|
+
CloseMiniApp = "close-miniapp"
|
|
100
107
|
}
|
|
101
108
|
declare enum ResponseEvent {
|
|
102
109
|
MiniAppVerifyAction = "miniapp-verify-action",
|
|
@@ -111,7 +118,8 @@ declare enum ResponseEvent {
|
|
|
111
118
|
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
|
|
112
119
|
MiniAppShare = "miniapp-share",
|
|
113
120
|
MiniAppMicrophone = "miniapp-microphone",
|
|
114
|
-
MiniAppChat = "miniapp-chat"
|
|
121
|
+
MiniAppChat = "miniapp-chat",
|
|
122
|
+
MiniAppAttestation = "miniapp-attestation"
|
|
115
123
|
}
|
|
116
124
|
declare const COMMAND_VERSIONS: Record<Command, number>;
|
|
117
125
|
declare function isCommandAvailable(command: Command): boolean;
|
|
@@ -149,6 +157,34 @@ type MiniKitInstallReturnType = {
|
|
|
149
157
|
};
|
|
150
158
|
declare function sendMiniKitEvent<T extends WebViewBasePayload = WebViewBasePayload>(payload: T): void;
|
|
151
159
|
|
|
160
|
+
type AttestationInput = {
|
|
161
|
+
/**
|
|
162
|
+
* Hex-encoded hash of the request to be attested.
|
|
163
|
+
* Hash must be generated per hashing spec documented in MiniKit docs.
|
|
164
|
+
*/
|
|
165
|
+
requestHash: string;
|
|
166
|
+
};
|
|
167
|
+
type AttestationPayload = {
|
|
168
|
+
request_hash: string;
|
|
169
|
+
};
|
|
170
|
+
declare enum AttestationErrorCodes {
|
|
171
|
+
Unauthorized = "unauthorized",
|
|
172
|
+
AttestationFailed = "attestation_failed",
|
|
173
|
+
IntegrityFailed = "integrity_failed",
|
|
174
|
+
InvalidInput = "invalid_input",
|
|
175
|
+
UnsupportedVersion = "unsupported_version"
|
|
176
|
+
}
|
|
177
|
+
declare const AttestationErrorMessage: Record<AttestationErrorCodes, string>;
|
|
178
|
+
type MiniAppAttestationSuccessPayload = MiniAppBaseSuccessPayload & {
|
|
179
|
+
token: string;
|
|
180
|
+
};
|
|
181
|
+
type MiniAppAttestationErrorPayload = MiniAppBaseErrorPayload<AttestationErrorCodes> & {
|
|
182
|
+
description: string;
|
|
183
|
+
};
|
|
184
|
+
type MiniAppAttestationPayload = MiniAppAttestationSuccessPayload | MiniAppAttestationErrorPayload;
|
|
185
|
+
declare function createAttestationCommand(_ctx: CommandContext): (input: AttestationInput) => AttestationPayload | null;
|
|
186
|
+
declare function createAttestationAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createAttestationCommand>): (input: AttestationInput) => AsyncHandlerReturn<AttestationPayload | null, MiniAppAttestationPayload>;
|
|
187
|
+
|
|
152
188
|
type ChatPayload = {
|
|
153
189
|
to?: string[];
|
|
154
190
|
message: string;
|
|
@@ -527,8 +563,9 @@ type VerifyCommandInput = {
|
|
|
527
563
|
action: IDKitConfig['action'];
|
|
528
564
|
signal?: IDKitConfig['signal'];
|
|
529
565
|
verification_level?: VerificationLevel | [VerificationLevel, ...VerificationLevel[]];
|
|
566
|
+
skip_proof_compression?: boolean;
|
|
530
567
|
};
|
|
531
|
-
type VerifyCommandPayload = VerifyCommandInput & {
|
|
568
|
+
type VerifyCommandPayload = Omit<VerifyCommandInput, 'skip_proof_compression'> & {
|
|
532
569
|
timestamp: string;
|
|
533
570
|
};
|
|
534
571
|
|
|
@@ -544,9 +581,11 @@ type MiniAppVerifyActionMultiSuccessPayload = MiniAppBaseSuccessPayload & {
|
|
|
544
581
|
};
|
|
545
582
|
type MiniAppVerifyActionErrorPayload = MiniAppBaseErrorPayload<string>;
|
|
546
583
|
type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionMultiSuccessPayload | MiniAppVerifyActionErrorPayload;
|
|
547
|
-
declare function createVerifyCommand(
|
|
584
|
+
declare function createVerifyCommand(ctx: CommandContext): (payload: VerifyCommandInput) => VerifyCommandPayload | null;
|
|
548
585
|
declare function createVerifyAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createVerifyCommand>): (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
|
|
549
586
|
|
|
587
|
+
declare function createCloseMiniAppCommand(_ctx: CommandContext): () => boolean;
|
|
588
|
+
|
|
550
589
|
declare function createCommands(ctx: CommandContext): {
|
|
551
590
|
verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
|
|
552
591
|
pay: (payload: PayCommandInput) => PayCommandPayload | null;
|
|
@@ -560,6 +599,8 @@ declare function createCommands(ctx: CommandContext): {
|
|
|
560
599
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
561
600
|
share: (payload: ShareInput) => ShareInput | null;
|
|
562
601
|
chat: (payload: ChatPayload) => ChatPayload | null;
|
|
602
|
+
attestation: (input: AttestationInput) => AttestationPayload | null;
|
|
603
|
+
closeMiniApp: () => boolean;
|
|
563
604
|
};
|
|
564
605
|
type Commands = ReturnType<typeof createCommands>;
|
|
565
606
|
declare function createAsyncCommands(ctx: CommandContext, commands: Commands): {
|
|
@@ -575,6 +616,7 @@ declare function createAsyncCommands(ctx: CommandContext, commands: Commands): {
|
|
|
575
616
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
576
617
|
share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
|
|
577
618
|
chat: (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
|
|
619
|
+
attestation: (input: AttestationInput) => AsyncHandlerReturn<AttestationPayload | null, MiniAppAttestationPayload>;
|
|
578
620
|
};
|
|
579
621
|
type AsyncCommands = ReturnType<typeof createAsyncCommands>;
|
|
580
622
|
|
|
@@ -638,4 +680,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
638
680
|
|
|
639
681
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
640
682
|
|
|
641
|
-
export { type AsyncCommands, type AsyncHandlerReturn, COMMAND_VERSIONS, ChatErrorCodes, ChatErrorMessage, type ChatPayload, Command, type CommandContext, type Commands, type Contact, type ContractFunctionArgs, type ContractFunctionName, type DeviceProperties, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppBaseErrorPayload, type MiniAppBaseSuccessPayload, type MiniAppChatErrorPayload, type MiniAppChatPayload, type MiniAppChatSuccessPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, MiniAppLaunchLocation, type MiniAppLocation, 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 MiniAppVerifyActionMultiSuccessPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload$1 as MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, Permission, type PermissionSettings, type Permit2, 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 Transaction, type User, type UserNameService, type VerificationResult, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, createAsyncCommands, createChatAsyncCommand, createChatCommand, createCommands, createGetPermissionsAsyncCommand, createGetPermissionsCommand, createPayAsyncCommand, createPayCommand, createRequestPermissionAsyncCommand, createRequestPermissionCommand, createSendHapticFeedbackAsyncCommand, createSendHapticFeedbackCommand, createSendTransactionAsyncCommand, createSendTransactionCommand, createShareAsyncCommand, createShareCommand, createShareContactsAsyncCommand, createShareContactsCommand, createSignMessageAsyncCommand, createSignMessageCommand, createSignTypedDataAsyncCommand, createSignTypedDataCommand, createVerifyAsyncCommand, createVerifyCommand, createWalletAuthAsyncCommand, createWalletAuthCommand, getIsUserVerified, isCommandAvailable, mapWorldAppLaunchLocation, parseSiweMessage, sendMiniKitEvent, setCommandAvailable, tokenToDecimals, validateCommands, verifySiweMessage };
|
|
683
|
+
export { type AsyncCommands, type AsyncHandlerReturn, AttestationErrorCodes, AttestationErrorMessage, type AttestationInput, type AttestationPayload, COMMAND_VERSIONS, ChatErrorCodes, ChatErrorMessage, type ChatPayload, Command, type CommandContext, type Commands, type Contact, type ContractFunctionArgs, type ContractFunctionName, type DeviceProperties, GetPermissionsErrorCodes, GetPermissionsErrorMessage, type GetPermissionsInput, type GetPermissionsPayload, type MiniAppAttestationErrorPayload, type MiniAppAttestationPayload, type MiniAppAttestationSuccessPayload, type MiniAppBaseErrorPayload, type MiniAppBaseSuccessPayload, type MiniAppChatErrorPayload, type MiniAppChatPayload, type MiniAppChatSuccessPayload, type MiniAppGetPermissionsErrorPayload, type MiniAppGetPermissionsPayload, type MiniAppGetPermissionsSuccessPayload, MiniAppLaunchLocation, type MiniAppLocation, 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 MiniAppVerifyActionMultiSuccessPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload$1 as MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, Permission, type PermissionSettings, type Permit2, 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 Transaction, type User, type UserNameService, type VerificationResult, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, createAsyncCommands, createAttestationAsyncCommand, createAttestationCommand, createChatAsyncCommand, createChatCommand, createCloseMiniAppCommand, createCommands, createGetPermissionsAsyncCommand, createGetPermissionsCommand, createPayAsyncCommand, createPayCommand, createRequestPermissionAsyncCommand, createRequestPermissionCommand, createSendHapticFeedbackAsyncCommand, createSendHapticFeedbackCommand, createSendTransactionAsyncCommand, createSendTransactionCommand, createShareAsyncCommand, createShareCommand, createShareContactsAsyncCommand, createShareContactsCommand, createSignMessageAsyncCommand, createSignMessageCommand, createSignTypedDataAsyncCommand, createSignTypedDataCommand, createVerifyAsyncCommand, createVerifyCommand, createWalletAuthAsyncCommand, createWalletAuthCommand, getIsUserVerified, isCommandAvailable, mapWorldAppLaunchLocation, parseSiweMessage, sendMiniKitEvent, setCommandAvailable, tokenToDecimals, validateCommands, verifySiweMessage };
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AppErrorCodes,
|
|
3
|
+
AttestationErrorCodes,
|
|
4
|
+
AttestationErrorMessage,
|
|
3
5
|
COMMAND_VERSIONS,
|
|
4
6
|
ChatErrorCodes,
|
|
5
7
|
ChatErrorMessage,
|
|
@@ -34,8 +36,11 @@ import {
|
|
|
34
36
|
WalletAuthErrorCodes,
|
|
35
37
|
WalletAuthErrorMessage,
|
|
36
38
|
createAsyncCommands,
|
|
39
|
+
createAttestationAsyncCommand,
|
|
40
|
+
createAttestationCommand,
|
|
37
41
|
createChatAsyncCommand,
|
|
38
42
|
createChatCommand,
|
|
43
|
+
createCloseMiniAppCommand,
|
|
39
44
|
createCommands,
|
|
40
45
|
createGetPermissionsAsyncCommand,
|
|
41
46
|
createGetPermissionsCommand,
|
|
@@ -67,7 +72,7 @@ import {
|
|
|
67
72
|
tokenToDecimals,
|
|
68
73
|
validateCommands,
|
|
69
74
|
verifySiweMessage
|
|
70
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-RTX3LRWR.js";
|
|
71
76
|
|
|
72
77
|
// index.ts
|
|
73
78
|
import { VerificationLevel } from "@worldcoin/idkit-core";
|
|
@@ -127,6 +132,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
127
132
|
}
|
|
128
133
|
};
|
|
129
134
|
export {
|
|
135
|
+
AttestationErrorCodes,
|
|
136
|
+
AttestationErrorMessage,
|
|
130
137
|
COMMAND_VERSIONS,
|
|
131
138
|
ChatErrorCodes,
|
|
132
139
|
ChatErrorMessage,
|
|
@@ -163,8 +170,11 @@ export {
|
|
|
163
170
|
WalletAuthErrorCodes,
|
|
164
171
|
WalletAuthErrorMessage,
|
|
165
172
|
createAsyncCommands,
|
|
173
|
+
createAttestationAsyncCommand,
|
|
174
|
+
createAttestationCommand,
|
|
166
175
|
createChatAsyncCommand,
|
|
167
176
|
createChatCommand,
|
|
177
|
+
createCloseMiniAppCommand,
|
|
168
178
|
createCommands,
|
|
169
179
|
createGetPermissionsAsyncCommand,
|
|
170
180
|
createGetPermissionsCommand,
|
|
@@ -49,7 +49,9 @@ var COMMAND_VERSIONS = {
|
|
|
49
49
|
["get-permissions" /* GetPermissions */]: 1,
|
|
50
50
|
["send-haptic-feedback" /* SendHapticFeedback */]: 1,
|
|
51
51
|
["share" /* Share */]: 1,
|
|
52
|
-
["chat" /* Chat */]: 1
|
|
52
|
+
["chat" /* Chat */]: 1,
|
|
53
|
+
["attestation" /* Attestation */]: 1,
|
|
54
|
+
["close-miniapp" /* CloseMiniApp */]: 1
|
|
53
55
|
};
|
|
54
56
|
var commandAvailability = {
|
|
55
57
|
["verify" /* Verify */]: false,
|
|
@@ -63,7 +65,9 @@ var commandAvailability = {
|
|
|
63
65
|
["get-permissions" /* GetPermissions */]: false,
|
|
64
66
|
["send-haptic-feedback" /* SendHapticFeedback */]: false,
|
|
65
67
|
["share" /* Share */]: false,
|
|
66
|
-
["chat" /* Chat */]: false
|
|
68
|
+
["chat" /* Chat */]: false,
|
|
69
|
+
["attestation" /* Attestation */]: false,
|
|
70
|
+
["close-miniapp" /* CloseMiniApp */]: false
|
|
67
71
|
};
|
|
68
72
|
function isCommandAvailable(command) {
|
|
69
73
|
return commandAvailability[command];
|
|
@@ -104,6 +108,59 @@ function sendMiniKitEvent(payload) {
|
|
|
104
108
|
sendWebviewEvent(payload);
|
|
105
109
|
}
|
|
106
110
|
|
|
111
|
+
// commands/attestation.ts
|
|
112
|
+
function createAttestationCommand(_ctx) {
|
|
113
|
+
return (input) => {
|
|
114
|
+
if (typeof window === "undefined" || !isCommandAvailable("attestation" /* Attestation */)) {
|
|
115
|
+
console.error(
|
|
116
|
+
"'attestation' command is unavailable. Check MiniKit.install() or update the app version"
|
|
117
|
+
);
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
if (!input.requestHash || input.requestHash.length === 0) {
|
|
121
|
+
console.error("'attestation' command requires a non-empty requestHash");
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const payload = {
|
|
125
|
+
request_hash: input.requestHash
|
|
126
|
+
};
|
|
127
|
+
sendMiniKitEvent({
|
|
128
|
+
command: "attestation" /* Attestation */,
|
|
129
|
+
version: COMMAND_VERSIONS["attestation" /* Attestation */],
|
|
130
|
+
payload
|
|
131
|
+
});
|
|
132
|
+
return payload;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function createAttestationAsyncCommand(ctx, syncCommand) {
|
|
136
|
+
return async (input) => {
|
|
137
|
+
return new Promise((resolve, reject) => {
|
|
138
|
+
try {
|
|
139
|
+
const handleResponse = (response) => {
|
|
140
|
+
ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
|
|
141
|
+
resolve({ commandPayload, finalPayload: response });
|
|
142
|
+
};
|
|
143
|
+
ctx.events.subscribe(
|
|
144
|
+
"miniapp-attestation" /* MiniAppAttestation */,
|
|
145
|
+
handleResponse
|
|
146
|
+
);
|
|
147
|
+
const commandPayload = syncCommand(input);
|
|
148
|
+
if (!commandPayload) {
|
|
149
|
+
ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
|
|
150
|
+
reject(
|
|
151
|
+
new Error(
|
|
152
|
+
"'attestation' command failed: command unavailable or invalid input"
|
|
153
|
+
)
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
} catch (error) {
|
|
157
|
+
ctx.events.unsubscribe("miniapp-attestation" /* MiniAppAttestation */);
|
|
158
|
+
reject(error);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
107
164
|
// commands/chat.ts
|
|
108
165
|
function createChatCommand(_ctx) {
|
|
109
166
|
return (payload) => {
|
|
@@ -143,6 +200,24 @@ function createChatAsyncCommand(ctx, syncCommand) {
|
|
|
143
200
|
};
|
|
144
201
|
}
|
|
145
202
|
|
|
203
|
+
// commands/close-miniapp.ts
|
|
204
|
+
function createCloseMiniAppCommand(_ctx) {
|
|
205
|
+
return () => {
|
|
206
|
+
if (typeof window === "undefined" || !isCommandAvailable("close-miniapp" /* CloseMiniApp */)) {
|
|
207
|
+
console.error(
|
|
208
|
+
"'closeMiniApp' command is unavailable. Check MiniKit.install() or update the app version"
|
|
209
|
+
);
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
sendMiniKitEvent({
|
|
213
|
+
command: "close-miniapp" /* CloseMiniApp */,
|
|
214
|
+
version: COMMAND_VERSIONS["close-miniapp" /* CloseMiniApp */],
|
|
215
|
+
payload: {}
|
|
216
|
+
});
|
|
217
|
+
return true;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
146
221
|
// commands/get-permissions.ts
|
|
147
222
|
function createGetPermissionsCommand(_ctx) {
|
|
148
223
|
return () => {
|
|
@@ -664,7 +739,7 @@ function createSignTypedDataAsyncCommand(ctx, syncCommand) {
|
|
|
664
739
|
var import_idkit_core = require("@worldcoin/idkit-core");
|
|
665
740
|
var import_hashing = require("@worldcoin/idkit-core/hashing");
|
|
666
741
|
var import_idkit_core2 = require("@worldcoin/idkit-core");
|
|
667
|
-
function createVerifyCommand(
|
|
742
|
+
function createVerifyCommand(ctx) {
|
|
668
743
|
return (payload) => {
|
|
669
744
|
if (typeof window === "undefined" || !isCommandAvailable("verify" /* Verify */)) {
|
|
670
745
|
console.error(
|
|
@@ -683,6 +758,9 @@ function createVerifyCommand(_ctx) {
|
|
|
683
758
|
verification_level: payload.verification_level || import_idkit_core.VerificationLevel.Orb,
|
|
684
759
|
timestamp
|
|
685
760
|
};
|
|
761
|
+
ctx.events.setVerifyActionProcessingOptions({
|
|
762
|
+
skip_proof_compression: payload.skip_proof_compression
|
|
763
|
+
});
|
|
686
764
|
sendMiniKitEvent({
|
|
687
765
|
command: "verify" /* Verify */,
|
|
688
766
|
version: COMMAND_VERSIONS["verify" /* Verify */],
|
|
@@ -692,12 +770,22 @@ function createVerifyCommand(_ctx) {
|
|
|
692
770
|
};
|
|
693
771
|
}
|
|
694
772
|
function createVerifyAsyncCommand(ctx, syncCommand) {
|
|
773
|
+
let hasInFlightVerifyRequest = false;
|
|
695
774
|
return async (payload) => {
|
|
775
|
+
if (hasInFlightVerifyRequest) {
|
|
776
|
+
return Promise.reject(
|
|
777
|
+
new Error(
|
|
778
|
+
"A verify request is already in flight. Wait for the current request to complete before sending another."
|
|
779
|
+
)
|
|
780
|
+
);
|
|
781
|
+
}
|
|
696
782
|
return new Promise((resolve, reject) => {
|
|
697
783
|
try {
|
|
784
|
+
hasInFlightVerifyRequest = true;
|
|
698
785
|
let commandPayload = null;
|
|
699
786
|
const handleResponse = (response) => {
|
|
700
787
|
ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
|
|
788
|
+
hasInFlightVerifyRequest = false;
|
|
701
789
|
resolve({ commandPayload, finalPayload: response });
|
|
702
790
|
};
|
|
703
791
|
ctx.events.subscribe(
|
|
@@ -705,7 +793,17 @@ function createVerifyAsyncCommand(ctx, syncCommand) {
|
|
|
705
793
|
handleResponse
|
|
706
794
|
);
|
|
707
795
|
commandPayload = syncCommand(payload);
|
|
796
|
+
if (commandPayload === null) {
|
|
797
|
+
ctx.events.unsubscribe("miniapp-verify-action" /* MiniAppVerifyAction */);
|
|
798
|
+
hasInFlightVerifyRequest = false;
|
|
799
|
+
reject(
|
|
800
|
+
new Error(
|
|
801
|
+
"Failed to send verify command. Ensure MiniKit is installed and the verify command is available."
|
|
802
|
+
)
|
|
803
|
+
);
|
|
804
|
+
}
|
|
708
805
|
} catch (error) {
|
|
806
|
+
hasInFlightVerifyRequest = false;
|
|
709
807
|
reject(error);
|
|
710
808
|
}
|
|
711
809
|
});
|
|
@@ -870,7 +968,9 @@ function createCommands(ctx) {
|
|
|
870
968
|
getPermissions: createGetPermissionsCommand(ctx),
|
|
871
969
|
sendHapticFeedback: createSendHapticFeedbackCommand(ctx),
|
|
872
970
|
share: createShareCommand(ctx),
|
|
873
|
-
chat: createChatCommand(ctx)
|
|
971
|
+
chat: createChatCommand(ctx),
|
|
972
|
+
attestation: createAttestationCommand(ctx),
|
|
973
|
+
closeMiniApp: createCloseMiniAppCommand(ctx)
|
|
874
974
|
};
|
|
875
975
|
}
|
|
876
976
|
function createAsyncCommands(ctx, commands) {
|
|
@@ -898,7 +998,8 @@ function createAsyncCommands(ctx, commands) {
|
|
|
898
998
|
commands.sendHapticFeedback
|
|
899
999
|
),
|
|
900
1000
|
share: createShareAsyncCommand(ctx, commands.share),
|
|
901
|
-
chat: createChatAsyncCommand(ctx, commands.chat)
|
|
1001
|
+
chat: createChatAsyncCommand(ctx, commands.chat),
|
|
1002
|
+
attestation: createAttestationAsyncCommand(ctx, commands.attestation)
|
|
902
1003
|
};
|
|
903
1004
|
}
|
|
904
1005
|
|
|
@@ -984,8 +1085,11 @@ var EventManager = class {
|
|
|
984
1085
|
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
985
1086
|
},
|
|
986
1087
|
["miniapp-chat" /* MiniAppChat */]: () => {
|
|
1088
|
+
},
|
|
1089
|
+
["miniapp-attestation" /* MiniAppAttestation */]: () => {
|
|
987
1090
|
}
|
|
988
1091
|
};
|
|
1092
|
+
this.verifyActionProcessingOptionsQueue = [];
|
|
989
1093
|
}
|
|
990
1094
|
subscribe(event, handler) {
|
|
991
1095
|
this.listeners[event] = handler;
|
|
@@ -993,6 +1097,11 @@ var EventManager = class {
|
|
|
993
1097
|
unsubscribe(event) {
|
|
994
1098
|
delete this.listeners[event];
|
|
995
1099
|
}
|
|
1100
|
+
setVerifyActionProcessingOptions(options) {
|
|
1101
|
+
this.verifyActionProcessingOptionsQueue.push({
|
|
1102
|
+
skip_proof_compression: Boolean(options?.skip_proof_compression ?? false)
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
996
1105
|
trigger(event, payload) {
|
|
997
1106
|
if (!this.listeners[event]) {
|
|
998
1107
|
console.error(
|
|
@@ -1002,20 +1111,23 @@ var EventManager = class {
|
|
|
1002
1111
|
}
|
|
1003
1112
|
if (event === "miniapp-verify-action" /* MiniAppVerifyAction */) {
|
|
1004
1113
|
const handler = this.listeners[event];
|
|
1005
|
-
this.
|
|
1114
|
+
const processingOptions = this.verifyActionProcessingOptionsQueue.shift() ?? {
|
|
1115
|
+
skip_proof_compression: false
|
|
1116
|
+
};
|
|
1006
1117
|
this.processVerifyActionPayload(
|
|
1007
1118
|
payload,
|
|
1008
|
-
handler
|
|
1119
|
+
handler,
|
|
1120
|
+
processingOptions
|
|
1009
1121
|
);
|
|
1010
1122
|
return;
|
|
1011
1123
|
}
|
|
1012
1124
|
this.listeners[event](payload);
|
|
1013
1125
|
}
|
|
1014
|
-
async processVerifyActionPayload(payload, handler) {
|
|
1126
|
+
async processVerifyActionPayload(payload, handler, processingOptions) {
|
|
1015
1127
|
if (payload.status === "error" && payload.error_code === "user_rejected") {
|
|
1016
1128
|
payload.error_code = import_idkit_core3.AppErrorCodes.VerificationRejected;
|
|
1017
1129
|
}
|
|
1018
|
-
if (payload.status === "success") {
|
|
1130
|
+
if (payload.status === "success" && !processingOptions.skip_proof_compression) {
|
|
1019
1131
|
if ("verifications" in payload) {
|
|
1020
1132
|
const orbVerification = payload.verifications.find(
|
|
1021
1133
|
(v) => v.verification_level === import_idkit_core3.VerificationLevel.Orb
|
|
@@ -1105,6 +1217,7 @@ var MiniKitState = class {
|
|
|
1105
1217
|
initFromWorldApp(worldApp) {
|
|
1106
1218
|
if (!worldApp) return;
|
|
1107
1219
|
this.user.optedIntoOptionalAnalytics = worldApp.is_optional_analytics;
|
|
1220
|
+
this.user.preferredCurrency = worldApp.preferred_currency;
|
|
1108
1221
|
this.user.deviceOS = worldApp.device_os;
|
|
1109
1222
|
this.user.worldAppVersion = worldApp.world_app_version;
|
|
1110
1223
|
this.deviceProperties.safeAreaInsets = worldApp.safe_area_insets;
|