@cordystackx/cordy_minikit 3.0.4 → 3.0.6
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 +13 -15
- package/dist/client/jwt.d.ts +15 -15
- package/dist/client/jwt.d.ts.map +1 -1
- package/dist/client/jwt.js +65 -62
- package/dist/client.d.ts +2 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/config/Image.json +6 -6
- package/dist/controllers/StellarButton.d.ts.map +1 -1
- package/dist/controllers/StellarButton.js +3 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
1
|
<div align="center">
|
|
3
2
|
<img src="https://raw.githubusercontent.com/cordyStackX/cordy_minikit_official/21cb17b5569b79b29545da80da33d82625e26c7b/assets/cordy-logo.svg" alt="Cordy Minikit logo" width="160" />
|
|
4
3
|
<h1>Cordy Minikit</h1>
|
|
5
|
-
<p>Typed Web3 toolkit for EVM and Stellar/Soroban wallet connections, balances, transfers, and
|
|
4
|
+
<p>Typed Web3 toolkit for EVM and Stellar/Soroban wallet connections, balances, transfers, and wallet connection checks.</p>
|
|
6
5
|
</div>
|
|
7
6
|
|
|
8
7
|
<p align="center">
|
|
9
|
-
<a href="https://badge.socket.dev/npm/package/@cordystackx/cordy_minikit/3.0.
|
|
10
|
-
<img src="https://badge.socket.dev/npm/package/@cordystackx/cordy_minikit/3.0.
|
|
8
|
+
<a href="https://badge.socket.dev/npm/package/@cordystackx/cordy_minikit/3.0.5">
|
|
9
|
+
<img src="https://badge.socket.dev/npm/package/@cordystackx/cordy_minikit/3.0.5" alt="Socket Badge" />
|
|
11
10
|
</a>
|
|
12
11
|
</p>
|
|
13
12
|
|
|
@@ -37,42 +36,41 @@ npm install @cordystackx/cordy_minikit
|
|
|
37
36
|
pnpm add @cordystackx/cordy_minikit
|
|
38
37
|
```
|
|
39
38
|
|
|
40
|
-
## 3.0.
|
|
39
|
+
## 3.0.5 documentation
|
|
41
40
|
|
|
42
41
|
Read the complete documentation in the [`docs/` folder](./docs/README.md):
|
|
43
42
|
|
|
44
43
|
- [Documentation index](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/README.md)
|
|
45
44
|
- [Environment configuration](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/environment.md)
|
|
46
|
-
- [3.0.
|
|
45
|
+
- [3.0.5 API reference](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/api.md)
|
|
47
46
|
- [3.0.0 migration guide](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/migration-3.0.0.md)
|
|
48
47
|
- [Provider and wallet UI setup](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/setup.md)
|
|
49
|
-
- [Server session endpoint examples](https://github.com/cordyStackX/cordy_minikit_official/blob/main/docs/server-endpoints.md)
|
|
50
48
|
|
|
51
49
|
## Current API
|
|
52
50
|
|
|
53
51
|
```ts
|
|
54
52
|
import { cordy } from "@cordystackx/cordy_minikit";
|
|
55
53
|
|
|
56
|
-
const
|
|
54
|
+
const wallet = await cordy.cons_verify();
|
|
57
55
|
const balance = await cordy.balance();
|
|
58
56
|
const transfer = await cordy.transfer("1", recipient);
|
|
59
|
-
await cordy.
|
|
57
|
+
await cordy.cons_disconnect();
|
|
60
58
|
```
|
|
61
59
|
|
|
62
|
-
The current 3.0.
|
|
60
|
+
The current 3.0.5 API is:
|
|
63
61
|
|
|
64
62
|
- `cordy.configure({ assets })`
|
|
65
|
-
- `cordy.
|
|
66
|
-
- `cordy.
|
|
63
|
+
- `cordy.cons_verify()`
|
|
64
|
+
- `cordy.cons_disconnect()`
|
|
67
65
|
- `cordy.transfer()`
|
|
68
66
|
- `cordy.balance()`
|
|
69
67
|
- `cordy.swap(amount, from, to)`
|
|
70
68
|
|
|
71
|
-
|
|
69
|
+
`cordy.cons_verify()` checks whether an EVM or Stellar wallet is connected in the browser. It returns status `200` when connected and `401` when disconnected; it does not make an HTTP request or authenticate wallet ownership to your server. `cordy.cons_disconnect()` disconnects the wallet locally. Legacy controller helpers remain available for compatibility, but new integrations should use the `cordy.*` API.
|
|
72
70
|
|
|
73
71
|
## Experimental API
|
|
74
72
|
|
|
75
|
-
`cordy.bridge()` is experimental in 3.0.
|
|
73
|
+
`cordy.bridge()` is experimental in 3.0.5 and currently supports test USDT between BOT Chain Testnet and Ethereum Sepolia only. See the [bridge API example](./docs/api.md#cordybridgeamount-from-to-recipient).
|
|
76
74
|
|
|
77
75
|
`cordy.swap(amount, from, to, tolerancePercent?)` is available for configured EVM and Stellar assets. EVM networks need a Uniswap V2-compatible `swapRouterAddress`; native EVM swaps also need `wrappedNativeTokenAddress`. Stellar swaps use Horizon strict-send path payments and require a live liquidity path. The optional fourth argument is a percentage: `1` means 1% tolerance, and omission defaults to 1%.
|
|
78
76
|
|
|
@@ -82,4 +80,4 @@ Use `cordy.jwt_verify()` to check the app's session. Legacy controller helpers r
|
|
|
82
80
|
- [GitHub repository](https://github.com/cordyStackX/cordy_minikit_official)
|
|
83
81
|
- [Changelog](https://github.com/cordyStackX/cordy_minikit_official/blob/main/CHANGELOG.md)
|
|
84
82
|
- [Contributing guide](https://github.com/cordyStackX/cordy_minikit_official/blob/main/CONTRIBUTING.md)
|
|
85
|
-
- [Security policy](https://github.com/cordyStackX/cordy_minikit_official/blob/main/SECURITY.md)
|
|
83
|
+
- [Security policy](https://github.com/cordyStackX/cordy_minikit_official/blob/main/SECURITY.md)
|
package/dist/client/jwt.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { configureCordyAssets, cordy_balance, cordy_bridge, cordy_swap, cordy_transfer } from "./transfer";
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export type ConsVerifyResult = {
|
|
3
|
+
/** Application-level status; no HTTP request is made. */
|
|
4
|
+
status: 200 | 401;
|
|
5
|
+
connected: boolean;
|
|
6
|
+
network?: "evm" | "stellar";
|
|
7
|
+
address?: string;
|
|
5
8
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export type JwtDisconnectResult = {
|
|
9
|
+
/** @deprecated Use JwtVerifyResult; this describes wallet state, not a JWT session. */
|
|
10
|
+
export type ConsSessionResult = ConsVerifyResult;
|
|
11
|
+
export type ConsDisconnectResult = {
|
|
11
12
|
success: boolean;
|
|
12
13
|
walletDisconnected: boolean;
|
|
13
|
-
status?: number;
|
|
14
14
|
error?: string;
|
|
15
15
|
};
|
|
16
|
-
/**
|
|
17
|
-
export declare function
|
|
18
|
-
/**
|
|
19
|
-
export declare function
|
|
16
|
+
/** Check whether this browser currently has a connected EVM or Stellar wallet. */
|
|
17
|
+
export declare function cons_verify(): Promise<ConsVerifyResult>;
|
|
18
|
+
/** Disconnect the connected EVM wallet and clear the Minikit Stellar wallet selection. */
|
|
19
|
+
export declare function cons_disconnect(): Promise<ConsDisconnectResult>;
|
|
20
20
|
export declare const cordy: {
|
|
21
21
|
configure: typeof configureCordyAssets;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
cons_verify: typeof cons_verify;
|
|
23
|
+
cons_disconnect: typeof cons_disconnect;
|
|
24
24
|
balance: typeof cordy_balance;
|
|
25
25
|
transfer: typeof cordy_transfer;
|
|
26
26
|
swap: typeof cordy_swap;
|
package/dist/client/jwt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../client/jwt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE3G,MAAM,MAAM,gBAAgB,GAAG;IAC7B,
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../client/jwt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE3G,MAAM,MAAM,gBAAgB,GAAG;IAC7B,yDAAyD;IACzD,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,uFAAuF;AACvF,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAEjD,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAkBF,kFAAkF;AAClF,wBAAsB,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAgC7D;AAED,0FAA0F;AAC1F,wBAAsB,eAAe,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAyBrE;AAED,eAAO,MAAM,KAAK;;;;;;;;CAQjB,CAAC"}
|
package/dist/client/jwt.js
CHANGED
|
@@ -1,79 +1,82 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { configureCordyAssets, cordy_balance, cordy_bridge, cordy_swap, cordy_transfer } from "./transfer";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new Error(`Session check failed (${response.status})`);
|
|
3
|
+
const STELLAR_WALLET_STORAGE_KEY = "cordy_minikit_stellar_wallet";
|
|
4
|
+
const ACTIVE_WALLET_SESSION_KEY = "cordy_minikit_active_wallet_session";
|
|
5
|
+
function getStellarAddress() {
|
|
6
|
+
try {
|
|
7
|
+
const raw = window.localStorage.getItem(STELLAR_WALLET_STORAGE_KEY);
|
|
8
|
+
if (!raw)
|
|
9
|
+
return undefined;
|
|
10
|
+
const wallet = JSON.parse(raw);
|
|
11
|
+
if (typeof wallet !== "object" || wallet === null || !("address" in wallet))
|
|
12
|
+
return undefined;
|
|
13
|
+
const address = wallet.address;
|
|
14
|
+
return typeof address === "string" && address.length > 0 ? address : undefined;
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return { ...data, authenticated: true };
|
|
16
|
+
catch {
|
|
17
|
+
return undefined;
|
|
20
18
|
}
|
|
21
|
-
return { authenticated: true };
|
|
22
19
|
}
|
|
23
|
-
/**
|
|
24
|
-
export async function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let errorMessage;
|
|
28
|
-
try {
|
|
29
|
-
const response = await fetch(options.endpoint ?? "/api/auth/logout", {
|
|
30
|
-
method: "POST",
|
|
31
|
-
credentials: "include",
|
|
32
|
-
cache: "no-store",
|
|
33
|
-
headers: { Accept: "application/json" },
|
|
34
|
-
});
|
|
35
|
-
status = response.status;
|
|
36
|
-
// A missing or expired session is already logged out.
|
|
37
|
-
sessionCleared = response.ok || response.status === 401;
|
|
38
|
-
if (!sessionCleared)
|
|
39
|
-
errorMessage = `Session logout failed (${response.status})`;
|
|
20
|
+
/** Check whether this browser currently has a connected EVM or Stellar wallet. */
|
|
21
|
+
export async function cons_verify() {
|
|
22
|
+
if (typeof window === "undefined") {
|
|
23
|
+
return { status: 401, connected: false };
|
|
40
24
|
}
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
const stellarAddress = getStellarAddress();
|
|
26
|
+
const activeWallet = window.localStorage.getItem(ACTIVE_WALLET_SESSION_KEY);
|
|
27
|
+
if (activeWallet === "stellar" && stellarAddress) {
|
|
28
|
+
return { status: 200, connected: true, network: "stellar", address: stellarAddress };
|
|
43
29
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
window.localStorage.removeItem("cordy_minikit_stellar_wallet");
|
|
55
|
-
window.localStorage.removeItem("cordy_minikit_active_wallet_session");
|
|
56
|
-
window.dispatchEvent(new Event("cordy:disconnect-stellar-wallet"));
|
|
57
|
-
walletDisconnected = true;
|
|
30
|
+
try {
|
|
31
|
+
const { getActiveWagmiConfig } = await import("../config/walletConfig");
|
|
32
|
+
const state = getActiveWagmiConfig().state;
|
|
33
|
+
const currentConnection = state.current ? state.connections.get(state.current) : undefined;
|
|
34
|
+
const connection = currentConnection?.accounts[0]
|
|
35
|
+
? currentConnection
|
|
36
|
+
: Array.from(state.connections.values()).find((item) => item.accounts[0]);
|
|
37
|
+
const address = connection?.accounts[0];
|
|
38
|
+
if (address) {
|
|
39
|
+
return { status: 200, connected: true, network: "evm", address };
|
|
58
40
|
}
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// A missing or unavailable EVM connector does not prevent checking Stellar.
|
|
44
|
+
}
|
|
45
|
+
if (stellarAddress) {
|
|
46
|
+
return { status: 200, connected: true, network: "stellar", address: stellarAddress };
|
|
47
|
+
}
|
|
48
|
+
return { status: 401, connected: false };
|
|
49
|
+
}
|
|
50
|
+
/** Disconnect the connected EVM wallet and clear the Minikit Stellar wallet selection. */
|
|
51
|
+
export async function cons_disconnect() {
|
|
52
|
+
if (typeof window === "undefined") {
|
|
53
|
+
return { success: false, walletDisconnected: false, error: "Wallet disconnect is only available in the browser." };
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const { disconnect } = await import("wagmi/actions");
|
|
57
|
+
const { getActiveWagmiConfig } = await import("../config/walletConfig");
|
|
58
|
+
const config = getActiveWagmiConfig();
|
|
59
|
+
const connections = Array.from(config.state.connections.values());
|
|
60
|
+
for (const connection of connections) {
|
|
61
|
+
await disconnect(config, { connector: connection.connector });
|
|
61
62
|
}
|
|
63
|
+
window.localStorage.removeItem(STELLAR_WALLET_STORAGE_KEY);
|
|
64
|
+
window.localStorage.removeItem(ACTIVE_WALLET_SESSION_KEY);
|
|
65
|
+
window.dispatchEvent(new Event("cordy:disconnect-stellar-wallet"));
|
|
66
|
+
return { success: true, walletDisconnected: true };
|
|
62
67
|
}
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
catch (error) {
|
|
69
|
+
return {
|
|
70
|
+
success: false,
|
|
71
|
+
walletDisconnected: false,
|
|
72
|
+
error: error instanceof Error ? error.message : "Wallet disconnect failed.",
|
|
73
|
+
};
|
|
65
74
|
}
|
|
66
|
-
return {
|
|
67
|
-
success: sessionCleared && walletDisconnected,
|
|
68
|
-
walletDisconnected,
|
|
69
|
-
status,
|
|
70
|
-
...(errorMessage ? { error: errorMessage } : {}),
|
|
71
|
-
};
|
|
72
75
|
}
|
|
73
76
|
export const cordy = {
|
|
74
77
|
configure: configureCordyAssets,
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
cons_verify,
|
|
79
|
+
cons_disconnect,
|
|
77
80
|
balance: cordy_balance,
|
|
78
81
|
transfer: cordy_transfer,
|
|
79
82
|
swap: cordy_swap,
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { cordy,
|
|
2
|
-
export type {
|
|
1
|
+
export { cordy, cons_verify, cons_disconnect } from "./client/jwt";
|
|
2
|
+
export type { ConsDisconnectResult, ConsSessionResult, ConsVerifyResult } from "./client/jwt";
|
|
3
3
|
export { configureCordyAssets, cordy_configure, cordy_bridge, cordy_swap, cordy_transfer } from "./client/transfer";
|
|
4
4
|
export type { CordyAssetsConfig, CordyBridgeResult, CordyBridgeSide, CordyTransferOptions, CordyTransferResult, CordySwapResult, EvmAssetConfig, EvmNetworkConfig, StellarAssetConfig } from "./client/transfer";
|
|
5
5
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE9F,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpH,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { cordy,
|
|
1
|
+
export { cordy, cons_verify, cons_disconnect } from "./client/jwt";
|
|
2
2
|
export { configureCordyAssets, cordy_configure, cordy_bridge, cordy_swap, cordy_transfer } from "./client/transfer";
|