@worldcoin/minikit-js 1.9.11 → 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-YDNDO45D.js → chunk-RTX3LRWR.js} +108 -4
- package/build/index.cjs +113 -4
- package/build/index.d.cts +40 -3
- package/build/index.d.ts +40 -3
- package/build/index.js +11 -1
- package/build/minikit-provider.cjs +85 -4
- 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";
|
|
@@ -1308,7 +1401,9 @@ function createCommands(ctx) {
|
|
|
1308
1401
|
getPermissions: createGetPermissionsCommand(ctx),
|
|
1309
1402
|
sendHapticFeedback: createSendHapticFeedbackCommand(ctx),
|
|
1310
1403
|
share: createShareCommand(ctx),
|
|
1311
|
-
chat: createChatCommand(ctx)
|
|
1404
|
+
chat: createChatCommand(ctx),
|
|
1405
|
+
attestation: createAttestationCommand(ctx),
|
|
1406
|
+
closeMiniApp: createCloseMiniAppCommand(ctx)
|
|
1312
1407
|
};
|
|
1313
1408
|
}
|
|
1314
1409
|
function createAsyncCommands(ctx, commands) {
|
|
@@ -1336,7 +1431,8 @@ function createAsyncCommands(ctx, commands) {
|
|
|
1336
1431
|
commands.sendHapticFeedback
|
|
1337
1432
|
),
|
|
1338
1433
|
share: createShareAsyncCommand(ctx, commands.share),
|
|
1339
|
-
chat: createChatAsyncCommand(ctx, commands.chat)
|
|
1434
|
+
chat: createChatAsyncCommand(ctx, commands.chat),
|
|
1435
|
+
attestation: createAttestationAsyncCommand(ctx, commands.attestation)
|
|
1340
1436
|
};
|
|
1341
1437
|
}
|
|
1342
1438
|
|
|
@@ -1485,6 +1581,8 @@ var EventManager = class {
|
|
|
1485
1581
|
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
1486
1582
|
},
|
|
1487
1583
|
["miniapp-chat" /* MiniAppChat */]: () => {
|
|
1584
|
+
},
|
|
1585
|
+
["miniapp-attestation" /* MiniAppAttestation */]: () => {
|
|
1488
1586
|
}
|
|
1489
1587
|
};
|
|
1490
1588
|
this.verifyActionProcessingOptionsQueue = [];
|
|
@@ -1597,6 +1695,7 @@ var MiniKitState = class {
|
|
|
1597
1695
|
initFromWorldApp(worldApp) {
|
|
1598
1696
|
if (!worldApp) return;
|
|
1599
1697
|
this.user.optedIntoOptionalAnalytics = worldApp.is_optional_analytics;
|
|
1698
|
+
this.user.preferredCurrency = worldApp.preferred_currency;
|
|
1600
1699
|
this.user.deviceOS = worldApp.device_os;
|
|
1601
1700
|
this.user.worldAppVersion = worldApp.world_app_version;
|
|
1602
1701
|
this.deviceProperties.safeAreaInsets = worldApp.safe_area_insets;
|
|
@@ -1919,10 +2018,15 @@ export {
|
|
|
1919
2018
|
setCommandAvailable,
|
|
1920
2019
|
validateCommands,
|
|
1921
2020
|
sendMiniKitEvent,
|
|
2021
|
+
AttestationErrorCodes,
|
|
2022
|
+
AttestationErrorMessage,
|
|
2023
|
+
createAttestationCommand,
|
|
2024
|
+
createAttestationAsyncCommand,
|
|
1922
2025
|
ChatErrorCodes,
|
|
1923
2026
|
ChatErrorMessage,
|
|
1924
2027
|
createChatCommand,
|
|
1925
2028
|
createChatAsyncCommand,
|
|
2029
|
+
createCloseMiniAppCommand,
|
|
1926
2030
|
GetPermissionsErrorCodes,
|
|
1927
2031
|
GetPermissionsErrorMessage,
|
|
1928
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";
|
|
@@ -1398,7 +1496,9 @@ function createCommands(ctx) {
|
|
|
1398
1496
|
getPermissions: createGetPermissionsCommand(ctx),
|
|
1399
1497
|
sendHapticFeedback: createSendHapticFeedbackCommand(ctx),
|
|
1400
1498
|
share: createShareCommand(ctx),
|
|
1401
|
-
chat: createChatCommand(ctx)
|
|
1499
|
+
chat: createChatCommand(ctx),
|
|
1500
|
+
attestation: createAttestationCommand(ctx),
|
|
1501
|
+
closeMiniApp: createCloseMiniAppCommand(ctx)
|
|
1402
1502
|
};
|
|
1403
1503
|
}
|
|
1404
1504
|
function createAsyncCommands(ctx, commands) {
|
|
@@ -1426,7 +1526,8 @@ function createAsyncCommands(ctx, commands) {
|
|
|
1426
1526
|
commands.sendHapticFeedback
|
|
1427
1527
|
),
|
|
1428
1528
|
share: createShareAsyncCommand(ctx, commands.share),
|
|
1429
|
-
chat: createChatAsyncCommand(ctx, commands.chat)
|
|
1529
|
+
chat: createChatAsyncCommand(ctx, commands.chat),
|
|
1530
|
+
attestation: createAttestationAsyncCommand(ctx, commands.attestation)
|
|
1430
1531
|
};
|
|
1431
1532
|
}
|
|
1432
1533
|
|
|
@@ -1512,6 +1613,8 @@ var EventManager = class {
|
|
|
1512
1613
|
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
1513
1614
|
},
|
|
1514
1615
|
["miniapp-chat" /* MiniAppChat */]: () => {
|
|
1616
|
+
},
|
|
1617
|
+
["miniapp-attestation" /* MiniAppAttestation */]: () => {
|
|
1515
1618
|
}
|
|
1516
1619
|
};
|
|
1517
1620
|
this.verifyActionProcessingOptionsQueue = [];
|
|
@@ -1650,6 +1753,7 @@ var MiniKitState = class {
|
|
|
1650
1753
|
initFromWorldApp(worldApp) {
|
|
1651
1754
|
if (!worldApp) return;
|
|
1652
1755
|
this.user.optedIntoOptionalAnalytics = worldApp.is_optional_analytics;
|
|
1756
|
+
this.user.preferredCurrency = worldApp.preferred_currency;
|
|
1653
1757
|
this.user.deviceOS = worldApp.device_os;
|
|
1654
1758
|
this.user.worldAppVersion = worldApp.world_app_version;
|
|
1655
1759
|
this.deviceProperties.safeAreaInsets = worldApp.safe_area_insets;
|
|
@@ -2053,6 +2157,8 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
2053
2157
|
};
|
|
2054
2158
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2055
2159
|
0 && (module.exports = {
|
|
2160
|
+
AttestationErrorCodes,
|
|
2161
|
+
AttestationErrorMessage,
|
|
2056
2162
|
COMMAND_VERSIONS,
|
|
2057
2163
|
ChatErrorCodes,
|
|
2058
2164
|
ChatErrorMessage,
|
|
@@ -2089,8 +2195,11 @@ var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
|
2089
2195
|
WalletAuthErrorCodes,
|
|
2090
2196
|
WalletAuthErrorMessage,
|
|
2091
2197
|
createAsyncCommands,
|
|
2198
|
+
createAttestationAsyncCommand,
|
|
2199
|
+
createAttestationCommand,
|
|
2092
2200
|
createChatAsyncCommand,
|
|
2093
2201
|
createChatCommand,
|
|
2202
|
+
createCloseMiniAppCommand,
|
|
2094
2203
|
createCommands,
|
|
2095
2204
|
createGetPermissionsAsyncCommand,
|
|
2096
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 */
|
|
@@ -100,7 +101,9 @@ declare enum Command {
|
|
|
100
101
|
GetPermissions = "get-permissions",
|
|
101
102
|
SendHapticFeedback = "send-haptic-feedback",
|
|
102
103
|
Share = "share",
|
|
103
|
-
Chat = "chat"
|
|
104
|
+
Chat = "chat",
|
|
105
|
+
Attestation = "attestation",
|
|
106
|
+
CloseMiniApp = "close-miniapp"
|
|
104
107
|
}
|
|
105
108
|
declare enum ResponseEvent {
|
|
106
109
|
MiniAppVerifyAction = "miniapp-verify-action",
|
|
@@ -115,7 +118,8 @@ declare enum ResponseEvent {
|
|
|
115
118
|
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
|
|
116
119
|
MiniAppShare = "miniapp-share",
|
|
117
120
|
MiniAppMicrophone = "miniapp-microphone",
|
|
118
|
-
MiniAppChat = "miniapp-chat"
|
|
121
|
+
MiniAppChat = "miniapp-chat",
|
|
122
|
+
MiniAppAttestation = "miniapp-attestation"
|
|
119
123
|
}
|
|
120
124
|
declare const COMMAND_VERSIONS: Record<Command, number>;
|
|
121
125
|
declare function isCommandAvailable(command: Command): boolean;
|
|
@@ -153,6 +157,34 @@ type MiniKitInstallReturnType = {
|
|
|
153
157
|
};
|
|
154
158
|
declare function sendMiniKitEvent<T extends WebViewBasePayload = WebViewBasePayload>(payload: T): void;
|
|
155
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
|
+
|
|
156
188
|
type ChatPayload = {
|
|
157
189
|
to?: string[];
|
|
158
190
|
message: string;
|
|
@@ -552,6 +584,8 @@ type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVer
|
|
|
552
584
|
declare function createVerifyCommand(ctx: CommandContext): (payload: VerifyCommandInput) => VerifyCommandPayload | null;
|
|
553
585
|
declare function createVerifyAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createVerifyCommand>): (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
|
|
554
586
|
|
|
587
|
+
declare function createCloseMiniAppCommand(_ctx: CommandContext): () => boolean;
|
|
588
|
+
|
|
555
589
|
declare function createCommands(ctx: CommandContext): {
|
|
556
590
|
verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
|
|
557
591
|
pay: (payload: PayCommandInput) => PayCommandPayload | null;
|
|
@@ -565,6 +599,8 @@ declare function createCommands(ctx: CommandContext): {
|
|
|
565
599
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
566
600
|
share: (payload: ShareInput) => ShareInput | null;
|
|
567
601
|
chat: (payload: ChatPayload) => ChatPayload | null;
|
|
602
|
+
attestation: (input: AttestationInput) => AttestationPayload | null;
|
|
603
|
+
closeMiniApp: () => boolean;
|
|
568
604
|
};
|
|
569
605
|
type Commands = ReturnType<typeof createCommands>;
|
|
570
606
|
declare function createAsyncCommands(ctx: CommandContext, commands: Commands): {
|
|
@@ -580,6 +616,7 @@ declare function createAsyncCommands(ctx: CommandContext, commands: Commands): {
|
|
|
580
616
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
581
617
|
share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
|
|
582
618
|
chat: (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
|
|
619
|
+
attestation: (input: AttestationInput) => AsyncHandlerReturn<AttestationPayload | null, MiniAppAttestationPayload>;
|
|
583
620
|
};
|
|
584
621
|
type AsyncCommands = ReturnType<typeof createAsyncCommands>;
|
|
585
622
|
|
|
@@ -643,4 +680,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
643
680
|
|
|
644
681
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
645
682
|
|
|
646
|
-
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 */
|
|
@@ -100,7 +101,9 @@ declare enum Command {
|
|
|
100
101
|
GetPermissions = "get-permissions",
|
|
101
102
|
SendHapticFeedback = "send-haptic-feedback",
|
|
102
103
|
Share = "share",
|
|
103
|
-
Chat = "chat"
|
|
104
|
+
Chat = "chat",
|
|
105
|
+
Attestation = "attestation",
|
|
106
|
+
CloseMiniApp = "close-miniapp"
|
|
104
107
|
}
|
|
105
108
|
declare enum ResponseEvent {
|
|
106
109
|
MiniAppVerifyAction = "miniapp-verify-action",
|
|
@@ -115,7 +118,8 @@ declare enum ResponseEvent {
|
|
|
115
118
|
MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
|
|
116
119
|
MiniAppShare = "miniapp-share",
|
|
117
120
|
MiniAppMicrophone = "miniapp-microphone",
|
|
118
|
-
MiniAppChat = "miniapp-chat"
|
|
121
|
+
MiniAppChat = "miniapp-chat",
|
|
122
|
+
MiniAppAttestation = "miniapp-attestation"
|
|
119
123
|
}
|
|
120
124
|
declare const COMMAND_VERSIONS: Record<Command, number>;
|
|
121
125
|
declare function isCommandAvailable(command: Command): boolean;
|
|
@@ -153,6 +157,34 @@ type MiniKitInstallReturnType = {
|
|
|
153
157
|
};
|
|
154
158
|
declare function sendMiniKitEvent<T extends WebViewBasePayload = WebViewBasePayload>(payload: T): void;
|
|
155
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
|
+
|
|
156
188
|
type ChatPayload = {
|
|
157
189
|
to?: string[];
|
|
158
190
|
message: string;
|
|
@@ -552,6 +584,8 @@ type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVer
|
|
|
552
584
|
declare function createVerifyCommand(ctx: CommandContext): (payload: VerifyCommandInput) => VerifyCommandPayload | null;
|
|
553
585
|
declare function createVerifyAsyncCommand(ctx: CommandContext, syncCommand: ReturnType<typeof createVerifyCommand>): (payload: VerifyCommandInput) => AsyncHandlerReturn<VerifyCommandPayload | null, MiniAppVerifyActionPayload>;
|
|
554
586
|
|
|
587
|
+
declare function createCloseMiniAppCommand(_ctx: CommandContext): () => boolean;
|
|
588
|
+
|
|
555
589
|
declare function createCommands(ctx: CommandContext): {
|
|
556
590
|
verify: (payload: VerifyCommandInput) => VerifyCommandPayload | null;
|
|
557
591
|
pay: (payload: PayCommandInput) => PayCommandPayload | null;
|
|
@@ -565,6 +599,8 @@ declare function createCommands(ctx: CommandContext): {
|
|
|
565
599
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => SendHapticFeedbackPayload | null;
|
|
566
600
|
share: (payload: ShareInput) => ShareInput | null;
|
|
567
601
|
chat: (payload: ChatPayload) => ChatPayload | null;
|
|
602
|
+
attestation: (input: AttestationInput) => AttestationPayload | null;
|
|
603
|
+
closeMiniApp: () => boolean;
|
|
568
604
|
};
|
|
569
605
|
type Commands = ReturnType<typeof createCommands>;
|
|
570
606
|
declare function createAsyncCommands(ctx: CommandContext, commands: Commands): {
|
|
@@ -580,6 +616,7 @@ declare function createAsyncCommands(ctx: CommandContext, commands: Commands): {
|
|
|
580
616
|
sendHapticFeedback: (payload: SendHapticFeedbackInput) => AsyncHandlerReturn<SendHapticFeedbackPayload | null, MiniAppSendHapticFeedbackPayload>;
|
|
581
617
|
share: (payload: ShareInput) => AsyncHandlerReturn<ShareInput | null, MiniAppSharePayload>;
|
|
582
618
|
chat: (payload: ChatPayload) => AsyncHandlerReturn<ChatPayload | null, MiniAppChatPayload>;
|
|
619
|
+
attestation: (input: AttestationInput) => AsyncHandlerReturn<AttestationPayload | null, MiniAppAttestationPayload>;
|
|
583
620
|
};
|
|
584
621
|
type AsyncCommands = ReturnType<typeof createAsyncCommands>;
|
|
585
622
|
|
|
@@ -643,4 +680,4 @@ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonc
|
|
|
643
680
|
|
|
644
681
|
declare const getIsUserVerified: (walletAddress: string, rpcUrl?: string) => Promise<boolean>;
|
|
645
682
|
|
|
646
|
-
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 () => {
|
|
@@ -893,7 +968,9 @@ function createCommands(ctx) {
|
|
|
893
968
|
getPermissions: createGetPermissionsCommand(ctx),
|
|
894
969
|
sendHapticFeedback: createSendHapticFeedbackCommand(ctx),
|
|
895
970
|
share: createShareCommand(ctx),
|
|
896
|
-
chat: createChatCommand(ctx)
|
|
971
|
+
chat: createChatCommand(ctx),
|
|
972
|
+
attestation: createAttestationCommand(ctx),
|
|
973
|
+
closeMiniApp: createCloseMiniAppCommand(ctx)
|
|
897
974
|
};
|
|
898
975
|
}
|
|
899
976
|
function createAsyncCommands(ctx, commands) {
|
|
@@ -921,7 +998,8 @@ function createAsyncCommands(ctx, commands) {
|
|
|
921
998
|
commands.sendHapticFeedback
|
|
922
999
|
),
|
|
923
1000
|
share: createShareAsyncCommand(ctx, commands.share),
|
|
924
|
-
chat: createChatAsyncCommand(ctx, commands.chat)
|
|
1001
|
+
chat: createChatAsyncCommand(ctx, commands.chat),
|
|
1002
|
+
attestation: createAttestationAsyncCommand(ctx, commands.attestation)
|
|
925
1003
|
};
|
|
926
1004
|
}
|
|
927
1005
|
|
|
@@ -1007,6 +1085,8 @@ var EventManager = class {
|
|
|
1007
1085
|
["miniapp-microphone" /* MiniAppMicrophone */]: () => {
|
|
1008
1086
|
},
|
|
1009
1087
|
["miniapp-chat" /* MiniAppChat */]: () => {
|
|
1088
|
+
},
|
|
1089
|
+
["miniapp-attestation" /* MiniAppAttestation */]: () => {
|
|
1010
1090
|
}
|
|
1011
1091
|
};
|
|
1012
1092
|
this.verifyActionProcessingOptionsQueue = [];
|
|
@@ -1137,6 +1217,7 @@ var MiniKitState = class {
|
|
|
1137
1217
|
initFromWorldApp(worldApp) {
|
|
1138
1218
|
if (!worldApp) return;
|
|
1139
1219
|
this.user.optedIntoOptionalAnalytics = worldApp.is_optional_analytics;
|
|
1220
|
+
this.user.preferredCurrency = worldApp.preferred_currency;
|
|
1140
1221
|
this.user.deviceOS = worldApp.device_os;
|
|
1141
1222
|
this.user.worldAppVersion = worldApp.world_app_version;
|
|
1142
1223
|
this.deviceProperties.safeAreaInsets = worldApp.safe_area_insets;
|