@bandeira-tech/b3nd-web 0.2.5 → 0.2.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/dist/{chunk-S7NJA6B6.js → chunk-FVLXYKYS.js} +372 -1
- package/dist/chunk-GIMIWVPX.js +202 -0
- package/dist/client-B0Ekm99R.d.ts +354 -0
- package/dist/clients/memory/mod.d.ts +1 -1
- package/dist/clients/memory/mod.js +3 -199
- package/dist/src/mod.web.d.ts +1 -1
- package/dist/src/mod.web.js +5 -3
- package/dist/wallet/mod.d.ts +73 -308
- package/dist/wallet/mod.js +11 -3
- package/package.json +1 -1
package/dist/wallet/mod.d.ts
CHANGED
|
@@ -1,354 +1,119 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Configuration for wallet client
|
|
8
|
-
*/
|
|
9
|
-
interface WalletClientConfig {
|
|
10
|
-
/**
|
|
11
|
-
* Wallet server URL (e.g., "http://localhost:3001")
|
|
12
|
-
*/
|
|
13
|
-
walletServerUrl: string;
|
|
14
|
-
/**
|
|
15
|
-
* API base path prefix (e.g., "/api/v1"). Must be provided explicitly.
|
|
16
|
-
*/
|
|
17
|
-
apiBasePath: string;
|
|
18
|
-
/**
|
|
19
|
-
* Optional fetch implementation (for custom HTTP handling)
|
|
20
|
-
*/
|
|
21
|
-
fetch?: typeof fetch;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* User credentials for authentication
|
|
25
|
-
*/
|
|
26
|
-
interface UserCredentials {
|
|
27
|
-
username: string;
|
|
28
|
-
password: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Authenticated session with JWT token
|
|
32
|
-
*/
|
|
33
|
-
interface AuthSession {
|
|
34
|
-
username: string;
|
|
35
|
-
token: string;
|
|
36
|
-
expiresIn: number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* User's public keys
|
|
40
|
-
*/
|
|
41
|
-
interface UserPublicKeys {
|
|
42
|
-
accountPublicKeyHex: string;
|
|
43
|
-
encryptionPublicKeyHex: string;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Password reset token
|
|
47
|
-
*/
|
|
48
|
-
interface PasswordResetToken {
|
|
49
|
-
resetToken: string;
|
|
50
|
-
expiresIn: number;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Write proxy request
|
|
54
|
-
*/
|
|
55
|
-
interface ProxyWriteRequest {
|
|
56
|
-
uri: string;
|
|
57
|
-
data: unknown;
|
|
58
|
-
encrypt?: boolean;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Write proxy response
|
|
62
|
-
*/
|
|
63
|
-
interface ProxyWriteResponse {
|
|
64
|
-
success: boolean;
|
|
65
|
-
uri: string;
|
|
66
|
-
resolvedUri?: string;
|
|
67
|
-
data: unknown;
|
|
68
|
-
record?: {
|
|
69
|
-
data: unknown;
|
|
70
|
-
ts: number;
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Read proxy request
|
|
75
|
-
*/
|
|
76
|
-
interface ProxyReadRequest {
|
|
77
|
-
uri: string;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Read proxy response
|
|
81
|
-
*/
|
|
82
|
-
interface ProxyReadResponse {
|
|
83
|
-
success: boolean;
|
|
84
|
-
uri: string;
|
|
85
|
-
record?: {
|
|
86
|
-
data: unknown;
|
|
87
|
-
ts: number;
|
|
88
|
-
};
|
|
89
|
-
decrypted?: unknown;
|
|
90
|
-
error?: string;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* API response wrapper
|
|
94
|
-
*/
|
|
95
|
-
interface ApiResponse {
|
|
96
|
-
success: boolean;
|
|
97
|
-
error?: string;
|
|
98
|
-
[key: string]: unknown;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Signup response
|
|
102
|
-
*/
|
|
103
|
-
interface SignupResponse extends ApiResponse {
|
|
104
|
-
username: string;
|
|
105
|
-
token: string;
|
|
106
|
-
expiresIn: number;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Login response
|
|
110
|
-
*/
|
|
111
|
-
interface LoginResponse extends ApiResponse {
|
|
112
|
-
username: string;
|
|
113
|
-
token: string;
|
|
114
|
-
expiresIn: number;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Public keys response
|
|
118
|
-
*/
|
|
119
|
-
interface PublicKeysResponse extends ApiResponse {
|
|
120
|
-
accountPublicKeyHex: string;
|
|
121
|
-
encryptionPublicKeyHex: string;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Change password response
|
|
125
|
-
*/
|
|
126
|
-
interface ChangePasswordResponse extends ApiResponse {
|
|
127
|
-
message: string;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Request password reset response
|
|
131
|
-
*/
|
|
132
|
-
interface RequestPasswordResetResponse extends ApiResponse {
|
|
133
|
-
message: string;
|
|
134
|
-
resetToken: string;
|
|
135
|
-
expiresIn: number;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Reset password response
|
|
139
|
-
*/
|
|
140
|
-
interface ResetPasswordResponse extends ApiResponse {
|
|
141
|
-
message: string;
|
|
142
|
-
username: string;
|
|
143
|
-
token: string;
|
|
144
|
-
expiresIn: number;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Health check response
|
|
148
|
-
*/
|
|
149
|
-
interface HealthResponse extends ApiResponse {
|
|
150
|
-
status: string;
|
|
151
|
-
server: string;
|
|
152
|
-
timestamp: string;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Google OAuth session (extended AuthSession with Google profile info)
|
|
156
|
-
*/
|
|
157
|
-
interface GoogleAuthSession extends AuthSession {
|
|
158
|
-
email: string;
|
|
159
|
-
name?: string;
|
|
160
|
-
picture?: string;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Google signup response
|
|
164
|
-
*/
|
|
165
|
-
interface GoogleSignupResponse extends ApiResponse {
|
|
166
|
-
username: string;
|
|
167
|
-
email: string;
|
|
168
|
-
name?: string;
|
|
169
|
-
picture?: string;
|
|
170
|
-
token: string;
|
|
171
|
-
expiresIn: number;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Google login response
|
|
175
|
-
*/
|
|
176
|
-
interface GoogleLoginResponse extends ApiResponse {
|
|
177
|
-
username: string;
|
|
178
|
-
email: string;
|
|
179
|
-
name?: string;
|
|
180
|
-
picture?: string;
|
|
181
|
-
token: string;
|
|
182
|
-
expiresIn: number;
|
|
183
|
-
}
|
|
1
|
+
import { A as AuthSession, H as HealthResponse, U as UserCredentials, P as PasswordResetToken, a as UserPublicKeys, b as ProxyWriteRequest, c as ProxyWriteResponse, d as ProxyReadRequest, e as ProxyReadResponse, G as GoogleAuthSession } from '../client-B0Ekm99R.js';
|
|
2
|
+
export { g as ApiResponse, C as ChangePasswordResponse, k as GoogleLoginResponse, j as GoogleSignupResponse, L as LoginResponse, h as PublicKeysResponse, R as RequestPasswordResetResponse, i as ResetPasswordResponse, S as SignupResponse, W as WalletClient, f as WalletClientConfig } from '../client-B0Ekm99R.js';
|
|
3
|
+
import { S as ServerKeys, W as WalletServerCore } from '../core-CgxQpSVM.js';
|
|
4
|
+
import { MemoryClient } from '../clients/memory/mod.js';
|
|
5
|
+
import 'hono';
|
|
6
|
+
import '../types-oQCx3U-_.js';
|
|
184
7
|
|
|
185
8
|
/**
|
|
186
|
-
*
|
|
9
|
+
* Memory Wallet Client
|
|
187
10
|
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* Works in both Deno and browser environments.
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* B3nd Wallet Client
|
|
11
|
+
* In-memory implementation of the wallet client for testing.
|
|
12
|
+
* Embeds WalletServerCore with MemoryClient storage - no HTTP required.
|
|
196
13
|
*
|
|
197
|
-
*
|
|
198
|
-
* for user management, key retrieval, and proxied writes.
|
|
14
|
+
* Same interface as WalletClient, so you can swap between them:
|
|
199
15
|
*
|
|
200
16
|
* @example
|
|
201
17
|
* ```typescript
|
|
18
|
+
* // Production
|
|
202
19
|
* const wallet = new WalletClient({
|
|
203
|
-
* walletServerUrl: "http://localhost:
|
|
204
|
-
* apiBasePath: "/api/v1"
|
|
20
|
+
* walletServerUrl: "http://localhost:8843",
|
|
21
|
+
* apiBasePath: "/api/v1"
|
|
205
22
|
* });
|
|
206
23
|
*
|
|
207
|
-
* //
|
|
208
|
-
* const
|
|
209
|
-
* username: "alice",
|
|
210
|
-
* password: "secure-password-123"
|
|
211
|
-
* });
|
|
24
|
+
* // Tests
|
|
25
|
+
* const wallet = await MemoryWalletClient.create();
|
|
212
26
|
*
|
|
213
|
-
* //
|
|
214
|
-
* wallet.
|
|
215
|
-
*
|
|
216
|
-
* // Write data through proxy
|
|
217
|
-
* await wallet.proxyWrite({
|
|
218
|
-
* uri: "mutable://data/my-app/profile",
|
|
219
|
-
* data: { name: "Alice" },
|
|
220
|
-
* encrypt: true
|
|
221
|
-
* });
|
|
27
|
+
* // Same API works for both
|
|
28
|
+
* await wallet.signupWithToken(appKey, { username: "alice", password: "secret" });
|
|
222
29
|
* ```
|
|
223
30
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
private apiBasePath;
|
|
227
|
-
private fetchImpl;
|
|
228
|
-
private currentSession;
|
|
229
|
-
constructor(config: WalletClientConfig);
|
|
230
|
-
private buildUrl;
|
|
231
|
-
private buildAppKeyUrl;
|
|
31
|
+
|
|
32
|
+
interface MemoryWalletClientConfig {
|
|
232
33
|
/**
|
|
233
|
-
*
|
|
34
|
+
* Optional server keys. If not provided, keys are auto-generated.
|
|
234
35
|
*/
|
|
235
|
-
|
|
36
|
+
serverKeys?: ServerKeys;
|
|
236
37
|
/**
|
|
237
|
-
*
|
|
38
|
+
* Optional JWT secret. Defaults to a test secret.
|
|
238
39
|
*/
|
|
239
|
-
|
|
40
|
+
jwtSecret?: string;
|
|
240
41
|
/**
|
|
241
|
-
*
|
|
42
|
+
* Optional JWT expiration in seconds. Defaults to 3600 (1 hour).
|
|
242
43
|
*/
|
|
243
|
-
|
|
44
|
+
jwtExpirationSeconds?: number;
|
|
244
45
|
/**
|
|
245
|
-
*
|
|
46
|
+
* Optional existing MemoryClient to use as storage backend.
|
|
47
|
+
* If not provided, a new one is created.
|
|
246
48
|
*/
|
|
247
|
-
|
|
49
|
+
storageClient?: MemoryClient;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Generate server keys for testing
|
|
53
|
+
*/
|
|
54
|
+
declare function generateTestServerKeys(): Promise<ServerKeys>;
|
|
55
|
+
/**
|
|
56
|
+
* Memory Wallet Client
|
|
57
|
+
*
|
|
58
|
+
* In-memory implementation that embeds WalletServerCore.
|
|
59
|
+
* Use for testing without running a real server.
|
|
60
|
+
*/
|
|
61
|
+
declare class MemoryWalletClient {
|
|
62
|
+
private server;
|
|
63
|
+
private handler;
|
|
64
|
+
private currentSession;
|
|
65
|
+
private apiBasePath;
|
|
66
|
+
private constructor();
|
|
248
67
|
/**
|
|
249
|
-
*
|
|
68
|
+
* Create a new MemoryWalletClient
|
|
69
|
+
* Use this factory method instead of constructor (async key generation)
|
|
250
70
|
*/
|
|
251
|
-
|
|
71
|
+
static create(config?: MemoryWalletClientConfig): Promise<MemoryWalletClient>;
|
|
252
72
|
/**
|
|
253
|
-
*
|
|
73
|
+
* Make a request to the embedded server
|
|
254
74
|
*/
|
|
255
|
-
|
|
75
|
+
private request;
|
|
256
76
|
/**
|
|
257
|
-
*
|
|
77
|
+
* Make an authenticated request
|
|
258
78
|
*/
|
|
79
|
+
private authRequest;
|
|
80
|
+
getSession(): AuthSession | null;
|
|
81
|
+
setSession(session: AuthSession | null): void;
|
|
82
|
+
isAuthenticated(): boolean;
|
|
83
|
+
getUsername(): string | null;
|
|
84
|
+
getToken(): string | null;
|
|
85
|
+
logout(): void;
|
|
259
86
|
health(): Promise<HealthResponse>;
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
87
|
+
getServerKeys(): Promise<{
|
|
88
|
+
identityPublicKeyHex: string;
|
|
89
|
+
encryptionPublicKeyHex: string;
|
|
90
|
+
}>;
|
|
264
91
|
signup(_credentials: UserCredentials): Promise<AuthSession>;
|
|
265
|
-
/**
|
|
266
|
-
* Login existing user
|
|
267
|
-
* Returns session data - call setSession() to activate it
|
|
268
|
-
*/
|
|
269
92
|
login(_credentials: UserCredentials): Promise<AuthSession>;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
* Requires active authentication session
|
|
273
|
-
*/
|
|
93
|
+
signupWithToken(appKey: string, tokenOrCredentials: string | UserCredentials, maybeCredentials?: UserCredentials): Promise<AuthSession>;
|
|
94
|
+
loginWithTokenSession(appKey: string, tokenOrSession: string, sessionOrCredentials: string | UserCredentials, maybeCredentials?: UserCredentials): Promise<AuthSession>;
|
|
274
95
|
changePassword(appKey: string, oldPassword: string, newPassword: string): Promise<void>;
|
|
275
|
-
/**
|
|
276
|
-
* Request a password reset token
|
|
277
|
-
* Does not require authentication
|
|
278
|
-
*/
|
|
279
96
|
requestPasswordReset(_username: string): Promise<PasswordResetToken>;
|
|
280
|
-
/**
|
|
281
|
-
* Reset password using a reset token
|
|
282
|
-
* Returns session data - call setSession() to activate it
|
|
283
|
-
*/
|
|
284
97
|
resetPassword(_username: string, _resetToken: string, _newPassword: string): Promise<AuthSession>;
|
|
285
|
-
/**
|
|
286
|
-
* Sign up with app token (scoped to an app)
|
|
287
|
-
*/
|
|
288
|
-
signupWithToken(appKey: string, tokenOrCredentials: string | UserCredentials, maybeCredentials?: UserCredentials): Promise<AuthSession>;
|
|
289
|
-
/**
|
|
290
|
-
* Login with app token and session (scoped to an app)
|
|
291
|
-
*/
|
|
292
|
-
loginWithTokenSession(appKey: string, tokenOrSession: string, sessionOrCredentials: string | UserCredentials, maybeCredentials?: UserCredentials): Promise<AuthSession>;
|
|
293
|
-
/**
|
|
294
|
-
* Request password reset scoped to app token
|
|
295
|
-
*/
|
|
296
98
|
requestPasswordResetWithToken(appKey: string, tokenOrUsername: string, maybeUsername?: string): Promise<PasswordResetToken>;
|
|
297
|
-
/**
|
|
298
|
-
* Reset password scoped to an app
|
|
299
|
-
*/
|
|
300
99
|
resetPasswordWithToken(appKey: string, _tokenOrUsername: string, usernameOrReset: string, resetToken?: string, newPassword?: string): Promise<AuthSession>;
|
|
301
|
-
/**
|
|
302
|
-
* Get public keys for the current authenticated user.
|
|
303
|
-
* Requires an active authentication session.
|
|
304
|
-
*/
|
|
305
100
|
getPublicKeys(appKey: string): Promise<UserPublicKeys>;
|
|
306
|
-
|
|
307
|
-
* Proxy a write request through the wallet server
|
|
308
|
-
* The server signs the write with its identity key
|
|
309
|
-
* Requires active authentication session
|
|
310
|
-
*/
|
|
101
|
+
getMyPublicKeys(appKey: string): Promise<UserPublicKeys>;
|
|
311
102
|
proxyWrite(request: ProxyWriteRequest): Promise<ProxyWriteResponse>;
|
|
312
|
-
/**
|
|
313
|
-
* Proxy a read request through the wallet server
|
|
314
|
-
* The server decrypts encrypted data using user's encryption key
|
|
315
|
-
* Requires active authentication session
|
|
316
|
-
*/
|
|
317
103
|
proxyRead(request: ProxyReadRequest): Promise<ProxyReadResponse>;
|
|
104
|
+
signupWithGoogle(appKey: string, token: string, googleIdToken: string): Promise<GoogleAuthSession>;
|
|
105
|
+
loginWithGoogle(appKey: string, token: string, session: string, googleIdToken: string): Promise<GoogleAuthSession>;
|
|
318
106
|
/**
|
|
319
|
-
*
|
|
320
|
-
* Requires active authentication session
|
|
107
|
+
* Get the underlying WalletServerCore (for testing/inspection)
|
|
321
108
|
*/
|
|
322
|
-
|
|
109
|
+
getServer(): WalletServerCore;
|
|
323
110
|
/**
|
|
324
|
-
* Get server's public keys
|
|
325
|
-
*
|
|
326
|
-
* @returns Server's identity and encryption public keys
|
|
327
|
-
* @throws Error if request fails
|
|
111
|
+
* Get server's public keys directly (convenience method)
|
|
328
112
|
*/
|
|
329
|
-
|
|
113
|
+
getServerPublicKeys(): {
|
|
330
114
|
identityPublicKeyHex: string;
|
|
331
115
|
encryptionPublicKeyHex: string;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Sign up with Google OAuth (scoped to app token)
|
|
335
|
-
* Returns session data with Google profile info - call setSession() to activate it
|
|
336
|
-
*
|
|
337
|
-
* @param token - App token from app server
|
|
338
|
-
* @param googleIdToken - Google ID token from Google Sign-In
|
|
339
|
-
* @returns GoogleAuthSession with username, JWT token, and Google profile info
|
|
340
|
-
*/
|
|
341
|
-
signupWithGoogle(appKey: string, token: string, googleIdToken: string): Promise<GoogleAuthSession>;
|
|
342
|
-
/**
|
|
343
|
-
* Login with Google OAuth (scoped to app token and session)
|
|
344
|
-
* Returns session data with Google profile info - call setSession() to activate it
|
|
345
|
-
*
|
|
346
|
-
* @param token - App token from app server
|
|
347
|
-
* @param session - Session key from app server
|
|
348
|
-
* @param googleIdToken - Google ID token from Google Sign-In
|
|
349
|
-
* @returns GoogleAuthSession with username, JWT token, and Google profile info
|
|
350
|
-
*/
|
|
351
|
-
loginWithGoogle(appKey: string, token: string, session: string, googleIdToken: string): Promise<GoogleAuthSession>;
|
|
116
|
+
};
|
|
352
117
|
}
|
|
353
118
|
|
|
354
|
-
export {
|
|
119
|
+
export { AuthSession, GoogleAuthSession, HealthResponse, MemoryWalletClient, type MemoryWalletClientConfig, PasswordResetToken, ProxyReadRequest, ProxyReadResponse, ProxyWriteRequest, ProxyWriteResponse, UserCredentials, UserPublicKeys, generateTestServerKeys };
|
package/dist/wallet/mod.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
MemoryWalletClient,
|
|
3
|
+
WalletClient,
|
|
4
|
+
generateTestServerKeys
|
|
5
|
+
} from "../chunk-FVLXYKYS.js";
|
|
6
|
+
import "../chunk-F3W5GZU6.js";
|
|
7
|
+
import "../chunk-JN75UL5C.js";
|
|
8
|
+
import "../chunk-LFUC4ETD.js";
|
|
9
|
+
import "../chunk-GIMIWVPX.js";
|
|
4
10
|
import "../chunk-MLKGABMK.js";
|
|
5
11
|
export {
|
|
6
|
-
|
|
12
|
+
MemoryWalletClient,
|
|
13
|
+
WalletClient,
|
|
14
|
+
generateTestServerKeys
|
|
7
15
|
};
|