@worldcoin/minikit-js 0.0.2 → 0.0.22-internal-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.cjs +96 -21
- package/build/index.d.cts +47 -20
- package/build/index.d.ts +47 -20
- package/build/index.js +95 -21
- package/package.json +2 -3
package/build/index.cjs
CHANGED
|
@@ -22,6 +22,8 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Command: () => Command,
|
|
24
24
|
MiniKit: () => MiniKit,
|
|
25
|
+
MiniKitInstallErrorCode: () => MiniKitInstallErrorCode,
|
|
26
|
+
MiniKitInstallErrorMessage: () => MiniKitInstallErrorMessage,
|
|
25
27
|
Network: () => Network,
|
|
26
28
|
PaymentErrorCodes: () => PaymentErrorCodes,
|
|
27
29
|
PaymentErrorMessage: () => PaymentErrorMessage,
|
|
@@ -37,6 +39,7 @@ __export(src_exports, {
|
|
|
37
39
|
generateNonce: () => generateNonce,
|
|
38
40
|
parseSiweMessage: () => parseSiweMessage,
|
|
39
41
|
tokenToDecimals: () => tokenToDecimals,
|
|
42
|
+
verifyCloudProof: () => import_backend.verifyCloudProof,
|
|
40
43
|
verifySiweMessage: () => verifySiweMessage
|
|
41
44
|
});
|
|
42
45
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -182,13 +185,19 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
|
|
|
182
185
|
}
|
|
183
186
|
}
|
|
184
187
|
if (nonce && siweMessageData.nonce !== nonce) {
|
|
185
|
-
throw new Error(
|
|
188
|
+
throw new Error(
|
|
189
|
+
`Nonce mismatch. Got: ${siweMessageData.nonce}, Expected: ${nonce}`
|
|
190
|
+
);
|
|
186
191
|
}
|
|
187
192
|
if (statement && siweMessageData.statement !== statement) {
|
|
188
|
-
throw new Error(
|
|
193
|
+
throw new Error(
|
|
194
|
+
`Statement mismatch. Got: ${siweMessageData.statement}, Expected: ${statement}`
|
|
195
|
+
);
|
|
189
196
|
}
|
|
190
197
|
if (requestId && siweMessageData.request_id !== requestId) {
|
|
191
|
-
throw new Error(
|
|
198
|
+
throw new Error(
|
|
199
|
+
`Request ID mismatch. Got: ${siweMessageData.request_id}, Expected: ${requestId}`
|
|
200
|
+
);
|
|
192
201
|
}
|
|
193
202
|
let provider = userProvider || import_ethers.ethers.getDefaultProvider("https://mainnet.optimism.io");
|
|
194
203
|
const signedMessage = `${ERC_191_PREFIX}${message.length}${message}`;
|
|
@@ -199,7 +208,7 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
|
|
|
199
208
|
await contract.checkSignatures(
|
|
200
209
|
hashedMessage,
|
|
201
210
|
`0x${messageBytes}`,
|
|
202
|
-
signature
|
|
211
|
+
`0x${signature}`
|
|
203
212
|
);
|
|
204
213
|
} catch (error) {
|
|
205
214
|
throw new Error("Signature verification failed");
|
|
@@ -231,15 +240,12 @@ var VerificationErrorMessage = {
|
|
|
231
240
|
[import_idkit_core.AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
|
|
232
241
|
};
|
|
233
242
|
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
234
|
-
PaymentErrorCodes2["
|
|
243
|
+
PaymentErrorCodes2["InputError"] = "input_error";
|
|
235
244
|
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
236
245
|
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
237
246
|
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
238
247
|
PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
239
|
-
PaymentErrorCodes2["InvalidTokenAddress"] = "invalid_token_address";
|
|
240
|
-
PaymentErrorCodes2["InvalidAppId"] = "invalid_app_id";
|
|
241
248
|
PaymentErrorCodes2["GenericError"] = "generic_error";
|
|
242
|
-
PaymentErrorCodes2["DuplicateReference"] = "duplicate_reference";
|
|
243
249
|
return PaymentErrorCodes2;
|
|
244
250
|
})(PaymentErrorCodes || {});
|
|
245
251
|
var PaymentErrorMessage = /* @__PURE__ */ ((PaymentErrorMessage2) => {
|
|
@@ -255,15 +261,30 @@ var PaymentErrorMessage = /* @__PURE__ */ ((PaymentErrorMessage2) => {
|
|
|
255
261
|
return PaymentErrorMessage2;
|
|
256
262
|
})(PaymentErrorMessage || {});
|
|
257
263
|
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
258
|
-
WalletAuthErrorCodes2["InvalidAddress"] = "invalid_address";
|
|
259
264
|
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
260
265
|
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
266
|
+
WalletAuthErrorCodes2["GenericError"] = "generic_error";
|
|
261
267
|
return WalletAuthErrorCodes2;
|
|
262
268
|
})(WalletAuthErrorCodes || {});
|
|
263
269
|
var WalletAuthErrorMessage = {
|
|
264
|
-
["invalid_address" /* InvalidAddress */]: "The specified address is not valid for the connected wallet.",
|
|
265
270
|
["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
|
|
266
|
-
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
271
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
272
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
273
|
+
};
|
|
274
|
+
var MiniKitInstallErrorCode = /* @__PURE__ */ ((MiniKitInstallErrorCode2) => {
|
|
275
|
+
MiniKitInstallErrorCode2["Unknown"] = "unknown";
|
|
276
|
+
MiniKitInstallErrorCode2["AlreadyInstalled"] = "already_installed";
|
|
277
|
+
MiniKitInstallErrorCode2["OutsideOfWorldApp"] = "outside_of_worldapp";
|
|
278
|
+
MiniKitInstallErrorCode2["NotOnClient"] = "not_on_client";
|
|
279
|
+
MiniKitInstallErrorCode2["AppOutOfDate"] = "app_out_of_date";
|
|
280
|
+
return MiniKitInstallErrorCode2;
|
|
281
|
+
})(MiniKitInstallErrorCode || {});
|
|
282
|
+
var MiniKitInstallErrorMessage = {
|
|
283
|
+
["unknown" /* Unknown */]: "Failed to install MiniKit.",
|
|
284
|
+
["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
|
|
285
|
+
["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
|
|
286
|
+
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
287
|
+
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
267
288
|
};
|
|
268
289
|
|
|
269
290
|
// helpers/send-webview-event.ts
|
|
@@ -293,12 +314,12 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
293
314
|
|
|
294
315
|
// types/payment.ts
|
|
295
316
|
var Tokens = /* @__PURE__ */ ((Tokens2) => {
|
|
296
|
-
Tokens2["
|
|
317
|
+
Tokens2["USDCE"] = "USDCE";
|
|
297
318
|
Tokens2["WLD"] = "WLD";
|
|
298
319
|
return Tokens2;
|
|
299
320
|
})(Tokens || {});
|
|
300
321
|
var TokenDecimals = {
|
|
301
|
-
["
|
|
322
|
+
["USDCE" /* USDCE */]: 6,
|
|
302
323
|
["WLD" /* WLD */]: 18
|
|
303
324
|
};
|
|
304
325
|
var Network = /* @__PURE__ */ ((Network2) => {
|
|
@@ -337,6 +358,12 @@ var sendMiniKitEvent = (payload) => {
|
|
|
337
358
|
sendWebviewEvent(payload);
|
|
338
359
|
};
|
|
339
360
|
var _MiniKit = class _MiniKit {
|
|
361
|
+
static sendInit() {
|
|
362
|
+
sendWebviewEvent({
|
|
363
|
+
command: "init",
|
|
364
|
+
payload: { version: this.MINIKIT_VERSION }
|
|
365
|
+
});
|
|
366
|
+
}
|
|
340
367
|
static subscribe(event, handler) {
|
|
341
368
|
this.listeners[event] = handler;
|
|
342
369
|
}
|
|
@@ -350,14 +377,46 @@ var _MiniKit = class _MiniKit {
|
|
|
350
377
|
}
|
|
351
378
|
this.listeners[event](payload);
|
|
352
379
|
}
|
|
380
|
+
static commandsValid(input) {
|
|
381
|
+
return input.every(
|
|
382
|
+
(command) => command.supported_versions.includes(this.commandVersion[command.name])
|
|
383
|
+
);
|
|
384
|
+
}
|
|
353
385
|
static install() {
|
|
354
|
-
if (typeof window
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
386
|
+
if (typeof window === "undefined" || Boolean(window.MiniKit)) {
|
|
387
|
+
return {
|
|
388
|
+
success: false,
|
|
389
|
+
errorCode: "already_installed" /* AlreadyInstalled */,
|
|
390
|
+
errorMessage: MiniKitInstallErrorMessage["already_installed" /* AlreadyInstalled */]
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
if (!window.WorldApp) {
|
|
394
|
+
return {
|
|
395
|
+
success: false,
|
|
396
|
+
errorCode: "outside_of_worldapp" /* OutsideOfWorldApp */,
|
|
397
|
+
errorMessage: MiniKitInstallErrorMessage["outside_of_worldapp" /* OutsideOfWorldApp */]
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
if (!this.commandsValid(window.WorldApp.supported_commands)) {
|
|
401
|
+
return {
|
|
402
|
+
success: false,
|
|
403
|
+
errorCode: "app_out_of_date" /* AppOutOfDate */,
|
|
404
|
+
errorMessage: MiniKitInstallErrorMessage["app_out_of_date" /* AppOutOfDate */]
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
try {
|
|
408
|
+
window.MiniKit = _MiniKit;
|
|
409
|
+
this.sendInit();
|
|
410
|
+
} catch (error) {
|
|
411
|
+
console.error(
|
|
412
|
+
MiniKitInstallErrorMessage["unknown" /* Unknown */],
|
|
413
|
+
error
|
|
414
|
+
);
|
|
415
|
+
return {
|
|
416
|
+
success: false,
|
|
417
|
+
errorCode: "unknown" /* Unknown */,
|
|
418
|
+
errorMessage: MiniKitInstallErrorMessage["unknown" /* Unknown */]
|
|
419
|
+
};
|
|
361
420
|
}
|
|
362
421
|
return { success: true };
|
|
363
422
|
}
|
|
@@ -367,6 +426,12 @@ var _MiniKit = class _MiniKit {
|
|
|
367
426
|
return true;
|
|
368
427
|
}
|
|
369
428
|
};
|
|
429
|
+
_MiniKit.MINIKIT_VERSION = 1;
|
|
430
|
+
_MiniKit.commandVersion = {
|
|
431
|
+
["verify" /* Verify */]: 1,
|
|
432
|
+
["pay" /* Pay */]: 1,
|
|
433
|
+
["wallet-auth" /* WalletAuth */]: 1
|
|
434
|
+
};
|
|
370
435
|
_MiniKit.listeners = {
|
|
371
436
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
372
437
|
},
|
|
@@ -384,7 +449,11 @@ _MiniKit.commands = {
|
|
|
384
449
|
verification_level: payload.verification_level || import_idkit_core3.VerificationLevel.Orb,
|
|
385
450
|
timestamp
|
|
386
451
|
};
|
|
387
|
-
sendMiniKitEvent({
|
|
452
|
+
sendMiniKitEvent({
|
|
453
|
+
command: "verify" /* Verify */,
|
|
454
|
+
version: _MiniKit.commandVersion["verify" /* Verify */],
|
|
455
|
+
payload: eventPayload
|
|
456
|
+
});
|
|
388
457
|
return eventPayload;
|
|
389
458
|
},
|
|
390
459
|
pay: (payload) => {
|
|
@@ -405,6 +474,7 @@ _MiniKit.commands = {
|
|
|
405
474
|
};
|
|
406
475
|
sendMiniKitEvent({
|
|
407
476
|
command: "pay" /* Pay */,
|
|
477
|
+
version: _MiniKit.commandVersion["pay" /* Pay */],
|
|
408
478
|
payload: eventPayload
|
|
409
479
|
});
|
|
410
480
|
return eventPayload;
|
|
@@ -448,6 +518,7 @@ _MiniKit.commands = {
|
|
|
448
518
|
const walletAuthPayload = { siweMessage };
|
|
449
519
|
sendMiniKitEvent({
|
|
450
520
|
command: "wallet-auth" /* WalletAuth */,
|
|
521
|
+
version: _MiniKit.commandVersion["wallet-auth" /* WalletAuth */],
|
|
451
522
|
payload: walletAuthPayload
|
|
452
523
|
});
|
|
453
524
|
return walletAuthPayload;
|
|
@@ -474,10 +545,13 @@ var tokenToDecimals = (amount, token) => {
|
|
|
474
545
|
|
|
475
546
|
// index.ts
|
|
476
547
|
var import_idkit_core4 = require("@worldcoin/idkit-core");
|
|
548
|
+
var import_backend = require("@worldcoin/idkit-core/backend");
|
|
477
549
|
// Annotate the CommonJS export names for ESM import in node:
|
|
478
550
|
0 && (module.exports = {
|
|
479
551
|
Command,
|
|
480
552
|
MiniKit,
|
|
553
|
+
MiniKitInstallErrorCode,
|
|
554
|
+
MiniKitInstallErrorMessage,
|
|
481
555
|
Network,
|
|
482
556
|
PaymentErrorCodes,
|
|
483
557
|
PaymentErrorMessage,
|
|
@@ -493,5 +567,6 @@ var import_idkit_core4 = require("@worldcoin/idkit-core");
|
|
|
493
567
|
generateNonce,
|
|
494
568
|
parseSiweMessage,
|
|
495
569
|
tokenToDecimals,
|
|
570
|
+
verifyCloudProof,
|
|
496
571
|
verifySiweMessage
|
|
497
572
|
});
|
package/build/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { AppErrorCodes, VerificationLevel } from '@worldcoin/idkit-core';
|
|
3
|
-
export { AppErrorCodes as VerificationErrorCodes, VerificationLevel } from '@worldcoin/idkit-core';
|
|
3
|
+
export { ISuccessResult, AppErrorCodes as VerificationErrorCodes, VerificationLevel } from '@worldcoin/idkit-core';
|
|
4
4
|
import { IDKitConfig, VerificationLevel as VerificationLevel$1 } from '@worldcoin/idkit-core/*';
|
|
5
|
+
export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
|
|
5
6
|
|
|
6
7
|
type SiweMessage = {
|
|
7
8
|
scheme?: string;
|
|
@@ -19,7 +20,7 @@ type SiweMessage = {
|
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
declare enum Tokens {
|
|
22
|
-
|
|
23
|
+
USDCE = "USDCE",
|
|
23
24
|
WLD = "WLD"
|
|
24
25
|
}
|
|
25
26
|
declare const TokenDecimals: {
|
|
@@ -31,15 +32,12 @@ declare enum Network {
|
|
|
31
32
|
|
|
32
33
|
declare const VerificationErrorMessage: Record<AppErrorCodes, string>;
|
|
33
34
|
declare enum PaymentErrorCodes {
|
|
34
|
-
|
|
35
|
+
InputError = "input_error",
|
|
35
36
|
PaymentRejected = "payment_rejected",
|
|
36
37
|
InvalidReceiver = "invalid_receiver",
|
|
37
38
|
InsufficientBalance = "insufficient_balance",
|
|
38
39
|
TransactionFailed = "transaction_failed",
|
|
39
|
-
|
|
40
|
-
InvalidAppId = "invalid_app_id",
|
|
41
|
-
GenericError = "generic_error",
|
|
42
|
-
DuplicateReference = "duplicate_reference"
|
|
40
|
+
GenericError = "generic_error"
|
|
43
41
|
}
|
|
44
42
|
declare enum PaymentErrorMessage {
|
|
45
43
|
MalformedRequest = "There was a problem with this request. Please try again or contact the app owner.",
|
|
@@ -53,14 +51,28 @@ declare enum PaymentErrorMessage {
|
|
|
53
51
|
DuplicateReference = "This reference ID already exists please generate a new one and try again."
|
|
54
52
|
}
|
|
55
53
|
declare enum WalletAuthErrorCodes {
|
|
56
|
-
InvalidAddress = "invalid_address",
|
|
57
54
|
MalformedRequest = "malformed_request",
|
|
58
|
-
UserRejected = "user_rejected"
|
|
55
|
+
UserRejected = "user_rejected",
|
|
56
|
+
GenericError = "generic_error"
|
|
59
57
|
}
|
|
60
58
|
declare const WalletAuthErrorMessage: {
|
|
61
|
-
invalid_address: string;
|
|
62
59
|
malformed_request: string;
|
|
63
60
|
user_rejected: string;
|
|
61
|
+
generic_error: string;
|
|
62
|
+
};
|
|
63
|
+
declare enum MiniKitInstallErrorCode {
|
|
64
|
+
Unknown = "unknown",
|
|
65
|
+
AlreadyInstalled = "already_installed",
|
|
66
|
+
OutsideOfWorldApp = "outside_of_worldapp",
|
|
67
|
+
NotOnClient = "not_on_client",
|
|
68
|
+
AppOutOfDate = "app_out_of_date"
|
|
69
|
+
}
|
|
70
|
+
declare const MiniKitInstallErrorMessage: {
|
|
71
|
+
unknown: string;
|
|
72
|
+
already_installed: string;
|
|
73
|
+
outside_of_worldapp: string;
|
|
74
|
+
not_on_client: string;
|
|
75
|
+
app_out_of_date: string;
|
|
64
76
|
};
|
|
65
77
|
|
|
66
78
|
declare enum ResponseEvent {
|
|
@@ -74,23 +86,28 @@ type MiniAppVerifyActionSuccessPayload = {
|
|
|
74
86
|
merkle_root: string;
|
|
75
87
|
nullifier_hash: string;
|
|
76
88
|
verification_level: VerificationLevel;
|
|
89
|
+
version: number;
|
|
77
90
|
};
|
|
78
91
|
type MiniAppVerifyActionErrorPayload = {
|
|
79
92
|
status: "error";
|
|
80
93
|
error_code: AppErrorCodes;
|
|
94
|
+
version: number;
|
|
81
95
|
};
|
|
82
96
|
type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionErrorPayload;
|
|
83
97
|
type MiniAppPaymentSuccessEventPayload = {
|
|
84
98
|
status: "success";
|
|
85
99
|
transaction_status: "submitted";
|
|
100
|
+
transaction_id: string;
|
|
86
101
|
reference: string;
|
|
87
102
|
from: string;
|
|
88
103
|
chain: Network;
|
|
89
104
|
timestamp: string;
|
|
105
|
+
version: number;
|
|
90
106
|
};
|
|
91
107
|
type MiniAppPaymentErrorPayload = {
|
|
92
108
|
status: "error";
|
|
93
109
|
error_code: PaymentErrorCodes;
|
|
110
|
+
version: number;
|
|
94
111
|
};
|
|
95
112
|
type MiniAppPaymentPayload = MiniAppPaymentSuccessEventPayload | MiniAppPaymentErrorPayload;
|
|
96
113
|
type MiniAppWalletAuthSuccessPayload = {
|
|
@@ -98,11 +115,13 @@ type MiniAppWalletAuthSuccessPayload = {
|
|
|
98
115
|
message: string;
|
|
99
116
|
signature: string;
|
|
100
117
|
address: string;
|
|
118
|
+
version: number;
|
|
101
119
|
};
|
|
102
120
|
type MiniAppWalletAuthErrorPayload = {
|
|
103
121
|
status: "error";
|
|
104
122
|
error_code: WalletAuthErrorCodes;
|
|
105
123
|
details: (typeof WalletAuthErrorMessage)[WalletAuthErrorCodes];
|
|
124
|
+
version: number;
|
|
106
125
|
};
|
|
107
126
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends ResponseEvent.MiniAppVerifyAction ? MiniAppVerifyActionPayload : MiniAppPaymentPayload;
|
|
108
127
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -134,11 +153,14 @@ type VerifyCommandInput = {
|
|
|
134
153
|
signal?: IDKitConfig["signal"];
|
|
135
154
|
verification_level?: VerificationLevel$1;
|
|
136
155
|
};
|
|
156
|
+
type TokensPayload = {
|
|
157
|
+
symbol: Tokens;
|
|
158
|
+
token_amount: string;
|
|
159
|
+
};
|
|
137
160
|
type PayCommandInput = {
|
|
138
161
|
reference: string;
|
|
139
162
|
to: string;
|
|
140
|
-
|
|
141
|
-
token: Tokens;
|
|
163
|
+
tokens: TokensPayload[];
|
|
142
164
|
network?: Network;
|
|
143
165
|
description: string;
|
|
144
166
|
};
|
|
@@ -158,19 +180,24 @@ type PayCommandPayload = PayCommandInput & {
|
|
|
158
180
|
type WalletAuthPayload = {
|
|
159
181
|
siweMessage: string;
|
|
160
182
|
};
|
|
183
|
+
type MiniKitInstallReturnType = {
|
|
184
|
+
success: true;
|
|
185
|
+
} | {
|
|
186
|
+
success: false;
|
|
187
|
+
errorCode: MiniKitInstallErrorCode;
|
|
188
|
+
errorMessage: (typeof MiniKitInstallErrorMessage)[MiniKitInstallErrorCode];
|
|
189
|
+
};
|
|
161
190
|
|
|
162
191
|
declare class MiniKit {
|
|
192
|
+
private static readonly MINIKIT_VERSION;
|
|
193
|
+
private static readonly commandVersion;
|
|
163
194
|
private static listeners;
|
|
195
|
+
private static sendInit;
|
|
164
196
|
static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
|
|
165
197
|
static unsubscribe(event: ResponseEvent): void;
|
|
166
198
|
static trigger(event: ResponseEvent, payload: EventPayload): void;
|
|
167
|
-
static
|
|
168
|
-
|
|
169
|
-
error: unknown;
|
|
170
|
-
} | {
|
|
171
|
-
success: boolean;
|
|
172
|
-
error?: undefined;
|
|
173
|
-
};
|
|
199
|
+
private static commandsValid;
|
|
200
|
+
static install(): MiniKitInstallReturnType;
|
|
174
201
|
static isInstalled(debug?: boolean): boolean;
|
|
175
202
|
static commands: {
|
|
176
203
|
verify: (payload: VerifyCommandInput) => VerifyCommandPayload;
|
|
@@ -182,4 +209,4 @@ declare class MiniKit {
|
|
|
182
209
|
|
|
183
210
|
declare const tokenToDecimals: (amount: number, token: Tokens) => number;
|
|
184
211
|
|
|
185
|
-
export { Command, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessEventPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, Network, type PayCommandInput, PaymentErrorCodes, PaymentErrorMessage, ResponseEvent, SAFE_CONTRACT_ABI, type SiweMessage, TokenDecimals, Tokens, VerificationErrorMessage, type VerifyCommandInput, WalletAuthErrorCodes, WalletAuthErrorMessage, generateNonce, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
|
212
|
+
export { Command, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessEventPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCode, MiniKitInstallErrorMessage, Network, type PayCommandInput, PaymentErrorCodes, PaymentErrorMessage, ResponseEvent, SAFE_CONTRACT_ABI, type SiweMessage, TokenDecimals, Tokens, VerificationErrorMessage, type VerifyCommandInput, WalletAuthErrorCodes, WalletAuthErrorMessage, generateNonce, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
package/build/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { AppErrorCodes, VerificationLevel } from '@worldcoin/idkit-core';
|
|
3
|
-
export { AppErrorCodes as VerificationErrorCodes, VerificationLevel } from '@worldcoin/idkit-core';
|
|
3
|
+
export { ISuccessResult, AppErrorCodes as VerificationErrorCodes, VerificationLevel } from '@worldcoin/idkit-core';
|
|
4
4
|
import { IDKitConfig, VerificationLevel as VerificationLevel$1 } from '@worldcoin/idkit-core/*';
|
|
5
|
+
export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
|
|
5
6
|
|
|
6
7
|
type SiweMessage = {
|
|
7
8
|
scheme?: string;
|
|
@@ -19,7 +20,7 @@ type SiweMessage = {
|
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
declare enum Tokens {
|
|
22
|
-
|
|
23
|
+
USDCE = "USDCE",
|
|
23
24
|
WLD = "WLD"
|
|
24
25
|
}
|
|
25
26
|
declare const TokenDecimals: {
|
|
@@ -31,15 +32,12 @@ declare enum Network {
|
|
|
31
32
|
|
|
32
33
|
declare const VerificationErrorMessage: Record<AppErrorCodes, string>;
|
|
33
34
|
declare enum PaymentErrorCodes {
|
|
34
|
-
|
|
35
|
+
InputError = "input_error",
|
|
35
36
|
PaymentRejected = "payment_rejected",
|
|
36
37
|
InvalidReceiver = "invalid_receiver",
|
|
37
38
|
InsufficientBalance = "insufficient_balance",
|
|
38
39
|
TransactionFailed = "transaction_failed",
|
|
39
|
-
|
|
40
|
-
InvalidAppId = "invalid_app_id",
|
|
41
|
-
GenericError = "generic_error",
|
|
42
|
-
DuplicateReference = "duplicate_reference"
|
|
40
|
+
GenericError = "generic_error"
|
|
43
41
|
}
|
|
44
42
|
declare enum PaymentErrorMessage {
|
|
45
43
|
MalformedRequest = "There was a problem with this request. Please try again or contact the app owner.",
|
|
@@ -53,14 +51,28 @@ declare enum PaymentErrorMessage {
|
|
|
53
51
|
DuplicateReference = "This reference ID already exists please generate a new one and try again."
|
|
54
52
|
}
|
|
55
53
|
declare enum WalletAuthErrorCodes {
|
|
56
|
-
InvalidAddress = "invalid_address",
|
|
57
54
|
MalformedRequest = "malformed_request",
|
|
58
|
-
UserRejected = "user_rejected"
|
|
55
|
+
UserRejected = "user_rejected",
|
|
56
|
+
GenericError = "generic_error"
|
|
59
57
|
}
|
|
60
58
|
declare const WalletAuthErrorMessage: {
|
|
61
|
-
invalid_address: string;
|
|
62
59
|
malformed_request: string;
|
|
63
60
|
user_rejected: string;
|
|
61
|
+
generic_error: string;
|
|
62
|
+
};
|
|
63
|
+
declare enum MiniKitInstallErrorCode {
|
|
64
|
+
Unknown = "unknown",
|
|
65
|
+
AlreadyInstalled = "already_installed",
|
|
66
|
+
OutsideOfWorldApp = "outside_of_worldapp",
|
|
67
|
+
NotOnClient = "not_on_client",
|
|
68
|
+
AppOutOfDate = "app_out_of_date"
|
|
69
|
+
}
|
|
70
|
+
declare const MiniKitInstallErrorMessage: {
|
|
71
|
+
unknown: string;
|
|
72
|
+
already_installed: string;
|
|
73
|
+
outside_of_worldapp: string;
|
|
74
|
+
not_on_client: string;
|
|
75
|
+
app_out_of_date: string;
|
|
64
76
|
};
|
|
65
77
|
|
|
66
78
|
declare enum ResponseEvent {
|
|
@@ -74,23 +86,28 @@ type MiniAppVerifyActionSuccessPayload = {
|
|
|
74
86
|
merkle_root: string;
|
|
75
87
|
nullifier_hash: string;
|
|
76
88
|
verification_level: VerificationLevel;
|
|
89
|
+
version: number;
|
|
77
90
|
};
|
|
78
91
|
type MiniAppVerifyActionErrorPayload = {
|
|
79
92
|
status: "error";
|
|
80
93
|
error_code: AppErrorCodes;
|
|
94
|
+
version: number;
|
|
81
95
|
};
|
|
82
96
|
type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionErrorPayload;
|
|
83
97
|
type MiniAppPaymentSuccessEventPayload = {
|
|
84
98
|
status: "success";
|
|
85
99
|
transaction_status: "submitted";
|
|
100
|
+
transaction_id: string;
|
|
86
101
|
reference: string;
|
|
87
102
|
from: string;
|
|
88
103
|
chain: Network;
|
|
89
104
|
timestamp: string;
|
|
105
|
+
version: number;
|
|
90
106
|
};
|
|
91
107
|
type MiniAppPaymentErrorPayload = {
|
|
92
108
|
status: "error";
|
|
93
109
|
error_code: PaymentErrorCodes;
|
|
110
|
+
version: number;
|
|
94
111
|
};
|
|
95
112
|
type MiniAppPaymentPayload = MiniAppPaymentSuccessEventPayload | MiniAppPaymentErrorPayload;
|
|
96
113
|
type MiniAppWalletAuthSuccessPayload = {
|
|
@@ -98,11 +115,13 @@ type MiniAppWalletAuthSuccessPayload = {
|
|
|
98
115
|
message: string;
|
|
99
116
|
signature: string;
|
|
100
117
|
address: string;
|
|
118
|
+
version: number;
|
|
101
119
|
};
|
|
102
120
|
type MiniAppWalletAuthErrorPayload = {
|
|
103
121
|
status: "error";
|
|
104
122
|
error_code: WalletAuthErrorCodes;
|
|
105
123
|
details: (typeof WalletAuthErrorMessage)[WalletAuthErrorCodes];
|
|
124
|
+
version: number;
|
|
106
125
|
};
|
|
107
126
|
type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends ResponseEvent.MiniAppVerifyAction ? MiniAppVerifyActionPayload : MiniAppPaymentPayload;
|
|
108
127
|
type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
|
|
@@ -134,11 +153,14 @@ type VerifyCommandInput = {
|
|
|
134
153
|
signal?: IDKitConfig["signal"];
|
|
135
154
|
verification_level?: VerificationLevel$1;
|
|
136
155
|
};
|
|
156
|
+
type TokensPayload = {
|
|
157
|
+
symbol: Tokens;
|
|
158
|
+
token_amount: string;
|
|
159
|
+
};
|
|
137
160
|
type PayCommandInput = {
|
|
138
161
|
reference: string;
|
|
139
162
|
to: string;
|
|
140
|
-
|
|
141
|
-
token: Tokens;
|
|
163
|
+
tokens: TokensPayload[];
|
|
142
164
|
network?: Network;
|
|
143
165
|
description: string;
|
|
144
166
|
};
|
|
@@ -158,19 +180,24 @@ type PayCommandPayload = PayCommandInput & {
|
|
|
158
180
|
type WalletAuthPayload = {
|
|
159
181
|
siweMessage: string;
|
|
160
182
|
};
|
|
183
|
+
type MiniKitInstallReturnType = {
|
|
184
|
+
success: true;
|
|
185
|
+
} | {
|
|
186
|
+
success: false;
|
|
187
|
+
errorCode: MiniKitInstallErrorCode;
|
|
188
|
+
errorMessage: (typeof MiniKitInstallErrorMessage)[MiniKitInstallErrorCode];
|
|
189
|
+
};
|
|
161
190
|
|
|
162
191
|
declare class MiniKit {
|
|
192
|
+
private static readonly MINIKIT_VERSION;
|
|
193
|
+
private static readonly commandVersion;
|
|
163
194
|
private static listeners;
|
|
195
|
+
private static sendInit;
|
|
164
196
|
static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
|
|
165
197
|
static unsubscribe(event: ResponseEvent): void;
|
|
166
198
|
static trigger(event: ResponseEvent, payload: EventPayload): void;
|
|
167
|
-
static
|
|
168
|
-
|
|
169
|
-
error: unknown;
|
|
170
|
-
} | {
|
|
171
|
-
success: boolean;
|
|
172
|
-
error?: undefined;
|
|
173
|
-
};
|
|
199
|
+
private static commandsValid;
|
|
200
|
+
static install(): MiniKitInstallReturnType;
|
|
174
201
|
static isInstalled(debug?: boolean): boolean;
|
|
175
202
|
static commands: {
|
|
176
203
|
verify: (payload: VerifyCommandInput) => VerifyCommandPayload;
|
|
@@ -182,4 +209,4 @@ declare class MiniKit {
|
|
|
182
209
|
|
|
183
210
|
declare const tokenToDecimals: (amount: number, token: Tokens) => number;
|
|
184
211
|
|
|
185
|
-
export { Command, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessEventPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, Network, type PayCommandInput, PaymentErrorCodes, PaymentErrorMessage, ResponseEvent, SAFE_CONTRACT_ABI, type SiweMessage, TokenDecimals, Tokens, VerificationErrorMessage, type VerifyCommandInput, WalletAuthErrorCodes, WalletAuthErrorMessage, generateNonce, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
|
212
|
+
export { Command, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessEventPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCode, MiniKitInstallErrorMessage, Network, type PayCommandInput, PaymentErrorCodes, PaymentErrorMessage, ResponseEvent, SAFE_CONTRACT_ABI, type SiweMessage, TokenDecimals, Tokens, VerificationErrorMessage, type VerifyCommandInput, WalletAuthErrorCodes, WalletAuthErrorMessage, generateNonce, parseSiweMessage, tokenToDecimals, verifySiweMessage };
|
package/build/index.js
CHANGED
|
@@ -139,13 +139,19 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
if (nonce && siweMessageData.nonce !== nonce) {
|
|
142
|
-
throw new Error(
|
|
142
|
+
throw new Error(
|
|
143
|
+
`Nonce mismatch. Got: ${siweMessageData.nonce}, Expected: ${nonce}`
|
|
144
|
+
);
|
|
143
145
|
}
|
|
144
146
|
if (statement && siweMessageData.statement !== statement) {
|
|
145
|
-
throw new Error(
|
|
147
|
+
throw new Error(
|
|
148
|
+
`Statement mismatch. Got: ${siweMessageData.statement}, Expected: ${statement}`
|
|
149
|
+
);
|
|
146
150
|
}
|
|
147
151
|
if (requestId && siweMessageData.request_id !== requestId) {
|
|
148
|
-
throw new Error(
|
|
152
|
+
throw new Error(
|
|
153
|
+
`Request ID mismatch. Got: ${siweMessageData.request_id}, Expected: ${requestId}`
|
|
154
|
+
);
|
|
149
155
|
}
|
|
150
156
|
let provider = userProvider || ethers.getDefaultProvider("https://mainnet.optimism.io");
|
|
151
157
|
const signedMessage = `${ERC_191_PREFIX}${message.length}${message}`;
|
|
@@ -156,7 +162,7 @@ var verifySiweMessage = async (payload, nonce, statement, requestId, userProvide
|
|
|
156
162
|
await contract.checkSignatures(
|
|
157
163
|
hashedMessage,
|
|
158
164
|
`0x${messageBytes}`,
|
|
159
|
-
signature
|
|
165
|
+
`0x${signature}`
|
|
160
166
|
);
|
|
161
167
|
} catch (error) {
|
|
162
168
|
throw new Error("Signature verification failed");
|
|
@@ -188,15 +194,12 @@ var VerificationErrorMessage = {
|
|
|
188
194
|
[AppErrorCodes.ConnectionFailed]: "Connection to your wallet failed. Please try again."
|
|
189
195
|
};
|
|
190
196
|
var PaymentErrorCodes = /* @__PURE__ */ ((PaymentErrorCodes2) => {
|
|
191
|
-
PaymentErrorCodes2["
|
|
197
|
+
PaymentErrorCodes2["InputError"] = "input_error";
|
|
192
198
|
PaymentErrorCodes2["PaymentRejected"] = "payment_rejected";
|
|
193
199
|
PaymentErrorCodes2["InvalidReceiver"] = "invalid_receiver";
|
|
194
200
|
PaymentErrorCodes2["InsufficientBalance"] = "insufficient_balance";
|
|
195
201
|
PaymentErrorCodes2["TransactionFailed"] = "transaction_failed";
|
|
196
|
-
PaymentErrorCodes2["InvalidTokenAddress"] = "invalid_token_address";
|
|
197
|
-
PaymentErrorCodes2["InvalidAppId"] = "invalid_app_id";
|
|
198
202
|
PaymentErrorCodes2["GenericError"] = "generic_error";
|
|
199
|
-
PaymentErrorCodes2["DuplicateReference"] = "duplicate_reference";
|
|
200
203
|
return PaymentErrorCodes2;
|
|
201
204
|
})(PaymentErrorCodes || {});
|
|
202
205
|
var PaymentErrorMessage = /* @__PURE__ */ ((PaymentErrorMessage2) => {
|
|
@@ -212,15 +215,30 @@ var PaymentErrorMessage = /* @__PURE__ */ ((PaymentErrorMessage2) => {
|
|
|
212
215
|
return PaymentErrorMessage2;
|
|
213
216
|
})(PaymentErrorMessage || {});
|
|
214
217
|
var WalletAuthErrorCodes = /* @__PURE__ */ ((WalletAuthErrorCodes2) => {
|
|
215
|
-
WalletAuthErrorCodes2["InvalidAddress"] = "invalid_address";
|
|
216
218
|
WalletAuthErrorCodes2["MalformedRequest"] = "malformed_request";
|
|
217
219
|
WalletAuthErrorCodes2["UserRejected"] = "user_rejected";
|
|
220
|
+
WalletAuthErrorCodes2["GenericError"] = "generic_error";
|
|
218
221
|
return WalletAuthErrorCodes2;
|
|
219
222
|
})(WalletAuthErrorCodes || {});
|
|
220
223
|
var WalletAuthErrorMessage = {
|
|
221
|
-
["invalid_address" /* InvalidAddress */]: "The specified address is not valid for the connected wallet.",
|
|
222
224
|
["malformed_request" /* MalformedRequest */]: "Provided parameters in the request are invalid.",
|
|
223
|
-
["user_rejected" /* UserRejected */]: "User rejected the request."
|
|
225
|
+
["user_rejected" /* UserRejected */]: "User rejected the request.",
|
|
226
|
+
["generic_error" /* GenericError */]: "Something unexpected went wrong."
|
|
227
|
+
};
|
|
228
|
+
var MiniKitInstallErrorCode = /* @__PURE__ */ ((MiniKitInstallErrorCode2) => {
|
|
229
|
+
MiniKitInstallErrorCode2["Unknown"] = "unknown";
|
|
230
|
+
MiniKitInstallErrorCode2["AlreadyInstalled"] = "already_installed";
|
|
231
|
+
MiniKitInstallErrorCode2["OutsideOfWorldApp"] = "outside_of_worldapp";
|
|
232
|
+
MiniKitInstallErrorCode2["NotOnClient"] = "not_on_client";
|
|
233
|
+
MiniKitInstallErrorCode2["AppOutOfDate"] = "app_out_of_date";
|
|
234
|
+
return MiniKitInstallErrorCode2;
|
|
235
|
+
})(MiniKitInstallErrorCode || {});
|
|
236
|
+
var MiniKitInstallErrorMessage = {
|
|
237
|
+
["unknown" /* Unknown */]: "Failed to install MiniKit.",
|
|
238
|
+
["already_installed" /* AlreadyInstalled */]: "MiniKit is already installed.",
|
|
239
|
+
["outside_of_worldapp" /* OutsideOfWorldApp */]: "MiniApp launched outside of WorldApp.",
|
|
240
|
+
["not_on_client" /* NotOnClient */]: "Window object is not available.",
|
|
241
|
+
["app_out_of_date" /* AppOutOfDate */]: "WorldApp is out of date. Please update the app."
|
|
224
242
|
};
|
|
225
243
|
|
|
226
244
|
// helpers/send-webview-event.ts
|
|
@@ -250,12 +268,12 @@ var ResponseEvent = /* @__PURE__ */ ((ResponseEvent2) => {
|
|
|
250
268
|
|
|
251
269
|
// types/payment.ts
|
|
252
270
|
var Tokens = /* @__PURE__ */ ((Tokens2) => {
|
|
253
|
-
Tokens2["
|
|
271
|
+
Tokens2["USDCE"] = "USDCE";
|
|
254
272
|
Tokens2["WLD"] = "WLD";
|
|
255
273
|
return Tokens2;
|
|
256
274
|
})(Tokens || {});
|
|
257
275
|
var TokenDecimals = {
|
|
258
|
-
["
|
|
276
|
+
["USDCE" /* USDCE */]: 6,
|
|
259
277
|
["WLD" /* WLD */]: 18
|
|
260
278
|
};
|
|
261
279
|
var Network = /* @__PURE__ */ ((Network2) => {
|
|
@@ -294,6 +312,12 @@ var sendMiniKitEvent = (payload) => {
|
|
|
294
312
|
sendWebviewEvent(payload);
|
|
295
313
|
};
|
|
296
314
|
var _MiniKit = class _MiniKit {
|
|
315
|
+
static sendInit() {
|
|
316
|
+
sendWebviewEvent({
|
|
317
|
+
command: "init",
|
|
318
|
+
payload: { version: this.MINIKIT_VERSION }
|
|
319
|
+
});
|
|
320
|
+
}
|
|
297
321
|
static subscribe(event, handler) {
|
|
298
322
|
this.listeners[event] = handler;
|
|
299
323
|
}
|
|
@@ -307,14 +331,46 @@ var _MiniKit = class _MiniKit {
|
|
|
307
331
|
}
|
|
308
332
|
this.listeners[event](payload);
|
|
309
333
|
}
|
|
334
|
+
static commandsValid(input) {
|
|
335
|
+
return input.every(
|
|
336
|
+
(command) => command.supported_versions.includes(this.commandVersion[command.name])
|
|
337
|
+
);
|
|
338
|
+
}
|
|
310
339
|
static install() {
|
|
311
|
-
if (typeof window
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
340
|
+
if (typeof window === "undefined" || Boolean(window.MiniKit)) {
|
|
341
|
+
return {
|
|
342
|
+
success: false,
|
|
343
|
+
errorCode: "already_installed" /* AlreadyInstalled */,
|
|
344
|
+
errorMessage: MiniKitInstallErrorMessage["already_installed" /* AlreadyInstalled */]
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
if (!window.WorldApp) {
|
|
348
|
+
return {
|
|
349
|
+
success: false,
|
|
350
|
+
errorCode: "outside_of_worldapp" /* OutsideOfWorldApp */,
|
|
351
|
+
errorMessage: MiniKitInstallErrorMessage["outside_of_worldapp" /* OutsideOfWorldApp */]
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
if (!this.commandsValid(window.WorldApp.supported_commands)) {
|
|
355
|
+
return {
|
|
356
|
+
success: false,
|
|
357
|
+
errorCode: "app_out_of_date" /* AppOutOfDate */,
|
|
358
|
+
errorMessage: MiniKitInstallErrorMessage["app_out_of_date" /* AppOutOfDate */]
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
try {
|
|
362
|
+
window.MiniKit = _MiniKit;
|
|
363
|
+
this.sendInit();
|
|
364
|
+
} catch (error) {
|
|
365
|
+
console.error(
|
|
366
|
+
MiniKitInstallErrorMessage["unknown" /* Unknown */],
|
|
367
|
+
error
|
|
368
|
+
);
|
|
369
|
+
return {
|
|
370
|
+
success: false,
|
|
371
|
+
errorCode: "unknown" /* Unknown */,
|
|
372
|
+
errorMessage: MiniKitInstallErrorMessage["unknown" /* Unknown */]
|
|
373
|
+
};
|
|
318
374
|
}
|
|
319
375
|
return { success: true };
|
|
320
376
|
}
|
|
@@ -324,6 +380,12 @@ var _MiniKit = class _MiniKit {
|
|
|
324
380
|
return true;
|
|
325
381
|
}
|
|
326
382
|
};
|
|
383
|
+
_MiniKit.MINIKIT_VERSION = 1;
|
|
384
|
+
_MiniKit.commandVersion = {
|
|
385
|
+
["verify" /* Verify */]: 1,
|
|
386
|
+
["pay" /* Pay */]: 1,
|
|
387
|
+
["wallet-auth" /* WalletAuth */]: 1
|
|
388
|
+
};
|
|
327
389
|
_MiniKit.listeners = {
|
|
328
390
|
["miniapp-verify-action" /* MiniAppVerifyAction */]: () => {
|
|
329
391
|
},
|
|
@@ -341,7 +403,11 @@ _MiniKit.commands = {
|
|
|
341
403
|
verification_level: payload.verification_level || VerificationLevel.Orb,
|
|
342
404
|
timestamp
|
|
343
405
|
};
|
|
344
|
-
sendMiniKitEvent({
|
|
406
|
+
sendMiniKitEvent({
|
|
407
|
+
command: "verify" /* Verify */,
|
|
408
|
+
version: _MiniKit.commandVersion["verify" /* Verify */],
|
|
409
|
+
payload: eventPayload
|
|
410
|
+
});
|
|
345
411
|
return eventPayload;
|
|
346
412
|
},
|
|
347
413
|
pay: (payload) => {
|
|
@@ -362,6 +428,7 @@ _MiniKit.commands = {
|
|
|
362
428
|
};
|
|
363
429
|
sendMiniKitEvent({
|
|
364
430
|
command: "pay" /* Pay */,
|
|
431
|
+
version: _MiniKit.commandVersion["pay" /* Pay */],
|
|
365
432
|
payload: eventPayload
|
|
366
433
|
});
|
|
367
434
|
return eventPayload;
|
|
@@ -405,6 +472,7 @@ _MiniKit.commands = {
|
|
|
405
472
|
const walletAuthPayload = { siweMessage };
|
|
406
473
|
sendMiniKitEvent({
|
|
407
474
|
command: "wallet-auth" /* WalletAuth */,
|
|
475
|
+
version: _MiniKit.commandVersion["wallet-auth" /* WalletAuth */],
|
|
408
476
|
payload: walletAuthPayload
|
|
409
477
|
});
|
|
410
478
|
return walletAuthPayload;
|
|
@@ -431,9 +499,14 @@ var tokenToDecimals = (amount, token) => {
|
|
|
431
499
|
|
|
432
500
|
// index.ts
|
|
433
501
|
import { VerificationLevel as VerificationLevel2 } from "@worldcoin/idkit-core";
|
|
502
|
+
import {
|
|
503
|
+
verifyCloudProof
|
|
504
|
+
} from "@worldcoin/idkit-core/backend";
|
|
434
505
|
export {
|
|
435
506
|
Command,
|
|
436
507
|
MiniKit,
|
|
508
|
+
MiniKitInstallErrorCode,
|
|
509
|
+
MiniKitInstallErrorMessage,
|
|
437
510
|
Network,
|
|
438
511
|
PaymentErrorCodes,
|
|
439
512
|
PaymentErrorMessage,
|
|
@@ -449,5 +522,6 @@ export {
|
|
|
449
522
|
generateNonce,
|
|
450
523
|
parseSiweMessage,
|
|
451
524
|
tokenToDecimals,
|
|
525
|
+
verifyCloudProof,
|
|
452
526
|
verifySiweMessage
|
|
453
527
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worldcoin/minikit-js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22-internal-alpha",
|
|
4
4
|
"homepage": "https://docs.worldcoin.org/id/minikit",
|
|
5
5
|
"description": "Internal Alpha: Mini-kit JS is a lightweight sdk for building mini-apps compatible with World App",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
"miniapps"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@worldcoin/idkit-core": "^1.2.0"
|
|
29
|
-
"apg-js": "^4.4.0"
|
|
28
|
+
"@worldcoin/idkit-core": "^1.2.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@typescript-eslint/eslint-plugin": "^7.7.0",
|