@veridex/sdk 1.1.1 → 1.1.2

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.
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunk-V636MIV3.mjs";
4
4
  import {
5
5
  EVMClient
6
- } from "../../chunk-YBN2VC6E.mjs";
6
+ } from "../../chunk-DZUNCSI5.mjs";
7
7
  import "../../chunk-TPEP6XUA.mjs";
8
8
  import "../../chunk-RD6ZYUVG.mjs";
9
9
  export {
@@ -1,4 +1,4 @@
1
- import { a as SessionKey } from '../../types-DWx-5jmz.mjs';
1
+ import { a as SessionKey } from '../../types-C564CfsE.mjs';
2
2
  import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature, D as DispatchResult, V as VaultCreationResult, x as RegisterSessionParams, y as RevokeSessionParams, S as SessionValidationResult } from '../../types-DP2CQT8p.mjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { a as SessionKey } from '../../types-DWx-5jmz.mjs';
1
+ import { a as SessionKey } from '../../types-C564CfsE.mjs';
2
2
  import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature, D as DispatchResult, V as VaultCreationResult, x as RegisterSessionParams, y as RevokeSessionParams, S as SessionValidationResult } from '../../types-DP2CQT8p.mjs';
3
3
  import { RpcProvider } from 'starknet';
4
4
 
@@ -0,0 +1,312 @@
1
+ import { PasskeyManager, PasskeyCredential } from '../../passkey.mjs';
2
+
3
+ /**
4
+ * Veridex Protocol SDK — Stellar chain types
5
+ *
6
+ * Local mirror of the subset of the Stellar-Wallets-Kit `ModuleInterface`
7
+ * contract we implement. We mirror it (rather than importing from
8
+ * `@creit.tech/stellar-wallets-kit`) so `@veridex/sdk` does not gain a hard
9
+ * peer dependency on the kit. Consumers who already depend on the kit can
10
+ * cast our module to the upstream type — the shapes are structurally
11
+ * identical.
12
+ *
13
+ * Upstream reference: `@creit.tech/stellar-wallets-kit` →
14
+ * src/types/mod.ts → `ModuleInterface`
15
+ */
16
+ declare enum StellarNetworks {
17
+ PUBLIC = "Public Global Stellar Network ; September 2015",
18
+ TESTNET = "Test SDF Network ; September 2015",
19
+ FUTURENET = "Test SDF Future Network ; October 2022",
20
+ SANDBOX = "Local Sandbox Stellar Network ; September 2022",
21
+ STANDALONE = "Standalone Network ; February 2017"
22
+ }
23
+ declare enum StellarModuleType {
24
+ HW_WALLET = "HW_WALLET",
25
+ HOT_WALLET = "HOT_WALLET",
26
+ BRIDGE_WALLET = "BRIDGE_WALLET",
27
+ AIR_GAPED_WALLET = "AIR_GAPED_WALLET"
28
+ }
29
+ interface StellarKitError {
30
+ code: number;
31
+ message: string;
32
+ ext?: string;
33
+ }
34
+ /**
35
+ * Stellar-Wallets-Kit `ModuleInterface` mirror.
36
+ * Only the methods we implement are documented; signature-compatible with
37
+ * the upstream contract.
38
+ */
39
+ interface StellarWalletModuleInterface {
40
+ moduleType: StellarModuleType;
41
+ productId: string;
42
+ productName: string;
43
+ productUrl: string;
44
+ productIcon: string;
45
+ isAvailable(): Promise<boolean>;
46
+ isPlatformWrapper?(): Promise<boolean>;
47
+ getAddress(params?: {
48
+ path?: string;
49
+ skipRequestAccess?: boolean;
50
+ }): Promise<{
51
+ address: string;
52
+ }>;
53
+ signTransaction(xdr: string, opts?: {
54
+ networkPassphrase?: string;
55
+ address?: string;
56
+ path?: string;
57
+ }): Promise<{
58
+ signedTxXdr: string;
59
+ signerAddress?: string;
60
+ }>;
61
+ signAuthEntry(authEntry: string, opts?: {
62
+ networkPassphrase?: string;
63
+ address?: string;
64
+ path?: string;
65
+ }): Promise<{
66
+ signedAuthEntry: string;
67
+ signerAddress?: string;
68
+ }>;
69
+ signMessage(message: string, opts?: {
70
+ networkPassphrase?: string;
71
+ address?: string;
72
+ path?: string;
73
+ }): Promise<{
74
+ signedMessage: string;
75
+ signerAddress?: string;
76
+ }>;
77
+ }
78
+ /**
79
+ * Veridex-specific configuration for the Stellar passkey signer.
80
+ */
81
+ interface VeridexStellarConfig {
82
+ /** Stellar network passphrase. Defaults to TESTNET. */
83
+ network?: StellarNetworks;
84
+ /**
85
+ * Soroban RPC URL (used to resolve the smart-account address or submit
86
+ * transactions when `signAndSubmitTransaction` is invoked).
87
+ */
88
+ rpcUrl?: string;
89
+ /**
90
+ * Optional pre-deployed smart-account contract id (C-address). If
91
+ * provided, `getAddress()` returns this directly. Otherwise the address
92
+ * is derived deterministically from the passkey `keyHash`.
93
+ */
94
+ smartAccountContractId?: string;
95
+ /**
96
+ * Override the deterministic smart-account factory contract. Used for
97
+ * address derivation when `smartAccountContractId` is not set.
98
+ */
99
+ smartAccountFactory?: string;
100
+ }
101
+ /**
102
+ * A signed WebAuthn assertion ready to be embedded in a Soroban auth entry.
103
+ *
104
+ * The shape matches what a Soroban smart-account's `__check_auth` entrypoint
105
+ * needs to verify a secp256r1 passkey signature:
106
+ * - `keyHash` identifies which registered passkey signed
107
+ * - `authenticatorData` + `clientDataJSON` are the WebAuthn assertion
108
+ * - `r`, `s` are the secp256r1 signature components
109
+ */
110
+ interface PasskeyAuthAssertion {
111
+ keyHash: string;
112
+ authenticatorData: string;
113
+ clientDataJSON: string;
114
+ challengeIndex: number;
115
+ typeIndex: number;
116
+ signatureR: string;
117
+ signatureS: string;
118
+ }
119
+
120
+ /**
121
+ * Veridex Protocol SDK — Stellar Passkey Signer
122
+ *
123
+ * Bridges Veridex's WebAuthn `PasskeyManager` to the SEP-43 signing surface
124
+ * expected by Soroban smart accounts (and the Stellar-Wallets-Kit
125
+ * `ModuleInterface`).
126
+ *
127
+ * Design:
128
+ * - The signer treats every SEP-43 signing call (transaction / auth entry
129
+ * / message) as a request to produce a WebAuthn assertion over the
130
+ * SHA-256 of a canonical preimage.
131
+ * - For a transaction we hash `network_id || tagged_tx_envelope` per the
132
+ * XDR-hash spec; for an auth entry we hash the
133
+ * `HashIdPreimageSorobanAuthorization`; for a message we hash the bytes
134
+ * directly.
135
+ * - The returned `signedTxXdr` / `signedAuthEntry` strings are
136
+ * base64-encoded JSON containers carrying the assertion. The downstream
137
+ * Soroban smart-account contract (`__check_auth`) is responsible for
138
+ * parsing the container, verifying secp256r1, and authorizing.
139
+ *
140
+ * This separation lets `@veridex/sdk` ship without a hard dependency on
141
+ * `@stellar/stellar-sdk`. Consumers who want full XDR-aware signing can
142
+ * subclass and override `hashTransactionXdr` / `hashAuthEntry`.
143
+ */
144
+
145
+ interface StellarPasskeySignerOptions {
146
+ passkey: PasskeyManager;
147
+ credential?: PasskeyCredential;
148
+ config?: VeridexStellarConfig;
149
+ }
150
+ declare class StellarPasskeySigner {
151
+ private readonly passkey;
152
+ private credential?;
153
+ private readonly network;
154
+ private readonly smartAccountContractId?;
155
+ constructor(opts: StellarPasskeySignerOptions);
156
+ /**
157
+ * Returns the Soroban smart-account address (C-address-derivable hex)
158
+ * associated with the active passkey. If a fixed contract id was
159
+ * configured we return it verbatim; otherwise we derive deterministically.
160
+ */
161
+ getAddress(skipRequestAccess?: boolean): Promise<{
162
+ address: string;
163
+ }>;
164
+ /**
165
+ * Produce a SEP-43 `signedTxXdr` for the given transaction envelope XDR.
166
+ *
167
+ * Because we do not bundle `@stellar/stellar-sdk` we hash the XDR's
168
+ * binary form prefixed with the network passphrase. Consumers that need
169
+ * canonical Stellar transaction hashes should preprocess `xdr` to the
170
+ * spec-compliant preimage before calling, or override this method.
171
+ */
172
+ signTransaction(xdr: string, opts?: {
173
+ networkPassphrase?: string;
174
+ address?: string;
175
+ }): Promise<{
176
+ signedTxXdr: string;
177
+ signerAddress: string;
178
+ }>;
179
+ /**
180
+ * Sign a Soroban `HashIdPreimageSorobanAuthorization` XDR. The auth
181
+ * entry payload is hashed and wrapped identically to a transaction.
182
+ */
183
+ signAuthEntry(authEntry: string, opts?: {
184
+ networkPassphrase?: string;
185
+ address?: string;
186
+ }): Promise<{
187
+ signedAuthEntry: string;
188
+ signerAddress: string;
189
+ }>;
190
+ /**
191
+ * Sign an arbitrary message per SEP-43 `signMessage`.
192
+ */
193
+ signMessage(message: string, opts?: {
194
+ networkPassphrase?: string;
195
+ address?: string;
196
+ }): Promise<{
197
+ signedMessage: string;
198
+ signerAddress: string;
199
+ }>;
200
+ protected hashTransactionXdr(xdr: string, networkPassphrase: string): Uint8Array;
201
+ protected hashAuthEntry(authEntry: string, networkPassphrase: string): Uint8Array;
202
+ private signChallenge;
203
+ private ensureCredential;
204
+ private encodeAssertionContainer;
205
+ private decodeBase64;
206
+ }
207
+
208
+ /**
209
+ * Veridex Protocol SDK — Stellar-Wallets-Kit ModuleInterface implementation
210
+ *
211
+ * Drop-in module for `@creit.tech/stellar-wallets-kit` that exposes
212
+ * Veridex's passkey-backed Soroban smart account as a wallet option.
213
+ *
214
+ * Usage (downstream app):
215
+ * ```ts
216
+ * import { StellarWalletsKit, allowAllModules } from '@creit.tech/stellar-wallets-kit';
217
+ * import { PasskeyManager } from '@veridex/sdk/passkey';
218
+ * import { VeridexStellarWalletModule } from '@veridex/sdk/chains/stellar';
219
+ *
220
+ * const passkey = new PasskeyManager({ rpName: 'My Dapp' });
221
+ * const veridexModule = new VeridexStellarWalletModule({ passkey });
222
+ *
223
+ * const kit = new StellarWalletsKit({
224
+ * network: WalletNetwork.TESTNET,
225
+ * selectedWalletId: VERIDEX_PASSKEY_ID,
226
+ * modules: [...allowAllModules(), veridexModule],
227
+ * });
228
+ * ```
229
+ */
230
+
231
+ declare const VERIDEX_PASSKEY_ID = "veridex-passkey";
232
+ interface VeridexStellarWalletModuleOptions {
233
+ passkey: PasskeyManager;
234
+ credential?: PasskeyCredential;
235
+ config?: VeridexStellarConfig;
236
+ productName?: string;
237
+ productUrl?: string;
238
+ productIcon?: string;
239
+ }
240
+ declare class VeridexStellarWalletModule implements StellarWalletModuleInterface {
241
+ readonly moduleType: StellarModuleType;
242
+ readonly productId: string;
243
+ readonly productName: string;
244
+ readonly productUrl: string;
245
+ readonly productIcon: string;
246
+ private readonly signer;
247
+ constructor(opts: VeridexStellarWalletModuleOptions);
248
+ isAvailable(): Promise<boolean>;
249
+ isPlatformWrapper(): Promise<boolean>;
250
+ getAddress(params?: {
251
+ path?: string;
252
+ skipRequestAccess?: boolean;
253
+ }): Promise<{
254
+ address: string;
255
+ }>;
256
+ signTransaction(xdr: string, opts?: {
257
+ networkPassphrase?: string;
258
+ address?: string;
259
+ path?: string;
260
+ }): Promise<{
261
+ signedTxXdr: string;
262
+ signerAddress?: string;
263
+ }>;
264
+ signAuthEntry(authEntry: string, opts?: {
265
+ networkPassphrase?: string;
266
+ address?: string;
267
+ path?: string;
268
+ }): Promise<{
269
+ signedAuthEntry: string;
270
+ signerAddress?: string;
271
+ }>;
272
+ signMessage(message: string, opts?: {
273
+ networkPassphrase?: string;
274
+ address?: string;
275
+ path?: string;
276
+ }): Promise<{
277
+ signedMessage: string;
278
+ signerAddress?: string;
279
+ }>;
280
+ }
281
+
282
+ /**
283
+ * Veridex Protocol SDK — Soroban smart-account address derivation
284
+ *
285
+ * The Veridex Stellar adapter binds a WebAuthn passkey to a Soroban smart
286
+ * account whose `__check_auth` entry verifies secp256r1 signatures against
287
+ * the passkey's `keyHash`.
288
+ *
289
+ * For the credibility-artifact stage we expose deterministic address
290
+ * derivation only — actual deployment is handled by a separate Soroban
291
+ * factory contract (see `contracts/stellar/` once added). This keeps the
292
+ * SDK chain-agnostic and avoids pulling in the heavy `@stellar/stellar-sdk`
293
+ * runtime.
294
+ */
295
+ /**
296
+ * Deterministically derive a Soroban contract id (C-address) from a passkey
297
+ * `keyHash`. This mirrors the SEP-0011 Stellar contract-id derivation
298
+ * scheme: contract_id = sha256(networkPassphrase || keyHash || salt).
299
+ *
300
+ * NOTE: This returns a stable 32-byte identifier encoded as hex. To produce
301
+ * a canonical `C...` strkey representation the consumer must encode it with
302
+ * `StrKey.encodeContract` from `@stellar/stellar-sdk`. We deliberately keep
303
+ * the encoding out of `@veridex/sdk` to avoid a hard dependency.
304
+ *
305
+ * @param keyHash - The Veridex passkey keyHash (hex, with or without 0x).
306
+ * @param networkPassphrase - Stellar network passphrase (e.g. testnet).
307
+ * @param salt - Optional 32-byte salt (hex). Defaults to all-zeros.
308
+ * @returns The 32-byte contract id encoded as a 0x-prefixed hex string.
309
+ */
310
+ declare function deriveSmartAccountId(keyHash: string, networkPassphrase: string, salt?: string): string;
311
+
312
+ export { type PasskeyAuthAssertion, type StellarKitError, StellarModuleType, StellarNetworks, StellarPasskeySigner, type StellarPasskeySignerOptions, type StellarWalletModuleInterface, VERIDEX_PASSKEY_ID, type VeridexStellarConfig, VeridexStellarWalletModule, type VeridexStellarWalletModuleOptions, deriveSmartAccountId };
@@ -0,0 +1,300 @@
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/chains/stellar/index.ts
21
+ var stellar_exports = {};
22
+ __export(stellar_exports, {
23
+ StellarModuleType: () => StellarModuleType,
24
+ StellarNetworks: () => StellarNetworks,
25
+ StellarPasskeySigner: () => StellarPasskeySigner,
26
+ VERIDEX_PASSKEY_ID: () => VERIDEX_PASSKEY_ID,
27
+ VeridexStellarWalletModule: () => VeridexStellarWalletModule,
28
+ deriveSmartAccountId: () => deriveSmartAccountId
29
+ });
30
+ module.exports = __toCommonJS(stellar_exports);
31
+
32
+ // src/chains/stellar/StellarPasskeySigner.ts
33
+ var import_sha2562 = require("@noble/hashes/sha256");
34
+
35
+ // src/utils.ts
36
+ var import_ethers = require("ethers");
37
+ function base64URLDecode(str) {
38
+ const base64 = str.replace(/-/g, "+").replace(/_/g, "/");
39
+ const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
40
+ const binary = atob(padded);
41
+ const bytes = new Uint8Array(binary.length);
42
+ for (let i = 0; i < binary.length; i++) {
43
+ bytes[i] = binary.charCodeAt(i);
44
+ }
45
+ return bytes;
46
+ }
47
+
48
+ // src/chains/stellar/types.ts
49
+ var StellarNetworks = /* @__PURE__ */ ((StellarNetworks2) => {
50
+ StellarNetworks2["PUBLIC"] = "Public Global Stellar Network ; September 2015";
51
+ StellarNetworks2["TESTNET"] = "Test SDF Network ; September 2015";
52
+ StellarNetworks2["FUTURENET"] = "Test SDF Future Network ; October 2022";
53
+ StellarNetworks2["SANDBOX"] = "Local Sandbox Stellar Network ; September 2022";
54
+ StellarNetworks2["STANDALONE"] = "Standalone Network ; February 2017";
55
+ return StellarNetworks2;
56
+ })(StellarNetworks || {});
57
+ var StellarModuleType = /* @__PURE__ */ ((StellarModuleType2) => {
58
+ StellarModuleType2["HW_WALLET"] = "HW_WALLET";
59
+ StellarModuleType2["HOT_WALLET"] = "HOT_WALLET";
60
+ StellarModuleType2["BRIDGE_WALLET"] = "BRIDGE_WALLET";
61
+ StellarModuleType2["AIR_GAPED_WALLET"] = "AIR_GAPED_WALLET";
62
+ return StellarModuleType2;
63
+ })(StellarModuleType || {});
64
+
65
+ // src/chains/stellar/SmartAccount.ts
66
+ var import_sha256 = require("@noble/hashes/sha256");
67
+ function deriveSmartAccountId(keyHash, networkPassphrase, salt) {
68
+ const cleanHash = keyHash.startsWith("0x") ? keyHash.slice(2) : keyHash;
69
+ if (cleanHash.length !== 64) {
70
+ throw new Error(
71
+ `deriveSmartAccountId: keyHash must be 32 bytes (64 hex chars), got ${cleanHash.length}`
72
+ );
73
+ }
74
+ const cleanSalt = salt ? salt.startsWith("0x") ? salt.slice(2) : salt : "0".repeat(64);
75
+ if (cleanSalt.length !== 64) {
76
+ throw new Error(
77
+ `deriveSmartAccountId: salt must be 32 bytes (64 hex chars), got ${cleanSalt.length}`
78
+ );
79
+ }
80
+ const encoder = new TextEncoder();
81
+ const passphraseBytes = encoder.encode(networkPassphrase);
82
+ const keyHashBytes = hexToBytes(cleanHash);
83
+ const saltBytes = hexToBytes(cleanSalt);
84
+ const buffer = new Uint8Array(
85
+ passphraseBytes.length + keyHashBytes.length + saltBytes.length
86
+ );
87
+ buffer.set(passphraseBytes, 0);
88
+ buffer.set(keyHashBytes, passphraseBytes.length);
89
+ buffer.set(saltBytes, passphraseBytes.length + keyHashBytes.length);
90
+ const digest = (0, import_sha256.sha256)(buffer);
91
+ return "0x" + bytesToHex(digest);
92
+ }
93
+ function hexToBytes(hex) {
94
+ const out = new Uint8Array(hex.length / 2);
95
+ for (let i = 0; i < out.length; i++) {
96
+ out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
97
+ }
98
+ return out;
99
+ }
100
+ function bytesToHex(bytes) {
101
+ let hex = "";
102
+ for (let i = 0; i < bytes.length; i++) {
103
+ hex += bytes[i].toString(16).padStart(2, "0");
104
+ }
105
+ return hex;
106
+ }
107
+
108
+ // src/chains/stellar/StellarPasskeySigner.ts
109
+ var StellarPasskeySigner = class {
110
+ passkey;
111
+ credential;
112
+ network;
113
+ smartAccountContractId;
114
+ constructor(opts) {
115
+ this.passkey = opts.passkey;
116
+ this.credential = opts.credential;
117
+ this.network = opts.config?.network ?? "Test SDF Network ; September 2015" /* TESTNET */;
118
+ this.smartAccountContractId = opts.config?.smartAccountContractId;
119
+ }
120
+ /**
121
+ * Returns the Soroban smart-account address (C-address-derivable hex)
122
+ * associated with the active passkey. If a fixed contract id was
123
+ * configured we return it verbatim; otherwise we derive deterministically.
124
+ */
125
+ async getAddress(skipRequestAccess = false) {
126
+ if (this.smartAccountContractId) {
127
+ return { address: this.smartAccountContractId };
128
+ }
129
+ const cred = await this.ensureCredential(skipRequestAccess);
130
+ const id = deriveSmartAccountId(cred.keyHash, this.network);
131
+ return { address: id };
132
+ }
133
+ /**
134
+ * Produce a SEP-43 `signedTxXdr` for the given transaction envelope XDR.
135
+ *
136
+ * Because we do not bundle `@stellar/stellar-sdk` we hash the XDR's
137
+ * binary form prefixed with the network passphrase. Consumers that need
138
+ * canonical Stellar transaction hashes should preprocess `xdr` to the
139
+ * spec-compliant preimage before calling, or override this method.
140
+ */
141
+ async signTransaction(xdr, opts) {
142
+ const cred = await this.ensureCredential(true);
143
+ const passphrase = opts?.networkPassphrase ?? this.network;
144
+ const challenge = this.hashTransactionXdr(xdr, passphrase);
145
+ const assertion = await this.signChallenge(challenge, cred);
146
+ const container = this.encodeAssertionContainer("tx", xdr, assertion);
147
+ const { address } = await this.getAddress(true);
148
+ return { signedTxXdr: container, signerAddress: opts?.address ?? address };
149
+ }
150
+ /**
151
+ * Sign a Soroban `HashIdPreimageSorobanAuthorization` XDR. The auth
152
+ * entry payload is hashed and wrapped identically to a transaction.
153
+ */
154
+ async signAuthEntry(authEntry, opts) {
155
+ const cred = await this.ensureCredential(true);
156
+ const passphrase = opts?.networkPassphrase ?? this.network;
157
+ const challenge = this.hashAuthEntry(authEntry, passphrase);
158
+ const assertion = await this.signChallenge(challenge, cred);
159
+ const container = this.encodeAssertionContainer("auth", authEntry, assertion);
160
+ const { address } = await this.getAddress(true);
161
+ return { signedAuthEntry: container, signerAddress: opts?.address ?? address };
162
+ }
163
+ /**
164
+ * Sign an arbitrary message per SEP-43 `signMessage`.
165
+ */
166
+ async signMessage(message, opts) {
167
+ const cred = await this.ensureCredential(true);
168
+ const challenge = (0, import_sha2562.sha256)(new TextEncoder().encode(message));
169
+ const assertion = await this.signChallenge(challenge, cred);
170
+ const container = this.encodeAssertionContainer("msg", message, assertion);
171
+ const { address } = await this.getAddress(true);
172
+ return { signedMessage: container, signerAddress: opts?.address ?? address };
173
+ }
174
+ // ------------------------------------------------------------------
175
+ // Internals
176
+ // ------------------------------------------------------------------
177
+ hashTransactionXdr(xdr, networkPassphrase) {
178
+ const passphraseHash = (0, import_sha2562.sha256)(new TextEncoder().encode(networkPassphrase));
179
+ const xdrBytes = this.decodeBase64(xdr);
180
+ const buf = new Uint8Array(passphraseHash.length + xdrBytes.length);
181
+ buf.set(passphraseHash, 0);
182
+ buf.set(xdrBytes, passphraseHash.length);
183
+ return (0, import_sha2562.sha256)(buf);
184
+ }
185
+ hashAuthEntry(authEntry, networkPassphrase) {
186
+ return this.hashTransactionXdr(authEntry, networkPassphrase);
187
+ }
188
+ async signChallenge(challenge, credential) {
189
+ const sig = await this.passkey.sign(challenge);
190
+ return {
191
+ keyHash: credential.keyHash,
192
+ authenticatorData: sig.authenticatorData,
193
+ clientDataJSON: sig.clientDataJSON,
194
+ challengeIndex: sig.challengeIndex,
195
+ typeIndex: sig.typeIndex,
196
+ signatureR: "0x" + sig.r.toString(16).padStart(64, "0"),
197
+ signatureS: "0x" + sig.s.toString(16).padStart(64, "0")
198
+ };
199
+ }
200
+ async ensureCredential(skipRequestAccess) {
201
+ if (this.credential) return this.credential;
202
+ if (skipRequestAccess) {
203
+ throw new Error(
204
+ "StellarPasskeySigner: no credential cached. Call passkey.authenticate() first or pass `credential` to the constructor."
205
+ );
206
+ }
207
+ const { credential } = await this.passkey.authenticate();
208
+ this.credential = credential;
209
+ return credential;
210
+ }
211
+ encodeAssertionContainer(kind, payload, assertion) {
212
+ const container = {
213
+ v: 1,
214
+ kind,
215
+ payload,
216
+ assertion
217
+ };
218
+ const json = JSON.stringify(container);
219
+ if (typeof Buffer !== "undefined") {
220
+ return Buffer.from(json, "utf8").toString("base64");
221
+ }
222
+ return btoa(unescape(encodeURIComponent(json)));
223
+ }
224
+ decodeBase64(input) {
225
+ try {
226
+ if (typeof Buffer !== "undefined") {
227
+ return new Uint8Array(Buffer.from(input, "base64"));
228
+ }
229
+ const binary = atob(input);
230
+ const bytes = new Uint8Array(binary.length);
231
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
232
+ return bytes;
233
+ } catch {
234
+ return base64URLDecode(input);
235
+ }
236
+ }
237
+ };
238
+
239
+ // src/chains/stellar/VeridexStellarWalletModule.ts
240
+ var import_browser = require("@simplewebauthn/browser");
241
+ var VERIDEX_PASSKEY_ID = "veridex-passkey";
242
+ var VeridexStellarWalletModule = class {
243
+ moduleType = "HOT_WALLET" /* HOT_WALLET */;
244
+ productId = VERIDEX_PASSKEY_ID;
245
+ productName;
246
+ productUrl;
247
+ productIcon;
248
+ signer;
249
+ constructor(opts) {
250
+ this.signer = new StellarPasskeySigner({
251
+ passkey: opts.passkey,
252
+ credential: opts.credential,
253
+ config: opts.config
254
+ });
255
+ this.productName = opts.productName ?? "Veridex Passkey";
256
+ this.productUrl = opts.productUrl ?? "https://veridex.network";
257
+ this.productIcon = opts.productIcon ?? "https://veridex.network/icons/passkey-256.png";
258
+ }
259
+ async isAvailable() {
260
+ try {
261
+ return (0, import_browser.browserSupportsWebAuthn)();
262
+ } catch {
263
+ return false;
264
+ }
265
+ }
266
+ async isPlatformWrapper() {
267
+ return false;
268
+ }
269
+ async getAddress(params) {
270
+ return this.signer.getAddress(params?.skipRequestAccess);
271
+ }
272
+ async signTransaction(xdr, opts) {
273
+ return this.signer.signTransaction(xdr, {
274
+ networkPassphrase: opts?.networkPassphrase,
275
+ address: opts?.address
276
+ });
277
+ }
278
+ async signAuthEntry(authEntry, opts) {
279
+ return this.signer.signAuthEntry(authEntry, {
280
+ networkPassphrase: opts?.networkPassphrase,
281
+ address: opts?.address
282
+ });
283
+ }
284
+ async signMessage(message, opts) {
285
+ return this.signer.signMessage(message, {
286
+ networkPassphrase: opts?.networkPassphrase,
287
+ address: opts?.address
288
+ });
289
+ }
290
+ };
291
+ // Annotate the CommonJS export names for ESM import in node:
292
+ 0 && (module.exports = {
293
+ StellarModuleType,
294
+ StellarNetworks,
295
+ StellarPasskeySigner,
296
+ VERIDEX_PASSKEY_ID,
297
+ VeridexStellarWalletModule,
298
+ deriveSmartAccountId
299
+ });
300
+ //# sourceMappingURL=index.js.map