@boundlessfi/identity-sdk 0.1.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.
- package/dist/boundless-sdk.d.ts +69 -0
- package/dist/boundless-sdk.d.ts.map +1 -0
- package/dist/boundless-sdk.js +373 -0
- package/dist/boundless-sdk.js.map +1 -0
- package/dist/constants.d.ts +32 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +31 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors.d.ts +9 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +16 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/stellar-plugin.d.ts +3 -0
- package/dist/server/stellar-plugin.d.ts.map +1 -0
- package/dist/server/stellar-plugin.js +51 -0
- package/dist/server/stellar-plugin.js.map +1 -0
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +20 -0
- package/dist/utils.js.map +1 -0
- package/package.json +35 -0
- package/src/boundless-sdk.ts +483 -0
- package/src/constants.ts +37 -0
- package/src/errors.ts +18 -0
- package/src/index.ts +17 -0
- package/src/server/index.ts +1 -0
- package/src/server/stellar-plugin.ts +66 -0
- package/src/types.ts +75 -0
- package/src/utils.ts +21 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { SmartAccountKit } from "smart-account-kit";
|
|
2
|
+
import type { AssembledTransaction } from "smart-account-kit";
|
|
3
|
+
import type { BoundlessSdkConfig, ConnectOptions, ConnectResult, SignAndSubmitResult, AddRecoveryKeyOptions, RecoveryKeyResult, BoundlessEventName, BoundlessEventHandler } from "./types";
|
|
4
|
+
export declare class BoundlessSDK {
|
|
5
|
+
private config;
|
|
6
|
+
private kit;
|
|
7
|
+
private _walletAddress;
|
|
8
|
+
private authClient;
|
|
9
|
+
constructor(config: BoundlessSdkConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Access the underlying SmartAccountKit instance for advanced usage.
|
|
12
|
+
*/
|
|
13
|
+
get smartAccountKit(): SmartAccountKit;
|
|
14
|
+
/**
|
|
15
|
+
* Connect to an existing passkey wallet.
|
|
16
|
+
* If prompt is true, forces the browser passkey selection UI.
|
|
17
|
+
* Does NOT deploy a new wallet.
|
|
18
|
+
*/
|
|
19
|
+
connect(options?: ConnectOptions): Promise<ConnectResult | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new wallet + credential for a user.
|
|
22
|
+
* Triggers browser passkey prompt.
|
|
23
|
+
* Links to the active Better-Auth session.
|
|
24
|
+
*/
|
|
25
|
+
register(userName: string): Promise<ConnectResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Link a Stellar wallet address to the currently authenticated user session.
|
|
28
|
+
*/
|
|
29
|
+
private linkToSession;
|
|
30
|
+
/**
|
|
31
|
+
* Sign and submit a transaction.
|
|
32
|
+
* Delegates to SmartAccountKit (which handles relayer if configured).
|
|
33
|
+
*/
|
|
34
|
+
signAndSubmit(transaction: AssembledTransaction<any>): Promise<SignAndSubmitResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Fetch the balance of the connected wallet (or any specific address).
|
|
37
|
+
* By default, fetches native XLM balance.
|
|
38
|
+
* If assetCode (and issuer) is provided, fetches that asset's balance.
|
|
39
|
+
* If assetCode starts with 'C', it is treated as a contract ID.
|
|
40
|
+
*/
|
|
41
|
+
getBalance(address: string, assetCode?: string, assetIssuer?: string): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Transfer funds (XLM or Token).
|
|
44
|
+
* Automatically resolves Asset-to-Contract if needed.
|
|
45
|
+
*/
|
|
46
|
+
transfer(to: string, amount: string | number, assetCode?: string, assetIssuer?: string): Promise<SignAndSubmitResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Disconnect the wallet (clear local session).
|
|
49
|
+
* Does NOT sign out of Better-Auth.
|
|
50
|
+
*/
|
|
51
|
+
disconnect(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the connected wallet address synchronously.
|
|
54
|
+
*/
|
|
55
|
+
getWalletAddress(): string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Add a recovery key (new passkey) to the existing account.
|
|
58
|
+
*/
|
|
59
|
+
addRecoveryKey(options: AddRecoveryKeyOptions): Promise<RecoveryKeyResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Remove a credential by ID.
|
|
62
|
+
*/
|
|
63
|
+
removeCredential(credentialId: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribe to events.
|
|
66
|
+
*/
|
|
67
|
+
onEvent(event: BoundlessEventName, handler: BoundlessEventHandler): () => void;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=boundless-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundless-sdk.d.ts","sourceRoot":"","sources":["../src/boundless-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAIhB,MAAM,mBAAmB,CAAC;AAW3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAM9D,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAKjB,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,GAAG,CAAkB;IAC7B,OAAO,CAAC,cAAc,CAAuB;IAE7C,OAAO,CAAC,UAAU,CAAM;gBAEZ,MAAM,EAAE,kBAAkB;IAmCtC;;OAEG;IACH,IAAI,eAAe,IAAI,eAAe,CAErC;IAED;;;;OAIG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAsCtE;;;;OAIG;IACG,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAmBxD;;OAEG;YACW,aAAa;IAkC3B;;;OAGG;IACG,aAAa,CACjB,WAAW,EAAE,oBAAoB,CAAC,GAAG,CAAC,GACrC,OAAO,CAAC,mBAAmB,CAAC;IAQ/B;;;;;OAKG;IACG,UAAU,CACd,OAAO,EAAE,MAAM,EACf,SAAS,SAAQ,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC;IAuGlB;;;OAGG;IACG,QAAQ,CACZ,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,SAAS,SAAQ,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,mBAAmB,CAAC;IAgC/B;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC;;OAEG;IACH,gBAAgB,IAAI,MAAM,GAAG,IAAI;IA6CjC;;OAEG;IACG,cAAc,CAClB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAkB7B;;OAEG;IACG,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW3D;;OAEG;IACH,OAAO,CACL,KAAK,EAAE,kBAAkB,EACzB,OAAO,EAAE,qBAAqB,GAC7B,MAAM,IAAI;CAyBd"}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { SmartAccountKit, WalletNotConnectedError, STROOPS_PER_XLM, } from "smart-account-kit";
|
|
2
|
+
import { rpc, Asset, Address, Contract, Account, TransactionBuilder, scValToNative, TimeoutInfinite, } from "@stellar/stellar-sdk";
|
|
3
|
+
import { createAuthClient } from "better-auth/client";
|
|
4
|
+
import { inferAdditionalFields } from "better-auth/client/plugins";
|
|
5
|
+
import { NETWORK_CONFIGS } from "./constants";
|
|
6
|
+
import { BoundlessAuthError, BoundlessLinkError } from "./errors";
|
|
7
|
+
// Valid G-address for simulation source (USDC Issuer)
|
|
8
|
+
const DUMMY_SOURCE = "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5";
|
|
9
|
+
export class BoundlessSDK {
|
|
10
|
+
config;
|
|
11
|
+
kit;
|
|
12
|
+
_walletAddress = null;
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
authClient; // typed via createAuthClient return
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
// 1. Resolve network config
|
|
18
|
+
const networkConfig = NETWORK_CONFIGS[config.network];
|
|
19
|
+
const rpcUrl = config.rpcUrl || networkConfig.defaultRpcUrl;
|
|
20
|
+
// 2. Initialize SmartAccountKit
|
|
21
|
+
this.kit = new SmartAccountKit({
|
|
22
|
+
rpcUrl,
|
|
23
|
+
networkPassphrase: networkConfig.networkPassphrase,
|
|
24
|
+
accountWasmHash: networkConfig.accountWasmHash,
|
|
25
|
+
webauthnVerifierAddress: networkConfig.webauthnVerifierAddress,
|
|
26
|
+
rpId: config.rpId,
|
|
27
|
+
rpName: config.rpName,
|
|
28
|
+
storage: config.storage, // optional
|
|
29
|
+
relayerUrl: config.relayerProxyUrl, // optional
|
|
30
|
+
});
|
|
31
|
+
// 3. Create Better-Auth client
|
|
32
|
+
// We cannot do `typeof auth` inference across packages easily without importing backend code.
|
|
33
|
+
// inferAdditionalFields is the standard polyrepo pattern.
|
|
34
|
+
this.authClient = createAuthClient({
|
|
35
|
+
baseURL: config.backendUrl,
|
|
36
|
+
plugins: [
|
|
37
|
+
inferAdditionalFields({
|
|
38
|
+
user: {
|
|
39
|
+
stellarAddress: { type: "string" },
|
|
40
|
+
credentialId: { type: "string" },
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Access the underlying SmartAccountKit instance for advanced usage.
|
|
48
|
+
*/
|
|
49
|
+
get smartAccountKit() {
|
|
50
|
+
return this.kit;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Connect to an existing passkey wallet.
|
|
54
|
+
* If prompt is true, forces the browser passkey selection UI.
|
|
55
|
+
* Does NOT deploy a new wallet.
|
|
56
|
+
*/
|
|
57
|
+
async connect(options) {
|
|
58
|
+
const prompt = options?.prompt === true;
|
|
59
|
+
// 1. Silent restore first (default behavior of connectWallet without args)
|
|
60
|
+
// If prompt is true, we skip silent restore if we want to force UI,
|
|
61
|
+
// but smart-account-kit connectWallet handles 'prompt: true' by forcing it.
|
|
62
|
+
// However, the spec says:
|
|
63
|
+
// "Call kit.connectWallet() ← silent restore"
|
|
64
|
+
// "If result → return mapped... "
|
|
65
|
+
// "If null AND options?.prompt === true → call kit.connectWallet({ prompt: true })"
|
|
66
|
+
let result = await this.kit.connectWallet();
|
|
67
|
+
if (result) {
|
|
68
|
+
this._walletAddress = result.contractId;
|
|
69
|
+
return {
|
|
70
|
+
walletAddress: result.contractId,
|
|
71
|
+
credentialId: result.credentialId || "",
|
|
72
|
+
isNew: false,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (prompt) {
|
|
76
|
+
result = await this.kit.connectWallet({ prompt: true });
|
|
77
|
+
if (result) {
|
|
78
|
+
this._walletAddress = result.contractId;
|
|
79
|
+
return {
|
|
80
|
+
walletAddress: result.contractId,
|
|
81
|
+
credentialId: result.credentialId || "",
|
|
82
|
+
isNew: false,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// "If null AND prompt is falsy → return null."
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create a new wallet + credential for a user.
|
|
91
|
+
* Triggers browser passkey prompt.
|
|
92
|
+
* Links to the active Better-Auth session.
|
|
93
|
+
*/
|
|
94
|
+
async register(userName) {
|
|
95
|
+
// 1. Create wallet (deploys on-chain + persists credential)
|
|
96
|
+
const result = await this.kit.createWallet(this.config.rpName, userName, {
|
|
97
|
+
autoSubmit: true,
|
|
98
|
+
});
|
|
99
|
+
// 2. Link to Better-Auth session
|
|
100
|
+
await this.linkToSession(result.contractId);
|
|
101
|
+
this._walletAddress = result.contractId;
|
|
102
|
+
// 3. Return result
|
|
103
|
+
return {
|
|
104
|
+
walletAddress: result.contractId,
|
|
105
|
+
credentialId: result.credentialId,
|
|
106
|
+
isNew: true,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Link a Stellar wallet address to the currently authenticated user session.
|
|
111
|
+
*/
|
|
112
|
+
async linkToSession(contractId) {
|
|
113
|
+
// 1. Check session
|
|
114
|
+
const res = await this.authClient.getSession();
|
|
115
|
+
const session = res?.data;
|
|
116
|
+
if (!session?.user) {
|
|
117
|
+
throw new BoundlessAuthError("No active auth session. User must be logged in via Better-Auth before linking a wallet.");
|
|
118
|
+
}
|
|
119
|
+
// 2. POST /api/auth/stellar/link
|
|
120
|
+
// Using fetch to manually hit the endpoint registered by the plugin.
|
|
121
|
+
// The SDK's authClient base URL is config.backendUrl.
|
|
122
|
+
const linkUrl = `${this.config.backendUrl}/api/auth/stellar/link`;
|
|
123
|
+
const response = await fetch(linkUrl, {
|
|
124
|
+
method: "POST",
|
|
125
|
+
headers: {
|
|
126
|
+
"Content-Type": "application/json",
|
|
127
|
+
},
|
|
128
|
+
body: JSON.stringify({ stellarAddress: contractId }),
|
|
129
|
+
// Credentials include cookies for the session
|
|
130
|
+
credentials: "include",
|
|
131
|
+
});
|
|
132
|
+
if (!response.ok) {
|
|
133
|
+
const text = await response.text();
|
|
134
|
+
throw new BoundlessLinkError(`Failed to link wallet: ${text}`, response.status);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Sign and submit a transaction.
|
|
139
|
+
* Delegates to SmartAccountKit (which handles relayer if configured).
|
|
140
|
+
*/
|
|
141
|
+
async signAndSubmit(transaction) {
|
|
142
|
+
const result = await this.kit.signAndSubmit(transaction);
|
|
143
|
+
return {
|
|
144
|
+
hash: result.hash,
|
|
145
|
+
success: result.success,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Fetch the balance of the connected wallet (or any specific address).
|
|
150
|
+
* By default, fetches native XLM balance.
|
|
151
|
+
* If assetCode (and issuer) is provided, fetches that asset's balance.
|
|
152
|
+
* If assetCode starts with 'C', it is treated as a contract ID.
|
|
153
|
+
*/
|
|
154
|
+
async getBalance(address, assetCode = "XLM", assetIssuer) {
|
|
155
|
+
if (!address)
|
|
156
|
+
return "0.00";
|
|
157
|
+
const networkConfig = NETWORK_CONFIGS[this.config.network];
|
|
158
|
+
const server = new rpc.Server(this.config.rpcUrl || networkConfig.defaultRpcUrl);
|
|
159
|
+
// 1. Native Balance
|
|
160
|
+
if (assetCode === "XLM") {
|
|
161
|
+
try {
|
|
162
|
+
const result = await server.getSACBalance(networkConfig.nativeTokenContract, Asset.native(), networkConfig.networkPassphrase);
|
|
163
|
+
if (result.balanceEntry) {
|
|
164
|
+
return (Number(result.balanceEntry.amount) / STROOPS_PER_XLM).toFixed(2);
|
|
165
|
+
}
|
|
166
|
+
return "0.00";
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
console.error("Error fetching native balance:", e);
|
|
170
|
+
return "0.00";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// 2. Custom Token Balance
|
|
174
|
+
let targetContractId = assetCode;
|
|
175
|
+
// Resolve Contract ID
|
|
176
|
+
if (assetCode.includes(":")) {
|
|
177
|
+
// CODE:ISSUER
|
|
178
|
+
const [code, issuer] = assetCode.split(":");
|
|
179
|
+
try {
|
|
180
|
+
const asset = new Asset(code, issuer);
|
|
181
|
+
targetContractId = asset.contractId(networkConfig.networkPassphrase);
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
console.error(`Invalid asset format: ${assetCode}`, e);
|
|
185
|
+
return "0";
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else if (assetIssuer) {
|
|
189
|
+
// Explicit Code + Issuer
|
|
190
|
+
try {
|
|
191
|
+
const asset = new Asset(assetCode, assetIssuer);
|
|
192
|
+
targetContractId = asset.contractId(networkConfig.networkPassphrase);
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
console.error(`Failed to derive contract for ${assetCode}`, e);
|
|
196
|
+
return "0";
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else if (!assetCode.startsWith("C")) {
|
|
200
|
+
// If it's just "USDC" without issuer, we might need a known list or fail.
|
|
201
|
+
// For SDK, we assume the user must provide enough info.
|
|
202
|
+
// However, if the user passes a contract address directly, we use it.
|
|
203
|
+
// Check if it's a valid contract address?
|
|
204
|
+
// For now, we assume if it's 56 chars starting with C, it's a contract.
|
|
205
|
+
// If not, we can't guess.
|
|
206
|
+
// But we'll try to treat it as a contract ID if it looks like one.
|
|
207
|
+
if (!assetCode.startsWith("C") || assetCode.length !== 56) {
|
|
208
|
+
console.warn("getBalance: Asset code must be XLM, C... contract ID, or CODE:ISSUER");
|
|
209
|
+
return "0";
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
// Simulate Balance Call
|
|
214
|
+
// Use DUMMY_SOURCE for simulation to avoid accountId errors with Smart Accounts
|
|
215
|
+
const sourceAccount = new Account(DUMMY_SOURCE, "0");
|
|
216
|
+
const tokenContract = new Contract(targetContractId);
|
|
217
|
+
const op = tokenContract.call("balance", new Address(address).toScVal());
|
|
218
|
+
const tx = new TransactionBuilder(sourceAccount, {
|
|
219
|
+
fee: "100",
|
|
220
|
+
networkPassphrase: networkConfig.networkPassphrase,
|
|
221
|
+
})
|
|
222
|
+
.addOperation(op)
|
|
223
|
+
.setTimeout(TimeoutInfinite)
|
|
224
|
+
.build();
|
|
225
|
+
const sim = await server.simulateTransaction(tx);
|
|
226
|
+
if (rpc.Api.isSimulationSuccess(sim) &&
|
|
227
|
+
sim.result &&
|
|
228
|
+
"retval" in sim.result) {
|
|
229
|
+
const val = scValToNative(sim.result.retval);
|
|
230
|
+
// Default formatting: Assume 7 decimals for now or return raw?
|
|
231
|
+
// Returning human-readable for convenience.
|
|
232
|
+
// Most Stellar tokens are 7 decimals.
|
|
233
|
+
return (Number(val) / 1e7).toFixed(2);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch (e) {
|
|
237
|
+
console.error(`Error fetching token balance for ${assetCode}:`, e);
|
|
238
|
+
}
|
|
239
|
+
return "0";
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Transfer funds (XLM or Token).
|
|
243
|
+
* Automatically resolves Asset-to-Contract if needed.
|
|
244
|
+
*/
|
|
245
|
+
async transfer(to, amount, assetCode = "XLM", assetIssuer) {
|
|
246
|
+
const networkConfig = NETWORK_CONFIGS[this.config.network];
|
|
247
|
+
let tokenContract = networkConfig.nativeTokenContract;
|
|
248
|
+
if (assetCode !== "XLM") {
|
|
249
|
+
if (assetCode.startsWith("C") && assetCode.length === 56) {
|
|
250
|
+
tokenContract = assetCode;
|
|
251
|
+
}
|
|
252
|
+
else if (assetCode.includes(":")) {
|
|
253
|
+
const [code, issuer] = assetCode.split(":");
|
|
254
|
+
const asset = new Asset(code, issuer);
|
|
255
|
+
tokenContract = asset.contractId(networkConfig.networkPassphrase);
|
|
256
|
+
}
|
|
257
|
+
else if (assetIssuer) {
|
|
258
|
+
const asset = new Asset(assetCode, assetIssuer);
|
|
259
|
+
tokenContract = asset.contractId(networkConfig.networkPassphrase);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
throw new Error("Invalid asset specifier. Use XLM, Contract ID, or Code + Issuer.");
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const amountNum = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
267
|
+
const result = await this.kit.transfer(tokenContract, to, amountNum);
|
|
268
|
+
return {
|
|
269
|
+
hash: result.hash,
|
|
270
|
+
success: result.success,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Disconnect the wallet (clear local session).
|
|
275
|
+
* Does NOT sign out of Better-Auth.
|
|
276
|
+
*/
|
|
277
|
+
async disconnect() {
|
|
278
|
+
await this.kit.disconnect();
|
|
279
|
+
this._walletAddress = null;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Get the connected wallet address synchronously.
|
|
283
|
+
*/
|
|
284
|
+
getWalletAddress() {
|
|
285
|
+
// smart-account-kit doesn't have a direct synchronous getter documented in the spec provided?
|
|
286
|
+
// "Read from the session state that SmartAccountKit maintains internally (check kit after connectWallet result)."
|
|
287
|
+
// Usually kit.address or similar is available if connected.
|
|
288
|
+
// Based on "sub-managers" list, it doesn't explicitly show 'address' property on kit intance.
|
|
289
|
+
// However, typical usage implies we can track it.
|
|
290
|
+
// BUT the prompt says: "check kit after connectWallet result".
|
|
291
|
+
// Wait, SmartAccountKit instance usage in 6.1 doesn't show a public 'address' field.
|
|
292
|
+
// But section 7.3 says: "Read from the session state that SmartAccountKit maintains internally".
|
|
293
|
+
// I will assume `kit.address` exists or I need to track it myself?
|
|
294
|
+
// "The SDK is one package... Client SDK class... It owns the client-side BoundlessSDK class".
|
|
295
|
+
// If I look at `kit` internals or typical patterns, it often exposes the address.
|
|
296
|
+
// If not, I should probably cache it on `connect` / `register`.
|
|
297
|
+
// BUT, `kit.connectWallet` returns the result.
|
|
298
|
+
// If the page reloads, `kit` is re-instantiated. `kit.connectWallet()` (silent) restores it.
|
|
299
|
+
// So `getWalletAddress` might need to rely on the *result* of the last connect/register.
|
|
300
|
+
//
|
|
301
|
+
// HOWEVER, `kit` might have an `address` getter.
|
|
302
|
+
// Let's assume for now I should inspect `kit` typings if I could, but I can't.
|
|
303
|
+
// "Read from the session state that SmartAccountKit maintains internally"
|
|
304
|
+
// implies `kit` has state.
|
|
305
|
+
// If `kit` tracks it, it's likely `kit.address`.
|
|
306
|
+
// I'll check if I can assume it.
|
|
307
|
+
// If `kit` does not expose it, I'd have to store it in `this.currentAddress`.
|
|
308
|
+
// But if `kit` disconnects, I need to know.
|
|
309
|
+
// `kit.events` emit 'walletDisconnected'.
|
|
310
|
+
// I'll use a safer approach: check if `kit` has a known property or Method.
|
|
311
|
+
// The spec 6.1 Core Methods allows `connectWallet`.
|
|
312
|
+
// If `kit` doesn't expose `address` directly, I'll rely on my own state updated via events/method calls.
|
|
313
|
+
// BUT Section 7.3 says "Read from the session state that SmartAccountKit maintains internally".
|
|
314
|
+
// This strongly suggests `kit` has it. I will try `(this.kit as any).address`.
|
|
315
|
+
// Or better, I will assume it might be there.
|
|
316
|
+
// Actually, looking at `smart-account-kit` typical implementations, it usually has `address`.
|
|
317
|
+
// I'll assume `this.kit.address` is the way.
|
|
318
|
+
// If TS complains, I'll fix it. I can't check types right now.
|
|
319
|
+
// I will use `(this.kit as any).address` to be safe if strict types block it,
|
|
320
|
+
// but better to try `this.kit.address` first? No, I want to avoid build errors.
|
|
321
|
+
// I'll cast for now to avoid blocking if the types aren't exactly matching my assumption.
|
|
322
|
+
// "Read from the session state that SmartAccountKit maintains internally"
|
|
323
|
+
return this._walletAddress || this.kit.address || null;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Add a recovery key (new passkey) to the existing account.
|
|
327
|
+
*/
|
|
328
|
+
async addRecoveryKey(options) {
|
|
329
|
+
const address = this.getWalletAddress();
|
|
330
|
+
if (!address) {
|
|
331
|
+
throw new WalletNotConnectedError("Wallet must be connected to add a recovery key.");
|
|
332
|
+
}
|
|
333
|
+
const { credentialId } = await this.kit.signers.addPasskey(0, // contextRuleId (0 = default)
|
|
334
|
+
options.appName, options.userName, { nickname: options.nickname });
|
|
335
|
+
return { credentialId };
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Remove a credential by ID.
|
|
339
|
+
*/
|
|
340
|
+
async removeCredential(credentialId) {
|
|
341
|
+
const address = this.getWalletAddress();
|
|
342
|
+
if (!address) {
|
|
343
|
+
throw new WalletNotConnectedError("Wallet must be connected to remove a credential.");
|
|
344
|
+
}
|
|
345
|
+
await this.kit.signers.removePasskey(0, credentialId);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Subscribe to events.
|
|
349
|
+
*/
|
|
350
|
+
onEvent(event, handler) {
|
|
351
|
+
const validEvents = [
|
|
352
|
+
"walletConnected",
|
|
353
|
+
"walletDisconnected",
|
|
354
|
+
"credentialCreated",
|
|
355
|
+
"credentialDeleted",
|
|
356
|
+
"sessionExpired",
|
|
357
|
+
"transactionSigned",
|
|
358
|
+
"transactionSubmitted",
|
|
359
|
+
];
|
|
360
|
+
if (!validEvents.includes(event)) {
|
|
361
|
+
// Just ignore or warn? Types prevent this usually.
|
|
362
|
+
console.warn(`BoundlessSDK: Unknown event "${event}"`);
|
|
363
|
+
return () => { };
|
|
364
|
+
}
|
|
365
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
366
|
+
this.kit.events.on(event, handler);
|
|
367
|
+
return () => {
|
|
368
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
369
|
+
this.kit.events.off(event, handler);
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=boundless-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundless-sdk.js","sourceRoot":"","sources":["../src/boundless-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,uBAAuB,EACvB,eAAe,GAChB,MAAM,mBAAmB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AG,CAAC,KAAK,EAAE,OAAc,CAAC,CAAC;QAC7C,CAAC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const NETWORK_CONFIGS: {
|
|
2
|
+
readonly testnet: {
|
|
3
|
+
readonly networkPassphrase: "Test SDF Network ; September 2015";
|
|
4
|
+
readonly defaultRpcUrl: "https://soroban-testnet.stellar.org";
|
|
5
|
+
readonly accountWasmHash: "a12e8fa9621efd20315753bd4007d974390e31fbcb4a7ddc4dd0a0dec728bf2e";
|
|
6
|
+
readonly webauthnVerifierAddress: "CBSHV66WG7UV6FQVUTB67P3DZUEJ2KJ5X6JKQH5MFRAAFNFJUAJVXJYV";
|
|
7
|
+
readonly ed25519VerifierAddress: "CDGMOL3BP6Y6LYOXXTRNXBNJ2SLNTQ47BGG3LOS2OBBE657E3NYCN54B";
|
|
8
|
+
readonly nativeTokenContract: "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC";
|
|
9
|
+
readonly policies: {
|
|
10
|
+
readonly threshold: "CCT4MMN5MJ6O2OU6LXPYTCVORQ2QVTBMDJ7MYBZQ2ULSYQVUIYP4IFYD";
|
|
11
|
+
readonly spendingLimit: "CBMMWY54XOV6JJHSWCMKWWPXVRXASR5U26UJMLZDN4SP6CFFTVZARPTY";
|
|
12
|
+
readonly weightedThreshold: "CBYDQ5XUBP7G24FI3LLGLW56QZCIEUSVRPX7FVOUCKHJQQ6DTF6BQGBZ";
|
|
13
|
+
};
|
|
14
|
+
readonly relayerUrl: "";
|
|
15
|
+
};
|
|
16
|
+
readonly mainnet: {
|
|
17
|
+
readonly networkPassphrase: "Public Global Stellar Network ; September 2015";
|
|
18
|
+
readonly defaultRpcUrl: "https://soroban-rpc.mainnet.stellar.org";
|
|
19
|
+
readonly accountWasmHash: "REPLACE_WITH_MAINNET_WASM_HASH";
|
|
20
|
+
readonly webauthnVerifierAddress: "REPLACE_WITH_MAINNET_VERIFIER";
|
|
21
|
+
readonly ed25519VerifierAddress: "REPLACE_WITH_MAINNET_VERIFIER";
|
|
22
|
+
readonly nativeTokenContract: "REPLACE_WITH_MAINNET_CONTRACT";
|
|
23
|
+
readonly policies: {
|
|
24
|
+
readonly threshold: "REPLACE_WITH_MAINNET_POLICY";
|
|
25
|
+
readonly spendingLimit: "REPLACE_WITH_MAINNET_POLICY";
|
|
26
|
+
readonly weightedThreshold: "REPLACE_WITH_MAINNET_POLICY";
|
|
27
|
+
};
|
|
28
|
+
readonly relayerUrl: "";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type NetworkName = keyof typeof NETWORK_CONFIGS;
|
|
32
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkClB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,eAAe,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const NETWORK_CONFIGS = {
|
|
2
|
+
testnet: {
|
|
3
|
+
networkPassphrase: "Test SDF Network ; September 2015",
|
|
4
|
+
defaultRpcUrl: "https://soroban-testnet.stellar.org",
|
|
5
|
+
accountWasmHash: "a12e8fa9621efd20315753bd4007d974390e31fbcb4a7ddc4dd0a0dec728bf2e",
|
|
6
|
+
webauthnVerifierAddress: "CBSHV66WG7UV6FQVUTB67P3DZUEJ2KJ5X6JKQH5MFRAAFNFJUAJVXJYV",
|
|
7
|
+
ed25519VerifierAddress: "CDGMOL3BP6Y6LYOXXTRNXBNJ2SLNTQ47BGG3LOS2OBBE657E3NYCN54B",
|
|
8
|
+
nativeTokenContract: "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC",
|
|
9
|
+
policies: {
|
|
10
|
+
threshold: "CCT4MMN5MJ6O2OU6LXPYTCVORQ2QVTBMDJ7MYBZQ2ULSYQVUIYP4IFYD",
|
|
11
|
+
spendingLimit: "CBMMWY54XOV6JJHSWCMKWWPXVRXASR5U26UJMLZDN4SP6CFFTVZARPTY",
|
|
12
|
+
weightedThreshold: "CBYDQ5XUBP7G24FI3LLGLW56QZCIEUSVRPX7FVOUCKHJQQ6DTF6BQGBZ",
|
|
13
|
+
},
|
|
14
|
+
relayerUrl: "",
|
|
15
|
+
},
|
|
16
|
+
mainnet: {
|
|
17
|
+
networkPassphrase: "Public Global Stellar Network ; September 2015",
|
|
18
|
+
defaultRpcUrl: "https://soroban-rpc.mainnet.stellar.org",
|
|
19
|
+
accountWasmHash: "REPLACE_WITH_MAINNET_WASM_HASH",
|
|
20
|
+
webauthnVerifierAddress: "REPLACE_WITH_MAINNET_VERIFIER",
|
|
21
|
+
ed25519VerifierAddress: "REPLACE_WITH_MAINNET_VERIFIER",
|
|
22
|
+
nativeTokenContract: "REPLACE_WITH_MAINNET_CONTRACT",
|
|
23
|
+
policies: {
|
|
24
|
+
threshold: "REPLACE_WITH_MAINNET_POLICY",
|
|
25
|
+
spendingLimit: "REPLACE_WITH_MAINNET_POLICY",
|
|
26
|
+
weightedThreshold: "REPLACE_WITH_MAINNET_POLICY",
|
|
27
|
+
},
|
|
28
|
+
relayerUrl: "",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE;QACP,iBAAiB,EAAE,mCAAmC;QACtD,aAAa,EAAE,qCAAqC;QACpD,eAAe,EACb,kEAAkE;QACpE,uBAAuB,EACrB,0DAA0D;QAC5D,sBAAsB,EACpB,0DAA0D;QAC5D,mBAAmB,EACjB,0DAA0D;QAC5D,QAAQ,EAAE;YACR,SAAS,EAAE,0DAA0D;YACrE,aAAa,EAAE,0DAA0D;YACzE,iBAAiB,EACf,0DAA0D;SAC7D;QACD,UAAU,EAAE,EAAE;KACf;IACD,OAAO,EAAE;QACP,iBAAiB,EAAE,gDAAgD;QACnE,aAAa,EAAE,yCAAyC;QACxD,eAAe,EAAE,gCAAgC;QACjD,uBAAuB,EAAE,+BAA+B;QACxD,sBAAsB,EAAE,+BAA+B;QACvD,mBAAmB,EAAE,+BAA+B;QACpD,QAAQ,EAAE;YACR,SAAS,EAAE,6BAA6B;YACxC,aAAa,EAAE,6BAA6B;YAC5C,iBAAiB,EAAE,6BAA6B;SACjD;QACD,UAAU,EAAE,EAAE;KACf;CACO,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SmartAccountError } from "smart-account-kit";
|
|
2
|
+
export declare class BoundlessAuthError extends SmartAccountError {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class BoundlessLinkError extends SmartAccountError {
|
|
6
|
+
statusCode?: number | undefined;
|
|
7
|
+
constructor(message: string, statusCode?: number | undefined);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,qBAAa,kBAAmB,SAAQ,iBAAiB;gBAC3C,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,iBAAiB;IAG9C,UAAU,CAAC,EAAE,MAAM;gBAD1B,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA;CAK7B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SmartAccountError } from "smart-account-kit";
|
|
2
|
+
export class BoundlessAuthError extends SmartAccountError {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message, "BOUNDLESS_AUTH");
|
|
5
|
+
this.name = "BoundlessAuthError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class BoundlessLinkError extends SmartAccountError {
|
|
9
|
+
statusCode;
|
|
10
|
+
constructor(message, statusCode) {
|
|
11
|
+
super(message, "BOUNDLESS_LINK");
|
|
12
|
+
this.statusCode = statusCode;
|
|
13
|
+
this.name = "BoundlessLinkError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IACvD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,gBAAuB,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAG9C;IAFT,YACE,OAAe,EACR,UAAmB;QAE1B,KAAK,CAAC,OAAO,EAAE,gBAAuB,CAAC,CAAC;QAFjC,eAAU,GAAV,UAAU,CAAS;QAG1B,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./boundless-sdk";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export * from "./errors";
|
|
4
|
+
export * from "./constants";
|
|
5
|
+
export * from "./utils";
|
|
6
|
+
export { SmartAccountError, WalletNotConnectedError, CredentialNotFoundError, SignerNotFoundError, SimulationError, SubmissionError, ValidationError, WebAuthnError, SessionError, wrapError, } from "smart-account-kit";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,SAAS,GACV,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./boundless-sdk";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export * from "./errors";
|
|
4
|
+
export * from "./constants";
|
|
5
|
+
export * from "./utils";
|
|
6
|
+
export { SmartAccountError, WalletNotConnectedError, CredentialNotFoundError, SignerNotFoundError, SimulationError, SubmissionError, ValidationError, WebAuthnError, SessionError, wrapError, } from "smart-account-kit";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,SAAS,GACV,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stellar-plugin.d.ts","sourceRoot":"","sources":["../../src/server/stellar-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,sBAAsB,QAAO,gBA+D/B,CAAC"}
|