@bandeira-tech/b3nd-web 0.2.3 → 0.2.5

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.
@@ -585,6 +585,8 @@ async function createSignedSymmetricMessage(data, signers, keyHex) {
585
585
  }
586
586
 
587
587
  export {
588
+ encodeHex,
589
+ decodeHex,
588
590
  IdentityKey,
589
591
  PublicEncryptionKey,
590
592
  SecretEncryptionKey,
@@ -0,0 +1,25 @@
1
+ import { S as Schema, N as NodeProtocolInterface, g as WriteResult, R as ReadResult, b as ListOptions, c as ListResult, H as HealthStatus, D as DeleteResult } from '../../types-oQCx3U-_.js';
2
+
3
+ type MemoryClientStorageNode<T> = {
4
+ value?: T;
5
+ children?: Map<string, MemoryClientStorageNode<unknown>>;
6
+ };
7
+ type MemoryClientStorage = Map<string, MemoryClientStorageNode<unknown>>;
8
+ interface MemoryClientConfig {
9
+ schema: Schema;
10
+ storage?: MemoryClientStorage;
11
+ }
12
+ declare class MemoryClient implements NodeProtocolInterface {
13
+ protected storage: MemoryClientStorage;
14
+ protected schema: Schema;
15
+ constructor(config: MemoryClientConfig);
16
+ write<T = unknown>(uri: string, payload: T): Promise<WriteResult<T>>;
17
+ read<T>(uri: string): Promise<ReadResult<T>>;
18
+ list(uri: string, options?: ListOptions): Promise<ListResult>;
19
+ health(): Promise<HealthStatus>;
20
+ getSchema(): Promise<string[]>;
21
+ cleanup(): Promise<void>;
22
+ delete(uri: string): Promise<DeleteResult>;
23
+ }
24
+
25
+ export { MemoryClient, type MemoryClientConfig };
@@ -0,0 +1,203 @@
1
+ import "../../chunk-MLKGABMK.js";
2
+
3
+ // clients/memory/mod.ts
4
+ function target(uri, schema, storage) {
5
+ const url = URL.parse(uri);
6
+ const program = `${url.protocol}//${url.hostname}`;
7
+ if (!schema[program]) {
8
+ return { success: false, error: "Program not found" };
9
+ }
10
+ const node = storage.get(program);
11
+ if (!node) {
12
+ return { success: false, error: "Storage not initialized for program" };
13
+ }
14
+ const parts = url.pathname.substring(1).split("/");
15
+ return {
16
+ success: true,
17
+ program,
18
+ path: url.pathname,
19
+ node,
20
+ parts
21
+ };
22
+ }
23
+ var MemoryClient = class {
24
+ constructor(config) {
25
+ this.schema = config.schema;
26
+ this.storage = config.storage || /* @__PURE__ */ new Map();
27
+ this.cleanup();
28
+ }
29
+ async write(uri, payload) {
30
+ const result = target(uri, this.schema, this.storage);
31
+ if (!result.success) {
32
+ return result;
33
+ }
34
+ const { program, node, parts } = result;
35
+ const validator = this.schema[program];
36
+ const validation = await validator({ uri, value: payload, read: this.read.bind(this) });
37
+ if (!validation.valid) {
38
+ return {
39
+ success: false,
40
+ error: validation.error || "Validation failed"
41
+ };
42
+ }
43
+ const record = {
44
+ ts: Date.now(),
45
+ data: payload
46
+ };
47
+ let prev = node;
48
+ parts.filter(Boolean).forEach((ns) => {
49
+ if (!prev.children) prev.children = /* @__PURE__ */ new Map();
50
+ if (!prev.children.get(ns)) {
51
+ const newnode = {};
52
+ prev.children.set(ns, newnode);
53
+ prev = newnode;
54
+ } else {
55
+ prev = prev.children.get(ns);
56
+ }
57
+ });
58
+ prev.value = record;
59
+ return {
60
+ success: true,
61
+ record
62
+ };
63
+ }
64
+ read(uri) {
65
+ const result = target(uri, this.schema, this.storage);
66
+ if (!result.success) {
67
+ return Promise.resolve(result);
68
+ }
69
+ const { node, parts } = result;
70
+ let current = node;
71
+ for (const part of parts.filter(Boolean)) {
72
+ current = current?.children?.get(part);
73
+ if (!current) {
74
+ return Promise.resolve({
75
+ success: false,
76
+ error: `Path not found: ${part}`
77
+ });
78
+ }
79
+ }
80
+ if (!current.value) {
81
+ return Promise.resolve({
82
+ success: false,
83
+ error: "Not found"
84
+ });
85
+ }
86
+ return Promise.resolve({
87
+ success: true,
88
+ record: current.value
89
+ });
90
+ }
91
+ list(uri, options) {
92
+ const result = target(uri, this.schema, this.storage);
93
+ if (!result.success) {
94
+ return Promise.resolve(result);
95
+ }
96
+ const { node, parts, program, path } = result;
97
+ let current = node;
98
+ const filteredParts = parts.filter(Boolean);
99
+ for (const part of filteredParts) {
100
+ current = current?.children?.get(part);
101
+ if (!current) {
102
+ return Promise.resolve({
103
+ success: false,
104
+ error: `Path not found: ${part}`
105
+ });
106
+ }
107
+ }
108
+ if (!current.children?.size) {
109
+ return Promise.resolve({
110
+ success: true,
111
+ data: [],
112
+ pagination: {
113
+ page: options?.page ?? 1,
114
+ limit: options?.limit ?? 50,
115
+ total: 0
116
+ }
117
+ });
118
+ }
119
+ let items = Array.from(current.children.entries()).map(([key, child]) => ({
120
+ uri: path.endsWith("/") ? `${program}://${path}${key}` : `${program}://${path}/${key}`,
121
+ type: child.value ? "file" : "directory"
122
+ }));
123
+ if (options?.pattern) {
124
+ const regex = new RegExp(options.pattern);
125
+ items = items.filter((item) => regex.test(item.uri));
126
+ }
127
+ if (options?.sortBy === "name") {
128
+ items.sort((a, b) => a.uri.localeCompare(b.uri));
129
+ } else if (options?.sortBy === "timestamp") {
130
+ items.sort((a, b) => {
131
+ const aTs = current.children?.get(a.uri.split("/").pop())?.value?.ts ?? 0;
132
+ const bTs = current.children?.get(b.uri.split("/").pop())?.value?.ts ?? 0;
133
+ return aTs - bTs;
134
+ });
135
+ }
136
+ if (options?.sortOrder === "desc") {
137
+ items.reverse();
138
+ }
139
+ const page = options?.page ?? 1;
140
+ const limit = options?.limit ?? 50;
141
+ const offset = (page - 1) * limit;
142
+ const paginated = items.slice(offset, offset + limit);
143
+ return Promise.resolve({
144
+ success: true,
145
+ data: paginated,
146
+ pagination: { page, limit, total: items.length }
147
+ });
148
+ }
149
+ health() {
150
+ return Promise.resolve({
151
+ status: "healthy"
152
+ });
153
+ }
154
+ getSchema() {
155
+ return Promise.resolve(Object.keys(this.schema));
156
+ }
157
+ cleanup() {
158
+ Object.keys(this.schema).forEach((program) => {
159
+ if (!this.storage.get(program)) {
160
+ this.storage.set(program, { children: /* @__PURE__ */ new Map() });
161
+ }
162
+ });
163
+ return Promise.resolve();
164
+ }
165
+ delete(uri) {
166
+ const result = target(uri, this.schema, this.storage);
167
+ if (!result.success) {
168
+ return Promise.resolve(result);
169
+ }
170
+ const { node, parts } = result;
171
+ const filteredParts = parts.filter(Boolean);
172
+ if (filteredParts.length === 0) {
173
+ return Promise.resolve({
174
+ success: false,
175
+ error: "Cannot delete root path"
176
+ });
177
+ }
178
+ let current = node;
179
+ const lastPart = filteredParts.pop();
180
+ for (const part of filteredParts) {
181
+ current = current?.children?.get(part);
182
+ if (!current) {
183
+ return Promise.resolve({
184
+ success: false,
185
+ error: `Path not found: ${part}`
186
+ });
187
+ }
188
+ }
189
+ if (!current.children?.has(lastPart)) {
190
+ return Promise.resolve({
191
+ success: false,
192
+ error: `Item not found: ${lastPart}`
193
+ });
194
+ }
195
+ current.children.delete(lastPart);
196
+ return Promise.resolve({
197
+ success: true
198
+ });
199
+ }
200
+ };
201
+ export {
202
+ MemoryClient
203
+ };
@@ -0,0 +1,275 @@
1
+ import { Hono } from 'hono';
2
+ import { N as NodeProtocolInterface } from './types-oQCx3U-_.js';
3
+
4
+ /**
5
+ * Wallet Server Dependency Injection Interfaces
6
+ *
7
+ * These interfaces abstract runtime-specific operations, enabling the wallet
8
+ * server to run in Deno, Node.js, or browsers through dependency injection.
9
+ */
10
+ /**
11
+ * File storage abstraction - replaces Deno.readTextFile/writeTextFile
12
+ */
13
+ interface FileStorage {
14
+ readTextFile(path: string): Promise<string>;
15
+ writeTextFile(path: string, content: string): Promise<void>;
16
+ exists(path: string): Promise<boolean>;
17
+ }
18
+ /**
19
+ * Environment abstraction - replaces Deno.env.get()
20
+ */
21
+ interface Environment {
22
+ get(key: string): string | undefined;
23
+ }
24
+ /**
25
+ * Logger abstraction - replaces console.log/warn/error
26
+ */
27
+ interface Logger {
28
+ log(...args: unknown[]): void;
29
+ warn(...args: unknown[]): void;
30
+ error(...args: unknown[]): void;
31
+ }
32
+ /**
33
+ * HTTP fetch abstraction - allows custom fetch implementations
34
+ */
35
+ type HttpFetch = (url: string, init?: RequestInit) => Promise<Response>;
36
+ /**
37
+ * Default console logger implementation
38
+ */
39
+ declare const defaultLogger: Logger;
40
+ /**
41
+ * In-memory file storage implementation (for testing/browser)
42
+ */
43
+ declare class MemoryFileStorage implements FileStorage {
44
+ private storage;
45
+ readTextFile(path: string): Promise<string>;
46
+ writeTextFile(path: string, content: string): Promise<void>;
47
+ exists(path: string): Promise<boolean>;
48
+ }
49
+ /**
50
+ * Environment from config object (for testing/browser)
51
+ */
52
+ declare class ConfigEnvironment implements Environment {
53
+ private config;
54
+ constructor(config?: Record<string, string>);
55
+ get(key: string): string | undefined;
56
+ }
57
+
58
+ /**
59
+ * Wallet Server Types
60
+ *
61
+ * Type definitions for the universal wallet server SDK.
62
+ */
63
+
64
+ /**
65
+ * Server key pair configuration
66
+ */
67
+ interface ServerKeyPair {
68
+ privateKeyPem: string;
69
+ publicKeyHex: string;
70
+ }
71
+ /**
72
+ * Server keys configuration (identity + encryption)
73
+ */
74
+ interface ServerKeys {
75
+ identityKey: ServerKeyPair;
76
+ encryptionKey: ServerKeyPair;
77
+ }
78
+ /**
79
+ * App backend configuration for bootstrap
80
+ */
81
+ interface AppBackendConfig {
82
+ url: string;
83
+ apiBasePath?: string;
84
+ }
85
+ /**
86
+ * Dependency injection configuration
87
+ */
88
+ interface WalletServerDeps {
89
+ /** File storage for bootstrap state persistence */
90
+ storage?: FileStorage;
91
+ /** Logger for output */
92
+ logger?: Logger;
93
+ /** Custom fetch implementation */
94
+ fetch?: HttpFetch;
95
+ /** Pre-configured credential client (alternative to credentialNodeUrl) */
96
+ credentialClient?: NodeProtocolInterface;
97
+ /** Pre-configured proxy client (alternative to proxyNodeUrl) */
98
+ proxyClient?: NodeProtocolInterface;
99
+ }
100
+ /**
101
+ * Wallet server configuration
102
+ */
103
+ interface WalletServerConfig {
104
+ /** Server identity and encryption keys */
105
+ serverKeys: ServerKeys;
106
+ /** JWT secret for token signing (must be 32+ characters) */
107
+ jwtSecret: string;
108
+ /** JWT expiration in seconds (default: 86400 = 24 hours) */
109
+ jwtExpirationSeconds?: number;
110
+ /** URL of the credential backend node */
111
+ credentialNodeUrl?: string;
112
+ /** URL of the proxy backend node */
113
+ proxyNodeUrl?: string;
114
+ /** CORS allowed origins (default: ["*"]) */
115
+ allowedOrigins?: string[];
116
+ /** App backend for bootstrap (optional) */
117
+ appBackend?: AppBackendConfig;
118
+ /** Password reset token TTL in seconds (default: 3600 = 1 hour) */
119
+ passwordResetTokenTtlSeconds?: number;
120
+ /** Google OAuth client ID (optional, enables Google auth) */
121
+ googleClientId?: string;
122
+ /** Path for bootstrap state file (optional) */
123
+ bootstrapStatePath?: string;
124
+ /** Dependency injection */
125
+ deps?: WalletServerDeps;
126
+ }
127
+ /**
128
+ * Resolved configuration with defaults applied
129
+ */
130
+ interface ResolvedWalletServerConfig {
131
+ serverKeys: ServerKeys;
132
+ jwtSecret: string;
133
+ jwtExpirationSeconds: number;
134
+ allowedOrigins: string[];
135
+ passwordResetTokenTtlSeconds: number;
136
+ googleClientId: string | null;
137
+ bootstrapStatePath: string | null;
138
+ appBackend: AppBackendConfig | null;
139
+ }
140
+ /**
141
+ * User keys structure
142
+ */
143
+ interface UserKeys {
144
+ accountKey: ServerKeyPair;
145
+ encryptionKey: ServerKeyPair;
146
+ }
147
+ /**
148
+ * Proxy write request
149
+ */
150
+ interface ProxyWriteRequest {
151
+ uri: string;
152
+ data: unknown;
153
+ encrypt?: boolean;
154
+ }
155
+ /**
156
+ * Proxy write response
157
+ */
158
+ interface ProxyWriteResponse {
159
+ success: boolean;
160
+ resolvedUri?: string;
161
+ error?: string;
162
+ record?: {
163
+ data: unknown;
164
+ ts: number;
165
+ };
166
+ }
167
+ /**
168
+ * Proxy read response
169
+ */
170
+ interface ProxyReadResponse {
171
+ success: boolean;
172
+ error?: string;
173
+ record?: {
174
+ data: unknown;
175
+ ts: number;
176
+ };
177
+ decrypted?: unknown;
178
+ }
179
+ /**
180
+ * Auth session response
181
+ */
182
+ interface AuthSessionResponse {
183
+ success: boolean;
184
+ username: string;
185
+ token: string;
186
+ expiresIn: number;
187
+ error?: string;
188
+ email?: string;
189
+ name?: string;
190
+ picture?: string;
191
+ }
192
+ /**
193
+ * Public keys response
194
+ */
195
+ interface PublicKeysResponse {
196
+ success: boolean;
197
+ accountPublicKeyHex?: string;
198
+ encryptionPublicKeyHex?: string;
199
+ error?: string;
200
+ }
201
+ /**
202
+ * Health response
203
+ */
204
+ interface HealthResponse {
205
+ success: boolean;
206
+ status: string;
207
+ server: string;
208
+ timestamp: string;
209
+ }
210
+ /**
211
+ * Server keys response
212
+ */
213
+ interface ServerKeysResponse {
214
+ success: boolean;
215
+ identityPublicKeyHex: string;
216
+ encryptionPublicKeyHex: string;
217
+ }
218
+
219
+ /**
220
+ * Wallet Server Core
221
+ *
222
+ * Universal wallet server that works in Deno, Node.js, and browsers.
223
+ * Uses dependency injection for all runtime-specific operations.
224
+ */
225
+
226
+ interface BootstrapState {
227
+ appKey: string;
228
+ createdAt: string;
229
+ appServerUrl: string;
230
+ apiBasePath: string;
231
+ }
232
+ /**
233
+ * Wallet Server Core
234
+ *
235
+ * Creates a portable Hono application that can be served by any runtime.
236
+ */
237
+ declare class WalletServerCore {
238
+ private config;
239
+ private serverKeys;
240
+ private credentialClient;
241
+ private proxyClient;
242
+ private app;
243
+ private logger;
244
+ private storage;
245
+ private fetchImpl;
246
+ constructor(userConfig: WalletServerConfig);
247
+ private validateConfig;
248
+ private applyDefaults;
249
+ /**
250
+ * Get the Hono app instance
251
+ */
252
+ getApp(): Hono;
253
+ /**
254
+ * Get the fetch handler for use with various runtimes
255
+ */
256
+ getFetchHandler(): (request: Request) => Response | Promise<Response>;
257
+ /**
258
+ * Get server public keys
259
+ */
260
+ getServerKeys(): {
261
+ identityPublicKeyHex: string;
262
+ encryptionPublicKeyHex: string;
263
+ };
264
+ /**
265
+ * Bootstrap wallet app registration (optional)
266
+ */
267
+ bootstrap(): Promise<BootstrapState | null>;
268
+ private normalizeApiBasePath;
269
+ private readBootstrapState;
270
+ private writeBootstrapState;
271
+ private sessionExists;
272
+ private createApp;
273
+ }
274
+
275
+ export { type AppBackendConfig as A, ConfigEnvironment as C, type Environment as E, type FileStorage as F, type HttpFetch as H, type Logger as L, MemoryFileStorage as M, type ProxyWriteRequest as P, type ResolvedWalletServerConfig as R, type ServerKeys as S, type UserKeys as U, WalletServerCore as W, type ProxyWriteResponse as a, type ProxyReadResponse as b, type WalletServerConfig as c, type WalletServerDeps as d, type ServerKeyPair as e, type AuthSessionResponse as f, type PublicKeysResponse as g, type HealthResponse as h, type ServerKeysResponse as i, defaultLogger as j };
@@ -1 +1 @@
1
- export { A as AuthenticatedMessage, a as EncryptedPayload, E as EncryptionKeyPair, I as IdentityKey, K as KeyPair, d as PrivateEncryptionKey, P as PublicEncryptionKey, c as SecretEncryptionKey, S as SignedEncryptedMessage, b as SignedSymmetricMessage, k as createAuthenticatedMessage, l as createAuthenticatedMessageWithHex, w as createSignedEncryptedMessage, B as createSignedSymmetricMessage, i as decrypt, z as decryptSymmetric, j as decryptWithHex, n as deriveKeyFromSeed, h as encrypt, y as encryptSymmetric, r as exportPrivateKeyPem, e as generateEncryptionKeyPair, o as generateNonce, q as generateRandomData, g as generateSigningKeyPair, p as pemToCryptoKey, s as sign, t as signPayload, f as signWithHex, v as verify, x as verifyAndDecryptMessage, u as verifyPayload } from '../mod-D02790g_.js';
1
+ export { A as AuthenticatedMessage, E as EncryptedPayload, a as EncryptionKeyPair, I as IdentityKey, K as KeyPair, d as PrivateEncryptionKey, P as PublicEncryptionKey, c as SecretEncryptionKey, S as SignedEncryptedMessage, b as SignedSymmetricMessage, k as createAuthenticatedMessage, l as createAuthenticatedMessageWithHex, w as createSignedEncryptedMessage, B as createSignedSymmetricMessage, i as decrypt, z as decryptSymmetric, j as decryptWithHex, n as deriveKeyFromSeed, h as encrypt, y as encryptSymmetric, r as exportPrivateKeyPem, e as generateEncryptionKeyPair, o as generateNonce, q as generateRandomData, g as generateSigningKeyPair, p as pemToCryptoKey, s as sign, t as signPayload, f as signWithHex, v as verify, x as verifyAndDecryptMessage, u as verifyPayload } from '../mod-CII9wqu2.js';
@@ -25,7 +25,7 @@ import {
25
25
  verify,
26
26
  verifyAndDecryptMessage,
27
27
  verifyPayload
28
- } from "../chunk-K3ZSSVHR.js";
28
+ } from "../chunk-JN75UL5C.js";
29
29
  import "../chunk-MLKGABMK.js";
30
30
  export {
31
31
  IdentityKey,
@@ -238,4 +238,4 @@ declare namespace mod {
238
238
  export { type mod_AuthenticatedMessage as AuthenticatedMessage, type mod_EncryptedPayload as EncryptedPayload, type mod_EncryptionKeyPair as EncryptionKeyPair, mod_IdentityKey as IdentityKey, type mod_KeyPair as KeyPair, mod_PrivateEncryptionKey as PrivateEncryptionKey, mod_PublicEncryptionKey as PublicEncryptionKey, mod_SecretEncryptionKey as SecretEncryptionKey, type mod_SignedEncryptedMessage as SignedEncryptedMessage, type mod_SignedSymmetricMessage as SignedSymmetricMessage, mod_createAuthenticatedMessage as createAuthenticatedMessage, mod_createAuthenticatedMessageWithHex as createAuthenticatedMessageWithHex, mod_createSignedEncryptedMessage as createSignedEncryptedMessage, mod_createSignedSymmetricMessage as createSignedSymmetricMessage, mod_decrypt as decrypt, mod_decryptSymmetric as decryptSymmetric, mod_decryptWithHex as decryptWithHex, mod_deriveKeyFromSeed as deriveKeyFromSeed, mod_encrypt as encrypt, mod_encryptSymmetric as encryptSymmetric, mod_exportPrivateKeyPem as exportPrivateKeyPem, mod_generateEncryptionKeyPair as generateEncryptionKeyPair, mod_generateNonce as generateNonce, mod_generateRandomData as generateRandomData, mod_generateSigningKeyPair as generateSigningKeyPair, mod_pemToCryptoKey as pemToCryptoKey, mod_sign as sign, mod_signPayload as signPayload, mod_signWithHex as signWithHex, mod_verify as verify, mod_verifyAndDecryptMessage as verifyAndDecryptMessage, mod_verifyPayload as verifyPayload };
239
239
  }
240
240
 
241
- export { type AuthenticatedMessage as A, createSignedSymmetricMessage as B, type EncryptionKeyPair as E, IdentityKey as I, type KeyPair as K, PublicEncryptionKey as P, type SignedEncryptedMessage as S, type EncryptedPayload as a, type SignedSymmetricMessage as b, SecretEncryptionKey as c, PrivateEncryptionKey as d, generateEncryptionKeyPair as e, signWithHex as f, generateSigningKeyPair as g, encrypt as h, decrypt as i, decryptWithHex as j, createAuthenticatedMessage as k, createAuthenticatedMessageWithHex as l, mod as m, deriveKeyFromSeed as n, generateNonce as o, pemToCryptoKey as p, generateRandomData as q, exportPrivateKeyPem as r, sign as s, signPayload as t, verifyPayload as u, verify as v, createSignedEncryptedMessage as w, verifyAndDecryptMessage as x, encryptSymmetric as y, decryptSymmetric as z };
241
+ export { type AuthenticatedMessage as A, createSignedSymmetricMessage as B, type EncryptedPayload as E, IdentityKey as I, type KeyPair as K, PublicEncryptionKey as P, type SignedEncryptedMessage as S, type EncryptionKeyPair as a, type SignedSymmetricMessage as b, SecretEncryptionKey as c, PrivateEncryptionKey as d, generateEncryptionKeyPair as e, signWithHex as f, generateSigningKeyPair as g, encrypt as h, decrypt as i, decryptWithHex as j, createAuthenticatedMessage as k, createAuthenticatedMessageWithHex as l, mod as m, deriveKeyFromSeed as n, generateNonce as o, pemToCryptoKey as p, generateRandomData as q, exportPrivateKeyPem as r, sign as s, signPayload as t, verifyPayload as u, verify as v, createSignedEncryptedMessage as w, verifyAndDecryptMessage as x, encryptSymmetric as y, decryptSymmetric as z };
@@ -4,4 +4,4 @@ export { WebSocketClient } from '../clients/websocket/mod.js';
4
4
  export { LocalStorageClient } from '../clients/local-storage/mod.js';
5
5
  export { WalletClient } from '../wallet/mod.js';
6
6
  export { AppsClient } from '../apps/mod.js';
7
- export { m as encrypt } from '../mod-D02790g_.js';
7
+ export { m as encrypt } from '../mod-CII9wqu2.js';
@@ -1,6 +1,12 @@
1
+ import {
2
+ WebSocketClient
3
+ } from "../chunk-T43IWAQK.js";
4
+ import {
5
+ AppsClient
6
+ } from "../chunk-VAZUCGED.js";
1
7
  import {
2
8
  mod_exports
3
- } from "../chunk-K3ZSSVHR.js";
9
+ } from "../chunk-JN75UL5C.js";
4
10
  import {
5
11
  WalletClient
6
12
  } from "../chunk-S7NJA6B6.js";
@@ -10,12 +16,6 @@ import {
10
16
  import {
11
17
  LocalStorageClient
12
18
  } from "../chunk-7U5JDFQW.js";
13
- import {
14
- WebSocketClient
15
- } from "../chunk-T43IWAQK.js";
16
- import {
17
- AppsClient
18
- } from "../chunk-VAZUCGED.js";
19
19
  import "../chunk-MLKGABMK.js";
20
20
  export {
21
21
  AppsClient,
@@ -0,0 +1,76 @@
1
+ import { F as FileStorage, S as ServerKeys, W as WalletServerCore } from '../../core-CgxQpSVM.js';
2
+ export { C as BrowserEnvironment, M as BrowserMemoryStorage } from '../../core-CgxQpSVM.js';
3
+ import 'hono';
4
+ import '../../types-oQCx3U-_.js';
5
+
6
+ /**
7
+ * Browser Adapter for Wallet Server
8
+ *
9
+ * Provides browser-compatible implementations for running a wallet server
10
+ * in simulation/demo mode using in-memory or localStorage storage.
11
+ */
12
+
13
+ /**
14
+ * Browser localStorage-backed file storage
15
+ */
16
+ declare class BrowserLocalStorageFileStorage implements FileStorage {
17
+ private keyPrefix;
18
+ constructor(keyPrefix?: string);
19
+ readTextFile(path: string): Promise<string>;
20
+ writeTextFile(path: string, content: string): Promise<void>;
21
+ exists(path: string): Promise<boolean>;
22
+ }
23
+
24
+ /**
25
+ * Options for creating a browser wallet server
26
+ */
27
+ interface BrowserWalletServerOptions {
28
+ /** Server keys (required) */
29
+ serverKeys: ServerKeys;
30
+ /** JWT secret (required, must be 32+ chars) */
31
+ jwtSecret: string;
32
+ /** Use localStorage for persistence (default: false = in-memory) */
33
+ useLocalStorage?: boolean;
34
+ /** Key prefix for localStorage (default: "b3nd-wallet-") */
35
+ localStoragePrefix?: string;
36
+ /** JWT expiration in seconds (default: 86400) */
37
+ jwtExpirationSeconds?: number;
38
+ /** Allowed origins (default: ["*"]) */
39
+ allowedOrigins?: string[];
40
+ /** Google OAuth client ID (optional) */
41
+ googleClientId?: string;
42
+ }
43
+ /**
44
+ * Create a browser-compatible wallet server for simulation/testing
45
+ *
46
+ * This creates a fully functional wallet server that runs in the browser
47
+ * using LocalStorageClient as the backend. Useful for:
48
+ * - Demo applications
49
+ * - Testing without a real backend
50
+ * - Offline-first applications
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * import { createBrowserWalletServer, generateBrowserServerKeys } from "@b3nd/sdk/wallet-server/adapters/browser";
55
+ *
56
+ * const serverKeys = await generateBrowserServerKeys();
57
+ * const server = createBrowserWalletServer({
58
+ * serverKeys,
59
+ * jwtSecret: "your-32-character-minimum-secret!!",
60
+ * useLocalStorage: true,
61
+ * });
62
+ *
63
+ * // Use with fetch API
64
+ * const response = await server.getFetchHandler()(new Request("/api/v1/health"));
65
+ * ```
66
+ */
67
+ declare function createBrowserWalletServer(options: BrowserWalletServerOptions): WalletServerCore;
68
+ /**
69
+ * Generate server keys in the browser
70
+ *
71
+ * Creates Ed25519 (identity) and X25519 (encryption) key pairs
72
+ * using the Web Crypto API.
73
+ */
74
+ declare function generateBrowserServerKeys(): Promise<ServerKeys>;
75
+
76
+ export { BrowserLocalStorageFileStorage, type BrowserWalletServerOptions, createBrowserWalletServer, generateBrowserServerKeys };