@worldcoin/minikit-js 1.9.10 → 2.0.0-dev.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/README.md +104 -0
- package/build/address-book.cjs +81 -0
- package/build/address-book.d.cts +3 -0
- package/build/address-book.d.ts +3 -0
- package/build/address-book.js +54 -0
- package/build/chunk-DIACPBCB.js +1692 -0
- package/build/chunk-LHHKY77D.js +274 -0
- package/build/chunk-OTAA7OOI.js +835 -0
- package/build/command-exports.cjs +1825 -0
- package/build/command-exports.d.cts +102 -0
- package/build/command-exports.d.ts +102 -0
- package/build/command-exports.js +121 -0
- package/build/connector/index.cjs +2388 -0
- package/build/connector/index.d.cts +55 -0
- package/build/connector/index.d.ts +55 -0
- package/build/connector/index.js +86 -0
- package/build/index.cjs +1696 -1480
- package/build/index.d.cts +136 -622
- package/build/index.d.ts +136 -622
- package/build/index.js +5 -196
- package/build/minikit-provider.cjs +1465 -834
- package/build/minikit-provider.d.cts +2 -1
- package/build/minikit-provider.d.ts +2 -1
- package/build/minikit-provider.js +2046 -4
- package/build/provider-DeDUsLbs.d.cts +43 -0
- package/build/provider-DeDUsLbs.d.ts +43 -0
- package/build/siwe-exports.cjs +249 -0
- package/build/siwe-exports.d.cts +10 -0
- package/build/siwe-exports.d.ts +10 -0
- package/build/siwe-exports.js +8 -0
- package/build/types-CGVVuGiN.d.ts +438 -0
- package/build/types-CKn5C-Ro.d.cts +220 -0
- package/build/types-CKn5C-Ro.d.ts +220 -0
- package/build/types-DO2UGrgp.d.cts +438 -0
- package/package.json +81 -18
- package/build/chunk-XFGJKKI2.js +0 -1951
- package/index.ts +0 -29
package/README.md
CHANGED
|
@@ -10,6 +10,110 @@ or use the CDN:
|
|
|
10
10
|
|
|
11
11
|
For comprehensive setup instructions and usage examples, visit our [developer documentation](https://docs.world.org/mini-apps).
|
|
12
12
|
|
|
13
|
+
## Scope
|
|
14
|
+
|
|
15
|
+
`@worldcoin/minikit-js` is the mini-app command SDK:
|
|
16
|
+
|
|
17
|
+
- `MiniKit.walletAuth()`
|
|
18
|
+
- `MiniKit.sendTransaction()`
|
|
19
|
+
- `MiniKit.pay()`
|
|
20
|
+
- `MiniKit.shareContacts()`
|
|
21
|
+
- `MiniKit.signMessage()`
|
|
22
|
+
- `MiniKit.signTypedData()`
|
|
23
|
+
- and related mini-app commands
|
|
24
|
+
|
|
25
|
+
World ID verification belongs to IDKit:
|
|
26
|
+
|
|
27
|
+
- Use `@worldcoin/idkit` for verification requests and widget UI
|
|
28
|
+
- Use `@worldcoin/idkit-core` for backend signing helpers such as `signRequest`
|
|
29
|
+
|
|
30
|
+
## v2 -> v3 Migration Highlights
|
|
31
|
+
|
|
32
|
+
- `MiniKit.commands.*` / `MiniKit.commandsAsync.*` are removed. Use `await MiniKit.<command>(...)`.
|
|
33
|
+
- Command responses now use `{ executedWith, data }`.
|
|
34
|
+
- Verify flows moved to IDKit (`@worldcoin/idkit`), not MiniKit.
|
|
35
|
+
- `walletAuth` nonce validation is stricter (alphanumeric SIWE nonce).
|
|
36
|
+
- Tree-shakeable subpath exports are available for commands and helpers.
|
|
37
|
+
|
|
38
|
+
### `sendTransaction` uses one flexible transaction type
|
|
39
|
+
|
|
40
|
+
When `transaction[i].data` is provided, MiniKit prioritizes raw calldata over
|
|
41
|
+
`abi` / `functionName` / `args`.
|
|
42
|
+
|
|
43
|
+
Example:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
await MiniKit.sendTransaction({
|
|
47
|
+
transaction: [
|
|
48
|
+
{
|
|
49
|
+
address: tokenAddress,
|
|
50
|
+
data: '0xa9059cbb...', // takes priority when present
|
|
51
|
+
abi: erc20Abi,
|
|
52
|
+
functionName: 'transfer',
|
|
53
|
+
args: [to, amount],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Type shape:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
type Transaction = {
|
|
63
|
+
address: string;
|
|
64
|
+
value?: string;
|
|
65
|
+
data?: string;
|
|
66
|
+
abi?: Abi | readonly unknown[];
|
|
67
|
+
functionName?: ContractFunctionName<...>;
|
|
68
|
+
args?: ContractFunctionArgs<...>;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
interface MiniKitSendTransactionOptions<TCustomFallback = SendTransactionResult> {
|
|
72
|
+
transaction: Transaction[];
|
|
73
|
+
chainId?: number; // defaults to 480 on World App
|
|
74
|
+
permit2?: Permit2[];
|
|
75
|
+
formatPayload?: boolean;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Tree-shakeable subpath exports
|
|
80
|
+
|
|
81
|
+
Use subpaths to import only what you need:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import {
|
|
85
|
+
MiniKitSendTransactionOptions,
|
|
86
|
+
SendTransactionErrorCodes,
|
|
87
|
+
} from '@worldcoin/minikit-js/commands';
|
|
88
|
+
import { getIsUserVerified } from '@worldcoin/minikit-js/address-book';
|
|
89
|
+
import { parseSiweMessage, verifySiweMessage } from '@worldcoin/minikit-js/siwe';
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
You can still import `MiniKit` itself from the package root:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { MiniKit } from '@worldcoin/minikit-js';
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Commands now support custom fallbacks
|
|
99
|
+
|
|
100
|
+
Use `fallback` to run equivalent logic outside World App:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const result = await MiniKit.sendHapticFeedback({
|
|
104
|
+
hapticsType: 'impact',
|
|
105
|
+
style: 'light',
|
|
106
|
+
fallback: () => {
|
|
107
|
+
navigator.vibrate?.(20);
|
|
108
|
+
return {
|
|
109
|
+
status: 'success',
|
|
110
|
+
version: 1,
|
|
111
|
+
timestamp: new Date().toISOString(),
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
13
117
|
## 🛠 ️Developing Locally
|
|
14
118
|
|
|
15
119
|
To run the example mini app locally:
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/address-book.ts
|
|
21
|
+
var address_book_exports = {};
|
|
22
|
+
__export(address_book_exports, {
|
|
23
|
+
getIsUserVerified: () => getIsUserVerified
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(address_book_exports);
|
|
26
|
+
|
|
27
|
+
// src/helpers/address-book.ts
|
|
28
|
+
var import_viem = require("viem");
|
|
29
|
+
var import_chains = require("viem/chains");
|
|
30
|
+
var worldIdAddressBookContractAddress = "0x57b930D551e677CC36e2fA036Ae2fe8FdaE0330D";
|
|
31
|
+
var addressVerifiedUntilAbi = [
|
|
32
|
+
{
|
|
33
|
+
inputs: [
|
|
34
|
+
{
|
|
35
|
+
internalType: "address",
|
|
36
|
+
name: "",
|
|
37
|
+
type: "address"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
name: "addressVerifiedUntil",
|
|
41
|
+
outputs: [
|
|
42
|
+
{
|
|
43
|
+
internalType: "uint256",
|
|
44
|
+
name: "",
|
|
45
|
+
type: "uint256"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
stateMutability: "view",
|
|
49
|
+
type: "function"
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
53
|
+
const publicClient = (0, import_viem.createPublicClient)({
|
|
54
|
+
chain: import_chains.worldchain,
|
|
55
|
+
transport: (0, import_viem.http)(
|
|
56
|
+
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
57
|
+
)
|
|
58
|
+
});
|
|
59
|
+
try {
|
|
60
|
+
const verifiedUntilResponse = await publicClient.readContract({
|
|
61
|
+
address: worldIdAddressBookContractAddress,
|
|
62
|
+
abi: addressVerifiedUntilAbi,
|
|
63
|
+
functionName: "addressVerifiedUntil",
|
|
64
|
+
args: [walletAddress]
|
|
65
|
+
});
|
|
66
|
+
const verifiedUntil = Number(verifiedUntilResponse.toString());
|
|
67
|
+
if (!Number.isFinite(verifiedUntil)) {
|
|
68
|
+
console.warn("Invalid verifiedUntil value:", verifiedUntil);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const currentTime = Math.floor(Date.now() / 1e3);
|
|
72
|
+
return verifiedUntil > currentTime;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error("Error verifying user:", error);
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
getIsUserVerified
|
|
81
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/helpers/address-book.ts
|
|
2
|
+
import { createPublicClient, http } from "viem";
|
|
3
|
+
import { worldchain } from "viem/chains";
|
|
4
|
+
var worldIdAddressBookContractAddress = "0x57b930D551e677CC36e2fA036Ae2fe8FdaE0330D";
|
|
5
|
+
var addressVerifiedUntilAbi = [
|
|
6
|
+
{
|
|
7
|
+
inputs: [
|
|
8
|
+
{
|
|
9
|
+
internalType: "address",
|
|
10
|
+
name: "",
|
|
11
|
+
type: "address"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
name: "addressVerifiedUntil",
|
|
15
|
+
outputs: [
|
|
16
|
+
{
|
|
17
|
+
internalType: "uint256",
|
|
18
|
+
name: "",
|
|
19
|
+
type: "uint256"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
stateMutability: "view",
|
|
23
|
+
type: "function"
|
|
24
|
+
}
|
|
25
|
+
];
|
|
26
|
+
var getIsUserVerified = async (walletAddress, rpcUrl) => {
|
|
27
|
+
const publicClient = createPublicClient({
|
|
28
|
+
chain: worldchain,
|
|
29
|
+
transport: http(
|
|
30
|
+
rpcUrl || "https://worldchain-mainnet.g.alchemy.com/public"
|
|
31
|
+
)
|
|
32
|
+
});
|
|
33
|
+
try {
|
|
34
|
+
const verifiedUntilResponse = await publicClient.readContract({
|
|
35
|
+
address: worldIdAddressBookContractAddress,
|
|
36
|
+
abi: addressVerifiedUntilAbi,
|
|
37
|
+
functionName: "addressVerifiedUntil",
|
|
38
|
+
args: [walletAddress]
|
|
39
|
+
});
|
|
40
|
+
const verifiedUntil = Number(verifiedUntilResponse.toString());
|
|
41
|
+
if (!Number.isFinite(verifiedUntil)) {
|
|
42
|
+
console.warn("Invalid verifiedUntil value:", verifiedUntil);
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const currentTime = Math.floor(Date.now() / 1e3);
|
|
46
|
+
return verifiedUntil > currentTime;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error("Error verifying user:", error);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
getIsUserVerified
|
|
54
|
+
};
|