@worldcoin/minikit-js 0.0.26-internal-alpha → 0.0.28-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.d.cts CHANGED
@@ -1,34 +1,8 @@
1
- import { ethers } from 'ethers';
2
- import { AppErrorCodes, VerificationLevel } from '@worldcoin/idkit-core';
1
+ import { AppErrorCodes, IDKitConfig, VerificationLevel } from '@worldcoin/idkit-core';
3
2
  export { ISuccessResult, AppErrorCodes as VerificationErrorCodes, VerificationLevel } from '@worldcoin/idkit-core';
4
- import { IDKitConfig, VerificationLevel as VerificationLevel$1 } from '@worldcoin/idkit-core/*';
3
+ import { Abi, AbiStateMutability, ExtractAbiFunctionNames, AbiParametersToPrimitiveTypes, ExtractAbiFunction, TypedData, TypedDataDomain } from 'abitype';
5
4
  export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
6
-
7
- type SiweMessage = {
8
- scheme?: string;
9
- domain: string;
10
- address?: string;
11
- statement?: string;
12
- uri: string;
13
- version: number;
14
- chain_id: number;
15
- nonce: string;
16
- issued_at: string;
17
- expiration_time?: string;
18
- not_before?: string;
19
- request_id?: string;
20
- };
21
-
22
- declare enum Tokens {
23
- USDCE = "USDCE",
24
- WLD = "WLD"
25
- }
26
- declare const TokenDecimals: {
27
- [key in Tokens]: number;
28
- };
29
- declare enum Network {
30
- Optimism = "optimism"
31
- }
5
+ import { Client } from 'viem';
32
6
 
33
7
  declare const VerificationErrorMessage: Record<AppErrorCodes, string>;
34
8
  declare enum PaymentErrorCodes {
@@ -57,7 +31,60 @@ declare const WalletAuthErrorMessage: {
57
31
  user_rejected: string;
58
32
  generic_error: string;
59
33
  };
60
- declare enum MiniKitInstallErrorCode {
34
+ declare enum SendTransactionErrorCodes {
35
+ InvalidOperation = "invalid_operation",
36
+ UserRejected = "user_rejected",
37
+ InputError = "input_error",
38
+ SimulationFailed = "simulation_failed",
39
+ TransactionFailed = "transaction_failed",
40
+ GenericError = "generic_error",
41
+ DisallowedOperation = "disallowed_operation",
42
+ InvalidContract = "invalid_contract",
43
+ MaliciousOperation = "malicious_operation"
44
+ }
45
+ declare const SendTransactionErrorMessage: {
46
+ invalid_operation: string;
47
+ user_rejected: string;
48
+ input_error: string;
49
+ simulation_failed: string;
50
+ transaction_failed: string;
51
+ generic_error: string;
52
+ disallowed_operation: string;
53
+ invalid_contract: string;
54
+ malicious_operation: string;
55
+ };
56
+ declare enum SignMessageErrorCodes {
57
+ InvalidMessage = "invalid_message",
58
+ UserRejected = "user_rejected",
59
+ GenericError = "generic_error"
60
+ }
61
+ declare const SignMessageErrorMessage: {
62
+ invalid_message: string;
63
+ user_rejected: string;
64
+ generic_error: string;
65
+ };
66
+ declare enum SignTypedDataErrorCodes {
67
+ InvalidOperation = "invalid_operation",
68
+ UserRejected = "user_rejected",
69
+ InputError = "input_error",
70
+ SimulationFailed = "simulation_failed",
71
+ GenericError = "generic_error",
72
+ DisallowedOperation = "disallowed_operation",
73
+ InvalidContract = "invalid_contract",
74
+ MaliciousOperation = "malicious_operation"
75
+ }
76
+ declare const SignTypedDataErrorMessage: {
77
+ invalid_operation: string;
78
+ user_rejected: string;
79
+ input_error: string;
80
+ simulation_failed: string;
81
+ transaction_failed: string;
82
+ generic_error: string;
83
+ disallowed_operation: string;
84
+ invalid_contract: string;
85
+ malicious_operation: string;
86
+ };
87
+ declare enum MiniKitInstallErrorCodes {
61
88
  Unknown = "unknown",
62
89
  AlreadyInstalled = "already_installed",
63
90
  OutsideOfWorldApp = "outside_of_worldapp",
@@ -72,10 +99,110 @@ declare const MiniKitInstallErrorMessage: {
72
99
  app_out_of_date: string;
73
100
  };
74
101
 
102
+ declare enum Tokens {
103
+ USDCE = "USDCE",
104
+ WLD = "WLD"
105
+ }
106
+ declare const TokenDecimals: {
107
+ [key in Tokens]: number;
108
+ };
109
+ declare enum Network {
110
+ Optimism = "optimism",
111
+ WorldChain = "worldchain"
112
+ }
113
+
114
+ type Permit2 = {
115
+ permitted: {
116
+ token: string;
117
+ amount: string | unknown;
118
+ };
119
+ spender: string;
120
+ nonce: string | unknown;
121
+ deadline: string | unknown;
122
+ };
123
+ type Transaction = {
124
+ address: string;
125
+ abi: Abi | readonly unknown[];
126
+ functionName: ContractFunctionName<Abi | readonly unknown[], "payable" | "nonpayable">;
127
+ args: ContractFunctionArgs<Abi | readonly unknown[], "payable" | "nonpayable", ContractFunctionName<Abi | readonly unknown[], "payable" | "nonpayable">>;
128
+ };
129
+ type ContractFunctionName<abi extends Abi | readonly unknown[] = Abi, mutability extends AbiStateMutability = AbiStateMutability> = ExtractAbiFunctionNames<abi extends Abi ? abi : Abi, mutability> extends infer functionName extends string ? [functionName] extends [never] ? string : functionName : string;
130
+ type ContractFunctionArgs<abi extends Abi | readonly unknown[] = Abi, mutability extends AbiStateMutability = AbiStateMutability, functionName extends ContractFunctionName<abi, mutability> = ContractFunctionName<abi, mutability>> = AbiParametersToPrimitiveTypes<ExtractAbiFunction<abi extends Abi ? abi : Abi, functionName, mutability>["inputs"], "inputs"> extends infer args ? [args] extends [never] ? readonly unknown[] : args : readonly unknown[];
131
+
132
+ declare enum Command {
133
+ Verify = "verify",
134
+ Pay = "pay",
135
+ WalletAuth = "wallet-auth",
136
+ SendTransaction = "send-transaction",
137
+ SignMessage = "sign-message",
138
+ SignTypedData = "sign-typed-data"
139
+ }
140
+ type WebViewBasePayload = {
141
+ command: Command;
142
+ version: number;
143
+ payload: Record<string, any>;
144
+ };
145
+ type VerifyCommandInput = {
146
+ action: IDKitConfig["action"];
147
+ signal?: IDKitConfig["signal"];
148
+ verification_level?: VerificationLevel;
149
+ };
150
+ type VerifyCommandPayload = VerifyCommandInput & {
151
+ timestamp: string;
152
+ };
153
+ type TokensPayload = {
154
+ symbol: Tokens;
155
+ token_amount: string;
156
+ };
157
+ type PayCommandInput = {
158
+ reference: string;
159
+ to: string;
160
+ tokens: TokensPayload[];
161
+ network?: Network;
162
+ description: string;
163
+ };
164
+ type PayCommandPayload = PayCommandInput;
165
+ type WalletAuthInput = {
166
+ nonce: string;
167
+ statement?: string;
168
+ requestId?: string;
169
+ expirationTime?: Date;
170
+ notBefore?: Date;
171
+ };
172
+ type WalletAuthPayload = {
173
+ siweMessage: string;
174
+ };
175
+ type MiniKitInstallReturnType = {
176
+ success: true;
177
+ } | {
178
+ success: false;
179
+ errorCode: MiniKitInstallErrorCodes;
180
+ errorMessage: (typeof MiniKitInstallErrorMessage)[MiniKitInstallErrorCodes];
181
+ };
182
+ type SendTransactionInput = {
183
+ transaction: Transaction[];
184
+ permit2?: Permit2[];
185
+ };
186
+ type SendTransactionPayload = SendTransactionInput;
187
+ type SignMessageInput = {
188
+ message: string;
189
+ };
190
+ type SignMessagePayload = SignMessageInput;
191
+ type SignTypedDataInput = {
192
+ types: TypedData;
193
+ primaryType: string;
194
+ message: Record<string, unknown>;
195
+ domain?: TypedDataDomain;
196
+ };
197
+ type SignTypedDataPayload = SignTypedDataInput;
198
+
75
199
  declare enum ResponseEvent {
76
200
  MiniAppVerifyAction = "miniapp-verify-action",
77
201
  MiniAppPayment = "miniapp-payment",
78
- MiniAppWalletAuth = "miniapp-wallet-auth"
202
+ MiniAppWalletAuth = "miniapp-wallet-auth",
203
+ MiniAppSendTransaction = "miniapp-send-transaction",
204
+ MiniAppSignMessage = "miniapp-sign-message",
205
+ MiniAppSignTypedData = "miniapp-sign-typed-data"
79
206
  }
80
207
  type MiniAppVerifyActionSuccessPayload = {
81
208
  status: "success";
@@ -91,7 +218,7 @@ type MiniAppVerifyActionErrorPayload = {
91
218
  version: number;
92
219
  };
93
220
  type MiniAppVerifyActionPayload = MiniAppVerifyActionSuccessPayload | MiniAppVerifyActionErrorPayload;
94
- type MiniAppPaymentSuccessEventPayload = {
221
+ type MiniAppPaymentSuccessPayload = {
95
222
  status: "success";
96
223
  transaction_status: "submitted";
97
224
  transaction_id: string;
@@ -106,7 +233,7 @@ type MiniAppPaymentErrorPayload = {
106
233
  error_code: PaymentErrorCodes;
107
234
  version: number;
108
235
  };
109
- type MiniAppPaymentPayload = MiniAppPaymentSuccessEventPayload | MiniAppPaymentErrorPayload;
236
+ type MiniAppPaymentPayload = MiniAppPaymentSuccessPayload | MiniAppPaymentErrorPayload;
110
237
  type MiniAppWalletAuthSuccessPayload = {
111
238
  status: "success";
112
239
  message: string;
@@ -120,68 +247,71 @@ type MiniAppWalletAuthErrorPayload = {
120
247
  details: (typeof WalletAuthErrorMessage)[WalletAuthErrorCodes];
121
248
  version: number;
122
249
  };
123
- type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends ResponseEvent.MiniAppVerifyAction ? MiniAppVerifyActionPayload : MiniAppPaymentPayload;
124
- type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
125
-
126
- declare const parseSiweMessage: (inputString: string) => SiweMessage;
127
- declare const SAFE_CONTRACT_ABI: {
128
- name: string;
129
- type: string;
130
- stateMutability: string;
131
- inputs: {
132
- name: string;
133
- type: string;
134
- }[];
135
- outputs: never[];
136
- }[];
137
- declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonce: string, statement?: string, requestId?: string, userProvider?: ethers.Provider) => Promise<{
138
- isValid: boolean;
139
- siweMessageData: SiweMessage;
140
- }>;
141
-
142
- declare enum Command {
143
- Verify = "verify",
144
- Pay = "pay",
145
- WalletAuth = "wallet-auth"
146
- }
147
- type VerifyCommandInput = {
148
- action: IDKitConfig["action"];
149
- signal?: IDKitConfig["signal"];
150
- verification_level?: VerificationLevel$1;
250
+ type MiniAppWalletAuthPayload = MiniAppWalletAuthSuccessPayload | MiniAppWalletAuthErrorPayload;
251
+ type MiniAppSendTransactionSuccessPayload = {
252
+ status: "success";
253
+ transaction_status: "submitted";
254
+ transaction_id: string;
255
+ reference: string;
256
+ from: string;
257
+ chain: Network;
258
+ timestamp: string;
259
+ version: number;
151
260
  };
152
- type TokensPayload = {
153
- symbol: Tokens;
154
- token_amount: string;
261
+ type MiniAppSendTransactionErrorPayload = {
262
+ status: "error";
263
+ error_code: SendTransactionErrorCodes;
264
+ version: number;
155
265
  };
156
- type PayCommandInput = {
157
- reference: string;
158
- to: string;
159
- tokens: TokensPayload[];
160
- network?: Network;
161
- description: string;
266
+ type MiniAppSendTransactionPayload = MiniAppSendTransactionSuccessPayload | MiniAppSendTransactionErrorPayload;
267
+ type MiniAppSignMessageSuccessPayload = {
268
+ status: "success";
269
+ signature: string;
270
+ address: string;
271
+ version: number;
162
272
  };
163
- type WalletAuthInput = {
164
- nonce: string;
165
- statement?: string;
166
- requestId?: string;
167
- expirationTime?: Date;
168
- notBefore?: Date;
273
+ type MiniAppSignMessageErrorPayload = {
274
+ status: "error";
275
+ error_code: SignMessageErrorCodes;
276
+ version: number;
169
277
  };
170
- type VerifyCommandPayload = VerifyCommandInput & {
171
- timestamp: string;
278
+ type MiniAppSignMessagePayload = MiniAppSignMessageSuccessPayload | MiniAppSignMessageErrorPayload;
279
+ type MiniAppSignTypedDataSuccessPayload = {
280
+ status: "success";
281
+ signature: string;
282
+ address: string;
283
+ version: number;
172
284
  };
173
- type PayCommandPayload = PayCommandInput & {
174
- reference: string;
285
+ type MiniAppSignTypedDataErrorPayload = {
286
+ status: "error";
287
+ error_code: SignTypedDataErrorCodes;
288
+ version: number;
175
289
  };
176
- type WalletAuthPayload = {
177
- siweMessage: string;
290
+ type MiniAppSignTypedDataPayload = MiniAppSignTypedDataSuccessPayload | MiniAppSignTypedDataErrorPayload;
291
+ type EventPayloadMap = {
292
+ [ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
293
+ [ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
294
+ [ResponseEvent.MiniAppWalletAuth]: MiniAppWalletAuthPayload;
295
+ [ResponseEvent.MiniAppSendTransaction]: MiniAppSendTransactionPayload;
296
+ [ResponseEvent.MiniAppSignMessage]: MiniAppSignMessagePayload;
297
+ [ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
178
298
  };
179
- type MiniKitInstallReturnType = {
180
- success: true;
181
- } | {
182
- success: false;
183
- errorCode: MiniKitInstallErrorCode;
184
- errorMessage: (typeof MiniKitInstallErrorMessage)[MiniKitInstallErrorCode];
299
+ type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
300
+ type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
301
+
302
+ type SiweMessage = {
303
+ scheme?: string;
304
+ domain: string;
305
+ address?: string;
306
+ statement?: string;
307
+ uri: string;
308
+ version: number;
309
+ chain_id: number;
310
+ nonce: string;
311
+ issued_at: string;
312
+ expiration_time?: string;
313
+ not_before?: string;
314
+ request_id?: string;
185
315
  };
186
316
 
187
317
  declare class MiniKit {
@@ -199,10 +329,28 @@ declare class MiniKit {
199
329
  verify: (payload: VerifyCommandInput) => VerifyCommandPayload;
200
330
  pay: (payload: PayCommandInput) => PayCommandPayload | null;
201
331
  walletAuth: (payload: WalletAuthInput) => WalletAuthPayload | null;
202
- closeWebview: () => void;
332
+ sendTransaction: (payload: SendTransactionInput) => SendTransactionPayload;
333
+ signMessage: (payload: SignMessageInput) => SignMessagePayload;
334
+ signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload;
203
335
  };
204
336
  }
205
337
 
206
338
  declare const tokenToDecimals: (amount: number, token: Tokens) => number;
207
339
 
208
- 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, PaymentValidationErrors, ResponseEvent, SAFE_CONTRACT_ABI, type SiweMessage, TokenDecimals, Tokens, VerificationErrorMessage, type VerifyCommandInput, WalletAuthErrorCodes, WalletAuthErrorMessage, parseSiweMessage, tokenToDecimals, verifySiweMessage };
340
+ declare const parseSiweMessage: (inputString: string) => SiweMessage;
341
+ declare const SAFE_CONTRACT_ABI: {
342
+ name: string;
343
+ type: string;
344
+ stateMutability: string;
345
+ inputs: {
346
+ name: string;
347
+ type: string;
348
+ }[];
349
+ outputs: never[];
350
+ }[];
351
+ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonce: string, statement?: string, requestId?: string, userProvider?: Client) => Promise<{
352
+ isValid: boolean;
353
+ siweMessageData: SiweMessage;
354
+ }>;
355
+
356
+ export { Command, type EventHandler, type EventPayload, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppSendTransactionErrorPayload, type MiniAppSendTransactionPayload, type MiniAppSendTransactionSuccessPayload, type MiniAppSignMessageErrorPayload, type MiniAppSignMessagePayload, type MiniAppSignMessageSuccessPayload, type MiniAppSignTypedDataErrorPayload, type MiniAppSignTypedDataPayload, type MiniAppSignTypedDataSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, type MiniAppWalletAuthSuccessPayload, MiniKit, MiniKitInstallErrorCodes, MiniKitInstallErrorMessage, type MiniKitInstallReturnType, Network, type PayCommandInput, type PayCommandPayload, PaymentErrorCodes, PaymentErrorMessage, PaymentValidationErrors, ResponseEvent, SAFE_CONTRACT_ABI, SendTransactionErrorCodes, SendTransactionErrorMessage, type SendTransactionInput, type SendTransactionPayload, SignMessageErrorCodes, SignMessageErrorMessage, type SignMessageInput, type SignMessagePayload, SignTypedDataErrorCodes, SignTypedDataErrorMessage, type SignTypedDataInput, type SignTypedDataPayload, type SiweMessage, TokenDecimals, Tokens, type TokensPayload, VerificationErrorMessage, type VerifyCommandInput, type VerifyCommandPayload, WalletAuthErrorCodes, WalletAuthErrorMessage, type WalletAuthInput, type WalletAuthPayload, type WebViewBasePayload, parseSiweMessage, tokenToDecimals, verifySiweMessage };