@worldcoin/minikit-js 1.11.0 → 2.0.0-dev.1

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.
Files changed (39) hide show
  1. package/README.md +107 -0
  2. package/build/address-book.cjs +81 -0
  3. package/build/address-book.d.cts +3 -0
  4. package/build/address-book.d.ts +3 -0
  5. package/build/address-book.js +54 -0
  6. package/build/chunk-2UPJKPQ6.js +272 -0
  7. package/build/chunk-EHBM7OXH.js +596 -0
  8. package/build/chunk-LHHKY77D.js +274 -0
  9. package/build/chunk-TGXD24YD.js +279 -0
  10. package/build/chunk-Z2UGRZJ2.js +1635 -0
  11. package/build/command-exports.cjs +1762 -0
  12. package/build/command-exports.d.cts +105 -0
  13. package/build/command-exports.d.ts +105 -0
  14. package/build/command-exports.js +129 -0
  15. package/build/connector/index.cjs +2601 -0
  16. package/build/connector/index.d.cts +55 -0
  17. package/build/connector/index.d.ts +55 -0
  18. package/build/connector/index.js +90 -0
  19. package/build/index.cjs +1634 -1627
  20. package/build/index.d.cts +143 -671
  21. package/build/index.d.ts +143 -671
  22. package/build/index.js +7 -206
  23. package/build/minikit-provider.cjs +1650 -948
  24. package/build/minikit-provider.d.cts +2 -1
  25. package/build/minikit-provider.d.ts +2 -1
  26. package/build/minikit-provider.js +13 -2
  27. package/build/provider-DeDUsLbs.d.cts +43 -0
  28. package/build/provider-DeDUsLbs.d.ts +43 -0
  29. package/build/siwe-exports.cjs +249 -0
  30. package/build/siwe-exports.d.cts +10 -0
  31. package/build/siwe-exports.d.ts +10 -0
  32. package/build/siwe-exports.js +8 -0
  33. package/build/types-CC2x79HX.d.ts +525 -0
  34. package/build/types-CSyzFDPt.d.cts +223 -0
  35. package/build/types-CSyzFDPt.d.ts +223 -0
  36. package/build/types-_jfLbcJW.d.cts +525 -0
  37. package/package.json +73 -11
  38. package/build/chunk-62NZ34E4.js +0 -2092
  39. package/index.ts +0 -29
@@ -0,0 +1,223 @@
1
+ type EventPayload = any;
2
+ type EventHandler<E extends ResponseEvent = ResponseEvent> = (data: EventPayload) => void;
3
+ declare class EventManager {
4
+ private listeners;
5
+ subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
6
+ unsubscribe(event: ResponseEvent): void;
7
+ trigger(event: ResponseEvent, payload: EventPayload): void;
8
+ }
9
+
10
+ type User = {
11
+ walletAddress?: string;
12
+ username?: string;
13
+ profilePictureUrl?: string;
14
+ permissions?: {
15
+ notifications: boolean;
16
+ contacts: boolean;
17
+ };
18
+ optedIntoOptionalAnalytics?: boolean;
19
+ };
20
+ type DeviceProperties = {
21
+ safeAreaInsets?: {
22
+ top: number;
23
+ right: number;
24
+ bottom: number;
25
+ left: number;
26
+ };
27
+ deviceOS?: string;
28
+ worldAppVersion?: number;
29
+ };
30
+ type UserNameService = {
31
+ walletAddress: string;
32
+ username?: string;
33
+ profilePictureUrl?: string;
34
+ };
35
+ type MiniAppLocation = {
36
+ countryCode?: string;
37
+ regionCode?: string;
38
+ };
39
+ declare enum MiniAppLaunchLocation {
40
+ Chat = "chat",
41
+ Home = "home",
42
+ AppStore = "app-store",
43
+ DeepLink = "deep-link",
44
+ WalletTab = "wallet-tab"
45
+ }
46
+ declare enum MiniKitInstallErrorCodes {
47
+ Unknown = "unknown",
48
+ AlreadyInstalled = "already_installed",
49
+ OutsideOfWorldApp = "outside_of_worldapp",
50
+ NotOnClient = "not_on_client",
51
+ AppOutOfDate = "app_out_of_date"
52
+ }
53
+ declare const MiniKitInstallErrorMessage: {
54
+ unknown: string;
55
+ already_installed: string;
56
+ outside_of_worldapp: string;
57
+ not_on_client: string;
58
+ app_out_of_date: string;
59
+ };
60
+ type MiniKitInstallReturnType = {
61
+ success: true;
62
+ } | {
63
+ success: false;
64
+ errorCode: MiniKitInstallErrorCodes;
65
+ errorMessage: (typeof MiniKitInstallErrorMessage)[MiniKitInstallErrorCodes];
66
+ };
67
+
68
+ declare enum Command {
69
+ Attestation = "attestation",
70
+ Pay = "pay",
71
+ WalletAuth = "wallet-auth",
72
+ SendTransaction = "send-transaction",
73
+ SignMessage = "sign-message",
74
+ SignTypedData = "sign-typed-data",
75
+ ShareContacts = "share-contacts",
76
+ RequestPermission = "request-permission",
77
+ GetPermissions = "get-permissions",
78
+ SendHapticFeedback = "send-haptic-feedback",
79
+ Share = "share",
80
+ Chat = "chat",
81
+ CloseMiniApp = "close-miniapp"
82
+ }
83
+ declare enum ResponseEvent {
84
+ MiniAppAttestation = "miniapp-attestation",
85
+ MiniAppPayment = "miniapp-payment",
86
+ MiniAppWalletAuth = "miniapp-wallet-auth",
87
+ MiniAppSendTransaction = "miniapp-send-transaction",
88
+ MiniAppSignMessage = "miniapp-sign-message",
89
+ MiniAppSignTypedData = "miniapp-sign-typed-data",
90
+ MiniAppShareContacts = "miniapp-share-contacts",
91
+ MiniAppRequestPermission = "miniapp-request-permission",
92
+ MiniAppGetPermissions = "miniapp-get-permissions",
93
+ MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
94
+ MiniAppShare = "miniapp-share",
95
+ MiniAppMicrophone = "miniapp-microphone",
96
+ MiniAppChat = "miniapp-chat"
97
+ }
98
+ declare const COMMAND_VERSIONS: Record<Command, number>;
99
+ declare function isCommandAvailable(command: Command | string): boolean;
100
+ declare function setCommandAvailable(command: Command, available: boolean): void;
101
+ declare function validateCommands(worldAppSupportedCommands: NonNullable<typeof window.WorldApp>['supported_commands']): boolean;
102
+ interface CommandState {
103
+ deviceProperties: DeviceProperties;
104
+ }
105
+ interface CommandContext {
106
+ events: EventManager;
107
+ state: CommandState;
108
+ }
109
+ type WebViewBasePayload = {
110
+ command: Command;
111
+ version: number;
112
+ payload: Record<string, any>;
113
+ };
114
+ declare function sendMiniKitEvent<T extends Record<string, any>>(payload: T): void;
115
+ type MiniAppBaseSuccessPayload = {
116
+ status: 'success';
117
+ version: number;
118
+ };
119
+ type MiniAppBaseErrorPayload<TErrorCode = string> = {
120
+ status: 'error';
121
+ error_code: TErrorCode;
122
+ version: number;
123
+ };
124
+ declare function isInWorldApp(): boolean;
125
+ type CommandVia = 'minikit' | 'wagmi' | 'fallback';
126
+ interface CommandResult<T> {
127
+ data: T;
128
+ executedWith: CommandVia;
129
+ }
130
+ type CommandResultByVia<TNative, TFallback = TNative, TViaNative extends CommandVia = Exclude<CommandVia, 'fallback'>> = {
131
+ executedWith: TViaNative;
132
+ data: TNative;
133
+ } | {
134
+ executedWith: 'fallback';
135
+ data: TFallback;
136
+ };
137
+ interface FallbackConfig<TFallback = unknown> {
138
+ /**
139
+ * Optional custom fallback executor.
140
+ * The fallback return type can differ from the native/Wagmi success payload.
141
+ */
142
+ fallback?: () => Promise<TFallback> | TFallback;
143
+ }
144
+ type FallbackReason = 'notInWorldApp' | 'commandNotSupported' | 'oldAppVersion';
145
+ declare class FallbackRequiredError extends Error {
146
+ constructor(command: string);
147
+ }
148
+ declare class CommandUnavailableError extends Error {
149
+ readonly reason: FallbackReason;
150
+ constructor(command: string, reason: FallbackReason);
151
+ }
152
+
153
+ /** @deprecated Use {@link MiniKitWalletAuthOptions} instead */
154
+ type WalletAuthInput = {
155
+ nonce: string;
156
+ statement?: string;
157
+ requestId?: string;
158
+ expirationTime?: Date;
159
+ notBefore?: Date;
160
+ };
161
+ type WalletAuthPayload = {
162
+ siweMessage: string;
163
+ };
164
+ declare enum WalletAuthErrorCodes {
165
+ MalformedRequest = "malformed_request",
166
+ UserRejected = "user_rejected",
167
+ GenericError = "generic_error"
168
+ }
169
+ declare const WalletAuthErrorMessage: {
170
+ malformed_request: string;
171
+ user_rejected: string;
172
+ generic_error: string;
173
+ };
174
+ type MiniAppWalletAuthSuccessPayload = MiniAppBaseSuccessPayload & {
175
+ message: string;
176
+ signature: string;
177
+ address: string;
178
+ };
179
+ type MiniAppWalletAuthErrorPayload = MiniAppBaseErrorPayload<WalletAuthErrorCodes> & {
180
+ details: (typeof WalletAuthErrorMessage)[WalletAuthErrorCodes];
181
+ };
182
+ type MiniAppWalletAuthPayload = MiniAppWalletAuthSuccessPayload | MiniAppWalletAuthErrorPayload;
183
+ interface MiniKitWalletAuthOptions<TCustomFallback = WalletAuthResult> extends FallbackConfig<TCustomFallback> {
184
+ /** Nonce for SIWE message (alphanumeric, at least 8 chars) */
185
+ nonce: string;
186
+ /** Optional statement to include in SIWE message */
187
+ statement?: string;
188
+ /** Optional request ID for tracking */
189
+ requestId?: string;
190
+ /** Optional expiration time for the SIWE message */
191
+ expirationTime?: Date;
192
+ /** Optional not-before time for the SIWE message */
193
+ notBefore?: Date;
194
+ }
195
+ interface WalletAuthResult {
196
+ /** Wallet address */
197
+ address: string;
198
+ /** Signed SIWE message */
199
+ message: string;
200
+ /** Signature */
201
+ signature: string;
202
+ }
203
+ type SiweMessage = {
204
+ scheme?: string;
205
+ domain: string;
206
+ address?: string;
207
+ statement?: string;
208
+ uri: string;
209
+ version: string;
210
+ chain_id: number;
211
+ nonce: string;
212
+ issued_at: string;
213
+ expiration_time?: string;
214
+ not_before?: string;
215
+ request_id?: string;
216
+ };
217
+ declare class WalletAuthError extends Error {
218
+ readonly code: string;
219
+ readonly details?: string;
220
+ constructor(code: string, details?: string);
221
+ }
222
+
223
+ export { type MiniAppWalletAuthPayload as A, WalletAuthError as B, type CommandResultByVia as C, type DeviceProperties as D, type MiniAppLocation as E, type FallbackConfig as F, MiniKitInstallErrorCodes as G, MiniKitInstallErrorMessage as H, type MiniKitWalletAuthOptions as M, ResponseEvent as R, type SiweMessage as S, type User as U, type WalletAuthResult as W, MiniAppLaunchLocation as a, type MiniKitInstallReturnType as b, type UserNameService as c, type CommandContext as d, Command as e, COMMAND_VERSIONS as f, isCommandAvailable as g, type CommandState as h, isInWorldApp as i, type WebViewBasePayload as j, sendMiniKitEvent as k, type MiniAppBaseSuccessPayload as l, type MiniAppBaseErrorPayload as m, type CommandVia as n, type CommandResult as o, type FallbackReason as p, FallbackRequiredError as q, CommandUnavailableError as r, setCommandAvailable as s, type WalletAuthInput as t, type WalletAuthPayload as u, validateCommands as v, WalletAuthErrorCodes as w, WalletAuthErrorMessage as x, type MiniAppWalletAuthSuccessPayload as y, type MiniAppWalletAuthErrorPayload as z };
@@ -0,0 +1,223 @@
1
+ type EventPayload = any;
2
+ type EventHandler<E extends ResponseEvent = ResponseEvent> = (data: EventPayload) => void;
3
+ declare class EventManager {
4
+ private listeners;
5
+ subscribe<E extends ResponseEvent>(event: E, handler: EventHandler<E>): void;
6
+ unsubscribe(event: ResponseEvent): void;
7
+ trigger(event: ResponseEvent, payload: EventPayload): void;
8
+ }
9
+
10
+ type User = {
11
+ walletAddress?: string;
12
+ username?: string;
13
+ profilePictureUrl?: string;
14
+ permissions?: {
15
+ notifications: boolean;
16
+ contacts: boolean;
17
+ };
18
+ optedIntoOptionalAnalytics?: boolean;
19
+ };
20
+ type DeviceProperties = {
21
+ safeAreaInsets?: {
22
+ top: number;
23
+ right: number;
24
+ bottom: number;
25
+ left: number;
26
+ };
27
+ deviceOS?: string;
28
+ worldAppVersion?: number;
29
+ };
30
+ type UserNameService = {
31
+ walletAddress: string;
32
+ username?: string;
33
+ profilePictureUrl?: string;
34
+ };
35
+ type MiniAppLocation = {
36
+ countryCode?: string;
37
+ regionCode?: string;
38
+ };
39
+ declare enum MiniAppLaunchLocation {
40
+ Chat = "chat",
41
+ Home = "home",
42
+ AppStore = "app-store",
43
+ DeepLink = "deep-link",
44
+ WalletTab = "wallet-tab"
45
+ }
46
+ declare enum MiniKitInstallErrorCodes {
47
+ Unknown = "unknown",
48
+ AlreadyInstalled = "already_installed",
49
+ OutsideOfWorldApp = "outside_of_worldapp",
50
+ NotOnClient = "not_on_client",
51
+ AppOutOfDate = "app_out_of_date"
52
+ }
53
+ declare const MiniKitInstallErrorMessage: {
54
+ unknown: string;
55
+ already_installed: string;
56
+ outside_of_worldapp: string;
57
+ not_on_client: string;
58
+ app_out_of_date: string;
59
+ };
60
+ type MiniKitInstallReturnType = {
61
+ success: true;
62
+ } | {
63
+ success: false;
64
+ errorCode: MiniKitInstallErrorCodes;
65
+ errorMessage: (typeof MiniKitInstallErrorMessage)[MiniKitInstallErrorCodes];
66
+ };
67
+
68
+ declare enum Command {
69
+ Attestation = "attestation",
70
+ Pay = "pay",
71
+ WalletAuth = "wallet-auth",
72
+ SendTransaction = "send-transaction",
73
+ SignMessage = "sign-message",
74
+ SignTypedData = "sign-typed-data",
75
+ ShareContacts = "share-contacts",
76
+ RequestPermission = "request-permission",
77
+ GetPermissions = "get-permissions",
78
+ SendHapticFeedback = "send-haptic-feedback",
79
+ Share = "share",
80
+ Chat = "chat",
81
+ CloseMiniApp = "close-miniapp"
82
+ }
83
+ declare enum ResponseEvent {
84
+ MiniAppAttestation = "miniapp-attestation",
85
+ MiniAppPayment = "miniapp-payment",
86
+ MiniAppWalletAuth = "miniapp-wallet-auth",
87
+ MiniAppSendTransaction = "miniapp-send-transaction",
88
+ MiniAppSignMessage = "miniapp-sign-message",
89
+ MiniAppSignTypedData = "miniapp-sign-typed-data",
90
+ MiniAppShareContacts = "miniapp-share-contacts",
91
+ MiniAppRequestPermission = "miniapp-request-permission",
92
+ MiniAppGetPermissions = "miniapp-get-permissions",
93
+ MiniAppSendHapticFeedback = "miniapp-send-haptic-feedback",
94
+ MiniAppShare = "miniapp-share",
95
+ MiniAppMicrophone = "miniapp-microphone",
96
+ MiniAppChat = "miniapp-chat"
97
+ }
98
+ declare const COMMAND_VERSIONS: Record<Command, number>;
99
+ declare function isCommandAvailable(command: Command | string): boolean;
100
+ declare function setCommandAvailable(command: Command, available: boolean): void;
101
+ declare function validateCommands(worldAppSupportedCommands: NonNullable<typeof window.WorldApp>['supported_commands']): boolean;
102
+ interface CommandState {
103
+ deviceProperties: DeviceProperties;
104
+ }
105
+ interface CommandContext {
106
+ events: EventManager;
107
+ state: CommandState;
108
+ }
109
+ type WebViewBasePayload = {
110
+ command: Command;
111
+ version: number;
112
+ payload: Record<string, any>;
113
+ };
114
+ declare function sendMiniKitEvent<T extends Record<string, any>>(payload: T): void;
115
+ type MiniAppBaseSuccessPayload = {
116
+ status: 'success';
117
+ version: number;
118
+ };
119
+ type MiniAppBaseErrorPayload<TErrorCode = string> = {
120
+ status: 'error';
121
+ error_code: TErrorCode;
122
+ version: number;
123
+ };
124
+ declare function isInWorldApp(): boolean;
125
+ type CommandVia = 'minikit' | 'wagmi' | 'fallback';
126
+ interface CommandResult<T> {
127
+ data: T;
128
+ executedWith: CommandVia;
129
+ }
130
+ type CommandResultByVia<TNative, TFallback = TNative, TViaNative extends CommandVia = Exclude<CommandVia, 'fallback'>> = {
131
+ executedWith: TViaNative;
132
+ data: TNative;
133
+ } | {
134
+ executedWith: 'fallback';
135
+ data: TFallback;
136
+ };
137
+ interface FallbackConfig<TFallback = unknown> {
138
+ /**
139
+ * Optional custom fallback executor.
140
+ * The fallback return type can differ from the native/Wagmi success payload.
141
+ */
142
+ fallback?: () => Promise<TFallback> | TFallback;
143
+ }
144
+ type FallbackReason = 'notInWorldApp' | 'commandNotSupported' | 'oldAppVersion';
145
+ declare class FallbackRequiredError extends Error {
146
+ constructor(command: string);
147
+ }
148
+ declare class CommandUnavailableError extends Error {
149
+ readonly reason: FallbackReason;
150
+ constructor(command: string, reason: FallbackReason);
151
+ }
152
+
153
+ /** @deprecated Use {@link MiniKitWalletAuthOptions} instead */
154
+ type WalletAuthInput = {
155
+ nonce: string;
156
+ statement?: string;
157
+ requestId?: string;
158
+ expirationTime?: Date;
159
+ notBefore?: Date;
160
+ };
161
+ type WalletAuthPayload = {
162
+ siweMessage: string;
163
+ };
164
+ declare enum WalletAuthErrorCodes {
165
+ MalformedRequest = "malformed_request",
166
+ UserRejected = "user_rejected",
167
+ GenericError = "generic_error"
168
+ }
169
+ declare const WalletAuthErrorMessage: {
170
+ malformed_request: string;
171
+ user_rejected: string;
172
+ generic_error: string;
173
+ };
174
+ type MiniAppWalletAuthSuccessPayload = MiniAppBaseSuccessPayload & {
175
+ message: string;
176
+ signature: string;
177
+ address: string;
178
+ };
179
+ type MiniAppWalletAuthErrorPayload = MiniAppBaseErrorPayload<WalletAuthErrorCodes> & {
180
+ details: (typeof WalletAuthErrorMessage)[WalletAuthErrorCodes];
181
+ };
182
+ type MiniAppWalletAuthPayload = MiniAppWalletAuthSuccessPayload | MiniAppWalletAuthErrorPayload;
183
+ interface MiniKitWalletAuthOptions<TCustomFallback = WalletAuthResult> extends FallbackConfig<TCustomFallback> {
184
+ /** Nonce for SIWE message (alphanumeric, at least 8 chars) */
185
+ nonce: string;
186
+ /** Optional statement to include in SIWE message */
187
+ statement?: string;
188
+ /** Optional request ID for tracking */
189
+ requestId?: string;
190
+ /** Optional expiration time for the SIWE message */
191
+ expirationTime?: Date;
192
+ /** Optional not-before time for the SIWE message */
193
+ notBefore?: Date;
194
+ }
195
+ interface WalletAuthResult {
196
+ /** Wallet address */
197
+ address: string;
198
+ /** Signed SIWE message */
199
+ message: string;
200
+ /** Signature */
201
+ signature: string;
202
+ }
203
+ type SiweMessage = {
204
+ scheme?: string;
205
+ domain: string;
206
+ address?: string;
207
+ statement?: string;
208
+ uri: string;
209
+ version: string;
210
+ chain_id: number;
211
+ nonce: string;
212
+ issued_at: string;
213
+ expiration_time?: string;
214
+ not_before?: string;
215
+ request_id?: string;
216
+ };
217
+ declare class WalletAuthError extends Error {
218
+ readonly code: string;
219
+ readonly details?: string;
220
+ constructor(code: string, details?: string);
221
+ }
222
+
223
+ export { type MiniAppWalletAuthPayload as A, WalletAuthError as B, type CommandResultByVia as C, type DeviceProperties as D, type MiniAppLocation as E, type FallbackConfig as F, MiniKitInstallErrorCodes as G, MiniKitInstallErrorMessage as H, type MiniKitWalletAuthOptions as M, ResponseEvent as R, type SiweMessage as S, type User as U, type WalletAuthResult as W, MiniAppLaunchLocation as a, type MiniKitInstallReturnType as b, type UserNameService as c, type CommandContext as d, Command as e, COMMAND_VERSIONS as f, isCommandAvailable as g, type CommandState as h, isInWorldApp as i, type WebViewBasePayload as j, sendMiniKitEvent as k, type MiniAppBaseSuccessPayload as l, type MiniAppBaseErrorPayload as m, type CommandVia as n, type CommandResult as o, type FallbackReason as p, FallbackRequiredError as q, CommandUnavailableError as r, setCommandAvailable as s, type WalletAuthInput as t, type WalletAuthPayload as u, validateCommands as v, WalletAuthErrorCodes as w, WalletAuthErrorMessage as x, type MiniAppWalletAuthSuccessPayload as y, type MiniAppWalletAuthErrorPayload as z };