@worldcoin/minikit-js 0.0.27-internal-alpha → 0.0.29-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";
@@ -121,79 +248,77 @@ type MiniAppWalletAuthErrorPayload = {
121
248
  version: number;
122
249
  };
123
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;
260
+ };
261
+ type MiniAppSendTransactionErrorPayload = {
262
+ status: "error";
263
+ error_code: SendTransactionErrorCodes;
264
+ version: number;
265
+ };
266
+ type MiniAppSendTransactionPayload = MiniAppSendTransactionSuccessPayload | MiniAppSendTransactionErrorPayload;
267
+ type MiniAppSignMessageSuccessPayload = {
268
+ status: "success";
269
+ signature: string;
270
+ address: string;
271
+ version: number;
272
+ };
273
+ type MiniAppSignMessageErrorPayload = {
274
+ status: "error";
275
+ error_code: SignMessageErrorCodes;
276
+ version: number;
277
+ };
278
+ type MiniAppSignMessagePayload = MiniAppSignMessageSuccessPayload | MiniAppSignMessageErrorPayload;
279
+ type MiniAppSignTypedDataSuccessPayload = {
280
+ status: "success";
281
+ signature: string;
282
+ address: string;
283
+ version: number;
284
+ };
285
+ type MiniAppSignTypedDataErrorPayload = {
286
+ status: "error";
287
+ error_code: SignTypedDataErrorCodes;
288
+ version: number;
289
+ };
290
+ type MiniAppSignTypedDataPayload = MiniAppSignTypedDataSuccessPayload | MiniAppSignTypedDataErrorPayload;
124
291
  type EventPayloadMap = {
125
292
  [ResponseEvent.MiniAppVerifyAction]: MiniAppVerifyActionPayload;
126
293
  [ResponseEvent.MiniAppPayment]: MiniAppPaymentPayload;
127
294
  [ResponseEvent.MiniAppWalletAuth]: MiniAppWalletAuthPayload;
295
+ [ResponseEvent.MiniAppSendTransaction]: MiniAppSendTransactionPayload;
296
+ [ResponseEvent.MiniAppSignMessage]: MiniAppSignMessagePayload;
297
+ [ResponseEvent.MiniAppSignTypedData]: MiniAppSignTypedDataPayload;
128
298
  };
129
299
  type EventPayload<T extends ResponseEvent = ResponseEvent> = T extends keyof EventPayloadMap ? EventPayloadMap[T] : never;
130
300
  type EventHandler<E extends ResponseEvent = ResponseEvent> = <T extends EventPayload<E>>(data: T) => void;
131
301
 
132
- declare const parseSiweMessage: (inputString: string) => SiweMessage;
133
- declare const SAFE_CONTRACT_ABI: {
134
- name: string;
135
- type: string;
136
- stateMutability: string;
137
- inputs: {
138
- name: string;
139
- type: string;
140
- }[];
141
- outputs: never[];
142
- }[];
143
- declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonce: string, statement?: string, requestId?: string, userProvider?: ethers.Provider) => Promise<{
144
- isValid: boolean;
145
- siweMessageData: SiweMessage;
146
- }>;
147
-
148
- declare enum Command {
149
- Verify = "verify",
150
- Pay = "pay",
151
- WalletAuth = "wallet-auth"
152
- }
153
- type VerifyCommandInput = {
154
- action: IDKitConfig["action"];
155
- signal?: IDKitConfig["signal"];
156
- verification_level?: VerificationLevel$1;
157
- };
158
- type TokensPayload = {
159
- symbol: Tokens;
160
- token_amount: string;
161
- };
162
- type PayCommandInput = {
163
- reference: string;
164
- to: string;
165
- tokens: TokensPayload[];
166
- network?: Network;
167
- description: string;
168
- };
169
- type WalletAuthInput = {
170
- nonce: string;
302
+ type SiweMessage = {
303
+ scheme?: string;
304
+ domain: string;
305
+ address?: string;
171
306
  statement?: string;
172
- requestId?: string;
173
- expirationTime?: Date;
174
- notBefore?: Date;
175
- };
176
- type VerifyCommandPayload = VerifyCommandInput & {
177
- timestamp: string;
178
- };
179
- type PayCommandPayload = PayCommandInput & {
180
- reference: string;
181
- };
182
- type WalletAuthPayload = {
183
- siweMessage: string;
184
- };
185
- type MiniKitInstallReturnType = {
186
- success: true;
187
- } | {
188
- success: false;
189
- errorCode: MiniKitInstallErrorCode;
190
- errorMessage: (typeof MiniKitInstallErrorMessage)[MiniKitInstallErrorCode];
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;
191
315
  };
192
316
 
193
317
  declare class MiniKit {
194
318
  private static readonly MINIKIT_VERSION;
195
319
  private static readonly commandVersion;
196
320
  private static listeners;
321
+ static walletAddress: string | null;
197
322
  private static sendInit;
198
323
  static subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
199
324
  static unsubscribe(event: ResponseEvent): void;
@@ -205,10 +330,28 @@ declare class MiniKit {
205
330
  verify: (payload: VerifyCommandInput) => VerifyCommandPayload;
206
331
  pay: (payload: PayCommandInput) => PayCommandPayload | null;
207
332
  walletAuth: (payload: WalletAuthInput) => WalletAuthPayload | null;
208
- closeWebview: () => void;
333
+ sendTransaction: (payload: SendTransactionInput) => SendTransactionPayload;
334
+ signMessage: (payload: SignMessageInput) => SignMessagePayload;
335
+ signTypedData: (payload: SignTypedDataInput) => SignTypedDataPayload;
209
336
  };
210
337
  }
211
338
 
212
339
  declare const tokenToDecimals: (amount: number, token: Tokens) => number;
213
340
 
214
- export { Command, type MiniAppPaymentErrorPayload, type MiniAppPaymentPayload, type MiniAppPaymentSuccessPayload, type MiniAppVerifyActionErrorPayload, type MiniAppVerifyActionPayload, type MiniAppVerifyActionSuccessPayload, type MiniAppWalletAuthErrorPayload, type MiniAppWalletAuthPayload, 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 };
341
+ declare const parseSiweMessage: (inputString: string) => SiweMessage;
342
+ declare const SAFE_CONTRACT_ABI: {
343
+ name: string;
344
+ type: string;
345
+ stateMutability: string;
346
+ inputs: {
347
+ name: string;
348
+ type: string;
349
+ }[];
350
+ outputs: never[];
351
+ }[];
352
+ declare const verifySiweMessage: (payload: MiniAppWalletAuthSuccessPayload, nonce: string, statement?: string, requestId?: string, userProvider?: Client) => Promise<{
353
+ isValid: boolean;
354
+ siweMessageData: SiweMessage;
355
+ }>;
356
+
357
+ 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 };