@bandeira-tech/b3nd-web 0.3.2 → 0.3.4

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WalletServerCore
3
- } from "./chunk-EF5ZUB4O.js";
3
+ } from "./chunk-B4VAPGAO.js";
4
4
  import {
5
5
  exportPrivateKeyPem,
6
6
  generateEncryptionKeyPair,
@@ -86,22 +86,6 @@ var WalletClient = class {
86
86
  }
87
87
  return await response.json();
88
88
  }
89
- /**
90
- * Sign up a new user
91
- * Returns session data - call setSession() to activate it
92
- */
93
- // Tokenless signup is not supported. Use signup(token,...)
94
- async signup(_credentials) {
95
- throw new Error("Use signup(token, credentials) \u2014 app token required");
96
- }
97
- /**
98
- * Login existing user
99
- * Returns session data - call setSession() to activate it
100
- */
101
- // Tokenless login is not supported. Use login(token, session, credentials)
102
- async login(_credentials) {
103
- throw new Error("Use login(token, session, credentials) \u2014 app token + session required");
104
- }
105
89
  /**
106
90
  * Change password for current user
107
91
  * Requires active authentication session
@@ -153,18 +137,29 @@ var WalletClient = class {
153
137
  *
154
138
  * @param appKey - The app's public key
155
139
  * @param session - Session keypair (generated via generateSessionKeypair)
156
- * @param credentials - User credentials (username/password)
140
+ * @param credentials - User credentials (password or Google)
157
141
  */
158
- async signupWithToken(appKey, session, credentials) {
142
+ async signup(appKey, session, credentials) {
159
143
  if (!session?.publicKeyHex || !session?.privateKeyHex) {
160
144
  throw new Error("session keypair is required");
161
145
  }
162
- const payloadToSign = {
163
- sessionPubkey: session.publicKeyHex,
164
- type: "password",
165
- username: credentials.username,
166
- password: credentials.password
167
- };
146
+ let payloadToSign;
147
+ if (credentials.type === "password") {
148
+ payloadToSign = {
149
+ sessionPubkey: session.publicKeyHex,
150
+ type: "password",
151
+ username: credentials.username,
152
+ password: credentials.password
153
+ };
154
+ } else if (credentials.type === "google") {
155
+ payloadToSign = {
156
+ sessionPubkey: session.publicKeyHex,
157
+ type: "google",
158
+ googleIdToken: credentials.googleIdToken
159
+ };
160
+ } else {
161
+ throw new Error(`Unknown credential type: ${credentials.type}`);
162
+ }
168
163
  const sessionSignature = await signWithHex(session.privateKeyHex, payloadToSign);
169
164
  const response = await this.fetchImpl(this.buildAppKeyUrl("/auth/signup", appKey), {
170
165
  method: "POST",
@@ -178,7 +173,15 @@ var WalletClient = class {
178
173
  if (!response.ok || !data.success) {
179
174
  throw new Error(data.error || `Signup failed: ${response.statusText}`);
180
175
  }
181
- return { username: data.username, token: data.token, expiresIn: data.expiresIn };
176
+ const result = {
177
+ username: data.username,
178
+ token: data.token,
179
+ expiresIn: data.expiresIn
180
+ };
181
+ if (data.email) result.email = data.email;
182
+ if (data.name) result.name = data.name;
183
+ if (data.picture) result.picture = data.picture;
184
+ return result;
182
185
  }
183
186
  /**
184
187
  * Login with session keypair (scoped to an app)
@@ -190,18 +193,29 @@ var WalletClient = class {
190
193
  *
191
194
  * @param appKey - The app's public key
192
195
  * @param session - Session keypair (generated via generateSessionKeypair)
193
- * @param credentials - User credentials (username/password)
196
+ * @param credentials - User credentials (password or Google)
194
197
  */
195
- async loginWithTokenSession(appKey, session, credentials) {
198
+ async login(appKey, session, credentials) {
196
199
  if (!session?.publicKeyHex || !session?.privateKeyHex) {
197
200
  throw new Error("session keypair is required");
198
201
  }
199
- const payloadToSign = {
200
- sessionPubkey: session.publicKeyHex,
201
- type: "password",
202
- username: credentials.username,
203
- password: credentials.password
204
- };
202
+ let payloadToSign;
203
+ if (credentials.type === "password") {
204
+ payloadToSign = {
205
+ sessionPubkey: session.publicKeyHex,
206
+ type: "password",
207
+ username: credentials.username,
208
+ password: credentials.password
209
+ };
210
+ } else if (credentials.type === "google") {
211
+ payloadToSign = {
212
+ sessionPubkey: session.publicKeyHex,
213
+ type: "google",
214
+ googleIdToken: credentials.googleIdToken
215
+ };
216
+ } else {
217
+ throw new Error(`Unknown credential type: ${credentials.type}`);
218
+ }
205
219
  const sessionSignature = await signWithHex(session.privateKeyHex, payloadToSign);
206
220
  const response = await this.fetchImpl(this.buildAppKeyUrl("/auth/login", appKey), {
207
221
  method: "POST",
@@ -215,7 +229,15 @@ var WalletClient = class {
215
229
  if (!response.ok || !data.success) {
216
230
  throw new Error(data.error || `Login failed: ${response.statusText}`);
217
231
  }
218
- return { username: data.username, token: data.token, expiresIn: data.expiresIn };
232
+ const result = {
233
+ username: data.username,
234
+ token: data.token,
235
+ expiresIn: data.expiresIn
236
+ };
237
+ if (data.email) result.email = data.email;
238
+ if (data.name) result.name = data.name;
239
+ if (data.picture) result.picture = data.picture;
240
+ return result;
219
241
  }
220
242
  /**
221
243
  * Request password reset scoped to app token
@@ -380,81 +402,6 @@ var WalletClient = class {
380
402
  encryptionPublicKeyHex: data.encryptionPublicKeyHex
381
403
  };
382
404
  }
383
- /**
384
- * Sign up with Google OAuth (scoped to app token)
385
- * Returns session data with Google profile info - call setSession() to activate it
386
- *
387
- * @param token - App token from app server
388
- * @param googleIdToken - Google ID token from Google Sign-In
389
- * @returns GoogleAuthSession with username, JWT token, and Google profile info
390
- */
391
- async signupWithGoogle(appKey, token, googleIdToken) {
392
- if (!token) throw new Error("token is required");
393
- if (!googleIdToken) throw new Error("googleIdToken is required");
394
- const response = await this.fetchImpl(this.buildAppKeyUrl("/auth/signup", appKey), {
395
- method: "POST",
396
- headers: { "Content-Type": "application/json" },
397
- body: JSON.stringify({ token, type: "google", googleIdToken })
398
- });
399
- const data = await response.json();
400
- if (!response.ok || !data.success) {
401
- throw new Error(data.error || `Google signup failed: ${response.statusText}`);
402
- }
403
- return {
404
- username: data.username,
405
- token: data.token,
406
- expiresIn: data.expiresIn,
407
- email: data.email,
408
- name: data.name,
409
- picture: data.picture
410
- };
411
- }
412
- /**
413
- * Login with Google OAuth (scoped to app token and session keypair)
414
- * Returns session data with Google profile info - call setSession() to activate it
415
- *
416
- * The session must be approved by the app beforehand.
417
- *
418
- * @param appKey - The app's public key
419
- * @param token - App token from app server
420
- * @param session - Session keypair (generated via generateSessionKeypair)
421
- * @param googleIdToken - Google ID token from Google Sign-In
422
- * @returns GoogleAuthSession with username, JWT token, and Google profile info
423
- */
424
- async loginWithGoogle(appKey, token, session, googleIdToken) {
425
- if (!token) throw new Error("token is required");
426
- if (!session?.publicKeyHex || !session?.privateKeyHex) {
427
- throw new Error("session keypair is required");
428
- }
429
- if (!googleIdToken) throw new Error("googleIdToken is required");
430
- const payloadToSign = {
431
- token,
432
- sessionPubkey: session.publicKeyHex,
433
- type: "google",
434
- googleIdToken
435
- };
436
- const sessionSignature = await signWithHex(session.privateKeyHex, payloadToSign);
437
- const response = await this.fetchImpl(this.buildAppKeyUrl("/auth/login", appKey), {
438
- method: "POST",
439
- headers: { "Content-Type": "application/json" },
440
- body: JSON.stringify({
441
- ...payloadToSign,
442
- sessionSignature
443
- })
444
- });
445
- const data = await response.json();
446
- if (!response.ok || !data.success) {
447
- throw new Error(data.error || `Google login failed: ${response.statusText}`);
448
- }
449
- return {
450
- username: data.username,
451
- token: data.token,
452
- expiresIn: data.expiresIn,
453
- email: data.email,
454
- name: data.name,
455
- picture: data.picture
456
- };
457
- }
458
405
  };
459
406
  async function generateSessionKeypair() {
460
407
  const keyPair = await generateSigningKeyPair();
@@ -611,34 +558,39 @@ var MemoryWalletClient = class _MemoryWalletClient {
611
558
  // ============================================================
612
559
  // Authentication
613
560
  // ============================================================
614
- async signup(_credentials) {
615
- throw new Error("Use signupWithToken(appKey, credentials) \u2014 app token required");
616
- }
617
- async login(_credentials) {
618
- throw new Error("Use loginWithTokenSession(appKey, session, credentials) \u2014 app token + session required");
619
- }
620
561
  /**
621
562
  * Sign up with session keypair (scoped to an app)
622
563
  *
623
564
  * The session must be approved by the app beforehand:
624
- * 1. Client writes request to: immutable://inbox/{appKey}/sessions/{sessionPubkey} = 1
565
+ * 1. Client writes request to: immutable://inbox/{appKey}/sessions/{sessionPubkey}
625
566
  * 2. App approves by writing: mutable://accounts/{appKey}/sessions/{sessionPubkey} = 1
626
567
  * 3. Client calls this method with the session keypair
627
568
  *
628
569
  * @param appKey - The app's public key
629
570
  * @param session - Session keypair (generated via generateSessionKeypair)
630
- * @param credentials - User credentials (username/password)
571
+ * @param credentials - User credentials (password or Google)
631
572
  */
632
- async signupWithToken(appKey, session, credentials) {
573
+ async signup(appKey, session, credentials) {
633
574
  if (!session?.publicKeyHex || !session?.privateKeyHex) {
634
575
  throw new Error("session keypair is required");
635
576
  }
636
- const payloadToSign = {
637
- sessionPubkey: session.publicKeyHex,
638
- type: "password",
639
- username: credentials.username,
640
- password: credentials.password
641
- };
577
+ let payloadToSign;
578
+ if (credentials.type === "password") {
579
+ payloadToSign = {
580
+ sessionPubkey: session.publicKeyHex,
581
+ type: "password",
582
+ username: credentials.username,
583
+ password: credentials.password
584
+ };
585
+ } else if (credentials.type === "google") {
586
+ payloadToSign = {
587
+ sessionPubkey: session.publicKeyHex,
588
+ type: "google",
589
+ googleIdToken: credentials.googleIdToken
590
+ };
591
+ } else {
592
+ throw new Error(`Unknown credential type: ${credentials.type}`);
593
+ }
642
594
  const sessionSignature = await signWithHex(session.privateKeyHex, payloadToSign);
643
595
  const response = await this.request("POST", `/auth/signup/${appKey}`, {
644
596
  ...payloadToSign,
@@ -648,11 +600,15 @@ var MemoryWalletClient = class _MemoryWalletClient {
648
600
  if (!response.ok || !data.success) {
649
601
  throw new Error(data.error || `Signup failed: ${response.statusText}`);
650
602
  }
651
- return {
603
+ const result = {
652
604
  username: data.username,
653
605
  token: data.token,
654
606
  expiresIn: data.expiresIn
655
607
  };
608
+ if (data.email) result.email = data.email;
609
+ if (data.name) result.name = data.name;
610
+ if (data.picture) result.picture = data.picture;
611
+ return result;
656
612
  }
657
613
  /**
658
614
  * Login with session keypair (scoped to an app)
@@ -664,18 +620,29 @@ var MemoryWalletClient = class _MemoryWalletClient {
664
620
  *
665
621
  * @param appKey - The app's public key
666
622
  * @param session - Session keypair (generated via generateSessionKeypair)
667
- * @param credentials - User credentials (username/password)
623
+ * @param credentials - User credentials (password or Google)
668
624
  */
669
- async loginWithTokenSession(appKey, session, credentials) {
625
+ async login(appKey, session, credentials) {
670
626
  if (!session?.publicKeyHex || !session?.privateKeyHex) {
671
627
  throw new Error("session keypair is required");
672
628
  }
673
- const payloadToSign = {
674
- sessionPubkey: session.publicKeyHex,
675
- type: "password",
676
- username: credentials.username,
677
- password: credentials.password
678
- };
629
+ let payloadToSign;
630
+ if (credentials.type === "password") {
631
+ payloadToSign = {
632
+ sessionPubkey: session.publicKeyHex,
633
+ type: "password",
634
+ username: credentials.username,
635
+ password: credentials.password
636
+ };
637
+ } else if (credentials.type === "google") {
638
+ payloadToSign = {
639
+ sessionPubkey: session.publicKeyHex,
640
+ type: "google",
641
+ googleIdToken: credentials.googleIdToken
642
+ };
643
+ } else {
644
+ throw new Error(`Unknown credential type: ${credentials.type}`);
645
+ }
679
646
  const sessionSignature = await signWithHex(session.privateKeyHex, payloadToSign);
680
647
  const response = await this.request("POST", `/auth/login/${appKey}`, {
681
648
  ...payloadToSign,
@@ -685,11 +652,15 @@ var MemoryWalletClient = class _MemoryWalletClient {
685
652
  if (!response.ok || !data.success) {
686
653
  throw new Error(data.error || `Login failed: ${response.statusText}`);
687
654
  }
688
- return {
655
+ const result = {
689
656
  username: data.username,
690
657
  token: data.token,
691
658
  expiresIn: data.expiresIn
692
659
  };
660
+ if (data.email) result.email = data.email;
661
+ if (data.name) result.name = data.name;
662
+ if (data.picture) result.picture = data.picture;
663
+ return result;
693
664
  }
694
665
  // ============================================================
695
666
  // Password Management
@@ -792,72 +763,6 @@ var MemoryWalletClient = class _MemoryWalletClient {
792
763
  return await response.json();
793
764
  }
794
765
  // ============================================================
795
- // Google OAuth (for completeness - may not work without real Google)
796
- // ============================================================
797
- async signupWithGoogle(appKey, token, googleIdToken) {
798
- if (!token) throw new Error("token is required");
799
- if (!googleIdToken) throw new Error("googleIdToken is required");
800
- const response = await this.request("POST", `/auth/signup/${appKey}`, {
801
- token,
802
- type: "google",
803
- googleIdToken
804
- });
805
- const data = await response.json();
806
- if (!response.ok || !data.success) {
807
- throw new Error(data.error || `Google signup failed: ${response.statusText}`);
808
- }
809
- return {
810
- username: data.username,
811
- token: data.token,
812
- expiresIn: data.expiresIn,
813
- email: data.email,
814
- name: data.name,
815
- picture: data.picture
816
- };
817
- }
818
- /**
819
- * Login with Google OAuth (scoped to app token and session keypair)
820
- * Returns session data with Google profile info - call setSession() to activate it
821
- *
822
- * The session must be approved by the app beforehand.
823
- *
824
- * @param appKey - The app's public key
825
- * @param token - App token from app server
826
- * @param session - Session keypair (generated via generateSessionKeypair)
827
- * @param googleIdToken - Google ID token from Google Sign-In
828
- * @returns GoogleAuthSession with username, JWT token, and Google profile info
829
- */
830
- async loginWithGoogle(appKey, token, session, googleIdToken) {
831
- if (!token) throw new Error("token is required");
832
- if (!session?.publicKeyHex || !session?.privateKeyHex) {
833
- throw new Error("session keypair is required");
834
- }
835
- if (!googleIdToken) throw new Error("googleIdToken is required");
836
- const payloadToSign = {
837
- token,
838
- sessionPubkey: session.publicKeyHex,
839
- type: "google",
840
- googleIdToken
841
- };
842
- const sessionSignature = await signWithHex(session.privateKeyHex, payloadToSign);
843
- const response = await this.request("POST", `/auth/login/${appKey}`, {
844
- ...payloadToSign,
845
- sessionSignature
846
- });
847
- const data = await response.json();
848
- if (!response.ok || !data.success) {
849
- throw new Error(data.error || `Google login failed: ${response.statusText}`);
850
- }
851
- return {
852
- username: data.username,
853
- token: data.token,
854
- expiresIn: data.expiresIn,
855
- email: data.email,
856
- name: data.name,
857
- picture: data.picture
858
- };
859
- }
860
- // ============================================================
861
766
  // Testing Utilities
862
767
  // ============================================================
863
768
  /**
@@ -897,7 +802,7 @@ async function createTestEnvironment(config = {}) {
897
802
  };
898
803
  const sessionUri = `mutable://accounts/${appKey}/sessions/${sessionKeypair.publicKeyHex}`;
899
804
  await backend.write(sessionUri, 1);
900
- const session = await wallet.signupWithToken(appKey, sessionKeypair, { username, password });
805
+ const session = await wallet.signup(appKey, sessionKeypair, { type: "password", username, password });
901
806
  wallet.setSession(session);
902
807
  const keys = await wallet.getPublicKeys(appKey);
903
808
  return { session, keys, sessionKeypair };
@@ -910,7 +815,7 @@ async function createTestEnvironment(config = {}) {
910
815
  };
911
816
  const sessionUri = `mutable://accounts/${appKey}/sessions/${sessionKeypair.publicKeyHex}`;
912
817
  await backend.write(sessionUri, 1);
913
- const session = await wallet.loginWithTokenSession(appKey, sessionKeypair, { username, password });
818
+ const session = await wallet.login(appKey, sessionKeypair, { type: "password", username, password });
914
819
  wallet.setSession(session);
915
820
  const keys = await wallet.getPublicKeys(appKey);
916
821
  return { session, keys, sessionKeypair };
@@ -39,12 +39,12 @@ interface WalletClientInterface {
39
39
  * Signup with session keypair.
40
40
  * Session must be approved by app at mutable://accounts/{appKey}/sessions/{sessionPubkey} = 1
41
41
  */
42
- signupWithToken(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
42
+ signup(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
43
43
  /**
44
44
  * Login with session keypair.
45
45
  * Session must be approved by app at mutable://accounts/{appKey}/sessions/{sessionPubkey} = 1
46
46
  */
47
- loginWithTokenSession(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
47
+ login(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
48
48
  changePassword(appKey: string, oldPassword: string, newPassword: string): Promise<void>;
49
49
  requestPasswordResetWithToken(appKey: string, tokenOrUsername: string, maybeUsername?: string): Promise<PasswordResetToken>;
50
50
  resetPasswordWithToken(appKey: string, tokenOrUsername: string, usernameOrReset: string, resetToken?: string, newPassword?: string): Promise<AuthSession>;
@@ -53,8 +53,6 @@ interface WalletClientInterface {
53
53
  proxyWrite(request: ProxyWriteRequest): Promise<ProxyWriteResponse>;
54
54
  proxyRead(request: ProxyReadRequest): Promise<ProxyReadResponse>;
55
55
  proxyReadMulti(request: ProxyReadMultiRequest): Promise<ProxyReadMultiResponse>;
56
- signupWithGoogle(appKey: string, token: string, googleIdToken: string): Promise<GoogleAuthSession>;
57
- loginWithGoogle(appKey: string, token: string, session: SessionKeypair, googleIdToken: string): Promise<GoogleAuthSession>;
58
56
  }
59
57
  /**
60
58
  * Configuration for wallet client
@@ -74,12 +72,25 @@ interface WalletClientConfig {
74
72
  fetch?: typeof fetch;
75
73
  }
76
74
  /**
77
- * User credentials for authentication
75
+ * Password-based credentials
78
76
  */
79
- interface UserCredentials {
77
+ interface PasswordCredentials {
78
+ type: 'password';
80
79
  username: string;
81
80
  password: string;
82
81
  }
82
+ /**
83
+ * Google OAuth credentials
84
+ */
85
+ interface GoogleCredentials {
86
+ type: 'google';
87
+ googleIdToken: string;
88
+ }
89
+ /**
90
+ * User credentials for authentication (discriminated union)
91
+ * Use `type` field to distinguish between authentication methods.
92
+ */
93
+ type UserCredentials = PasswordCredentials | GoogleCredentials;
83
94
  /**
84
95
  * Session keypair for authentication
85
96
  * Sessions are Ed25519 keypairs. The client creates the session, requests
@@ -93,11 +104,18 @@ interface SessionKeypair {
93
104
  }
94
105
  /**
95
106
  * Authenticated session with JWT token
107
+ * For Google auth, includes optional profile fields.
96
108
  */
97
109
  interface AuthSession {
98
110
  username: string;
99
111
  token: string;
100
112
  expiresIn: number;
113
+ /** Present when auth type is 'google' */
114
+ email?: string;
115
+ /** Present when auth type is 'google' */
116
+ name?: string;
117
+ /** Present when auth type is 'google' */
118
+ picture?: string;
101
119
  }
102
120
  /**
103
121
  * User's public keys
@@ -248,13 +266,10 @@ interface HealthResponse extends ApiResponse {
248
266
  timestamp: string;
249
267
  }
250
268
  /**
251
- * Google OAuth session (extended AuthSession with Google profile info)
269
+ * Google OAuth session
270
+ * @deprecated Use AuthSession directly - Google profile fields are now optional on AuthSession
252
271
  */
253
- interface GoogleAuthSession extends AuthSession {
254
- email: string;
255
- name?: string;
256
- picture?: string;
257
- }
272
+ type GoogleAuthSession = AuthSession;
258
273
  /**
259
274
  * Google signup response
260
275
  */
@@ -353,16 +368,6 @@ declare class WalletClient {
353
368
  * Check wallet server health
354
369
  */
355
370
  health(): Promise<HealthResponse>;
356
- /**
357
- * Sign up a new user
358
- * Returns session data - call setSession() to activate it
359
- */
360
- signup(_credentials: UserCredentials): Promise<AuthSession>;
361
- /**
362
- * Login existing user
363
- * Returns session data - call setSession() to activate it
364
- */
365
- login(_credentials: UserCredentials): Promise<AuthSession>;
366
371
  /**
367
372
  * Change password for current user
368
373
  * Requires active authentication session
@@ -388,9 +393,9 @@ declare class WalletClient {
388
393
  *
389
394
  * @param appKey - The app's public key
390
395
  * @param session - Session keypair (generated via generateSessionKeypair)
391
- * @param credentials - User credentials (username/password)
396
+ * @param credentials - User credentials (password or Google)
392
397
  */
393
- signupWithToken(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
398
+ signup(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
394
399
  /**
395
400
  * Login with session keypair (scoped to an app)
396
401
  *
@@ -401,9 +406,9 @@ declare class WalletClient {
401
406
  *
402
407
  * @param appKey - The app's public key
403
408
  * @param session - Session keypair (generated via generateSessionKeypair)
404
- * @param credentials - User credentials (username/password)
409
+ * @param credentials - User credentials (password or Google)
405
410
  */
406
- loginWithTokenSession(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
411
+ login(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
407
412
  /**
408
413
  * Request password reset scoped to app token
409
414
  */
@@ -457,28 +462,6 @@ declare class WalletClient {
457
462
  identityPublicKeyHex: string;
458
463
  encryptionPublicKeyHex: string;
459
464
  }>;
460
- /**
461
- * Sign up with Google OAuth (scoped to app token)
462
- * Returns session data with Google profile info - call setSession() to activate it
463
- *
464
- * @param token - App token from app server
465
- * @param googleIdToken - Google ID token from Google Sign-In
466
- * @returns GoogleAuthSession with username, JWT token, and Google profile info
467
- */
468
- signupWithGoogle(appKey: string, token: string, googleIdToken: string): Promise<GoogleAuthSession>;
469
- /**
470
- * Login with Google OAuth (scoped to app token and session keypair)
471
- * Returns session data with Google profile info - call setSession() to activate it
472
- *
473
- * The session must be approved by the app beforehand.
474
- *
475
- * @param appKey - The app's public key
476
- * @param token - App token from app server
477
- * @param session - Session keypair (generated via generateSessionKeypair)
478
- * @param googleIdToken - Google ID token from Google Sign-In
479
- * @returns GoogleAuthSession with username, JWT token, and Google profile info
480
- */
481
- loginWithGoogle(appKey: string, token: string, session: SessionKeypair, googleIdToken: string): Promise<GoogleAuthSession>;
482
465
  }
483
466
  /**
484
467
  * Generate a new session keypair for authentication
@@ -2,6 +2,6 @@ export { C as ClientError, D as DeleteResult, H as HealthStatus, a as HttpClient
2
2
  export { HttpClient } from '../clients/http/mod.js';
3
3
  export { WebSocketClient } from '../clients/websocket/mod.js';
4
4
  export { LocalStorageClient } from '../clients/local-storage/mod.js';
5
- export { W as WalletClient } from '../client-C4oQxiDu.js';
5
+ export { W as WalletClient } from '../client-DHCiJ9I7.js';
6
6
  export { AppsClient } from '../apps/mod.js';
7
7
  export { m as encrypt } from '../mod-CII9wqu2.js';
@@ -1,23 +1,23 @@
1
+ import {
2
+ WebSocketClient
3
+ } from "../chunk-UUHVOWVI.js";
1
4
  import {
2
5
  WalletClient
3
- } from "../chunk-FDJZ4P2M.js";
4
- import "../chunk-EF5ZUB4O.js";
6
+ } from "../chunk-NEYGL7RS.js";
5
7
  import {
6
- HttpClient
7
- } from "../chunk-OY4CDOHY.js";
8
+ AppsClient
9
+ } from "../chunk-VAZUCGED.js";
10
+ import "../chunk-B4VAPGAO.js";
8
11
  import {
9
12
  mod_exports
10
13
  } from "../chunk-JN75UL5C.js";
11
14
  import {
12
- AppsClient
13
- } from "../chunk-VAZUCGED.js";
14
- import {
15
- WebSocketClient
16
- } from "../chunk-UUHVOWVI.js";
17
- import "../chunk-O53KW746.js";
15
+ HttpClient
16
+ } from "../chunk-OY4CDOHY.js";
18
17
  import {
19
18
  LocalStorageClient
20
19
  } from "../chunk-PZFEKQ7F.js";
20
+ import "../chunk-O53KW746.js";
21
21
  import "../chunk-MLKGABMK.js";
22
22
  export {
23
23
  AppsClient,
@@ -1,5 +1,5 @@
1
- import { A as AuthSession, H as HealthResponse, U as UserCredentials, S as SessionKeypair, P as PasswordResetToken, a as UserPublicKeys, b as ProxyWriteRequest, c as ProxyWriteResponse, d as ProxyReadRequest, e as ProxyReadResponse, f as ProxyReadMultiRequest, g as ProxyReadMultiResponse, G as GoogleAuthSession } from '../client-C4oQxiDu.js';
2
- export { l as ApiResponse, C as ChangePasswordResponse, q as GoogleLoginResponse, p as GoogleSignupResponse, L as LoginResponse, k as ProxyReadMultiResultItem, n as PublicKeysResponse, R as RequestPasswordResetResponse, o as ResetPasswordResponse, m as SignupResponse, W as WalletClient, j as WalletClientConfig, i as WalletClientInterface, h as generateSessionKeypair } from '../client-C4oQxiDu.js';
1
+ import { A as AuthSession, H as HealthResponse, S as SessionKeypair, U as UserCredentials, P as PasswordResetToken, a as UserPublicKeys, b as ProxyWriteRequest, c as ProxyWriteResponse, d as ProxyReadRequest, e as ProxyReadResponse, f as ProxyReadMultiRequest, g as ProxyReadMultiResponse } from '../client-DHCiJ9I7.js';
2
+ export { l as ApiResponse, C as ChangePasswordResponse, G as GoogleAuthSession, q as GoogleLoginResponse, p as GoogleSignupResponse, L as LoginResponse, k as ProxyReadMultiResultItem, n as PublicKeysResponse, R as RequestPasswordResetResponse, o as ResetPasswordResponse, m as SignupResponse, W as WalletClient, j as WalletClientConfig, i as WalletClientInterface, h as generateSessionKeypair } from '../client-DHCiJ9I7.js';
3
3
  import { N as NodeProtocolInterface, S as Schema } from '../types-uuvn4oKw.js';
4
4
  import { S as ServerKeys, W as WalletServerCore } from '../core-ClnuubZw.js';
5
5
  import { MemoryClient } from '../clients/memory/mod.js';
@@ -105,21 +105,19 @@ declare class MemoryWalletClient {
105
105
  identityPublicKeyHex: string;
106
106
  encryptionPublicKeyHex: string;
107
107
  }>;
108
- signup(_credentials: UserCredentials): Promise<AuthSession>;
109
- login(_credentials: UserCredentials): Promise<AuthSession>;
110
108
  /**
111
109
  * Sign up with session keypair (scoped to an app)
112
110
  *
113
111
  * The session must be approved by the app beforehand:
114
- * 1. Client writes request to: immutable://inbox/{appKey}/sessions/{sessionPubkey} = 1
112
+ * 1. Client writes request to: immutable://inbox/{appKey}/sessions/{sessionPubkey}
115
113
  * 2. App approves by writing: mutable://accounts/{appKey}/sessions/{sessionPubkey} = 1
116
114
  * 3. Client calls this method with the session keypair
117
115
  *
118
116
  * @param appKey - The app's public key
119
117
  * @param session - Session keypair (generated via generateSessionKeypair)
120
- * @param credentials - User credentials (username/password)
118
+ * @param credentials - User credentials (password or Google)
121
119
  */
122
- signupWithToken(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
120
+ signup(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
123
121
  /**
124
122
  * Login with session keypair (scoped to an app)
125
123
  *
@@ -130,9 +128,9 @@ declare class MemoryWalletClient {
130
128
  *
131
129
  * @param appKey - The app's public key
132
130
  * @param session - Session keypair (generated via generateSessionKeypair)
133
- * @param credentials - User credentials (username/password)
131
+ * @param credentials - User credentials (password or Google)
134
132
  */
135
- loginWithTokenSession(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
133
+ login(appKey: string, session: SessionKeypair, credentials: UserCredentials): Promise<AuthSession>;
136
134
  changePassword(appKey: string, oldPassword: string, newPassword: string): Promise<void>;
137
135
  requestPasswordReset(_username: string): Promise<PasswordResetToken>;
138
136
  resetPassword(_username: string, _resetToken: string, _newPassword: string): Promise<AuthSession>;
@@ -143,20 +141,6 @@ declare class MemoryWalletClient {
143
141
  proxyWrite(request: ProxyWriteRequest): Promise<ProxyWriteResponse>;
144
142
  proxyRead(request: ProxyReadRequest): Promise<ProxyReadResponse>;
145
143
  proxyReadMulti(request: ProxyReadMultiRequest): Promise<ProxyReadMultiResponse>;
146
- signupWithGoogle(appKey: string, token: string, googleIdToken: string): Promise<GoogleAuthSession>;
147
- /**
148
- * Login with Google OAuth (scoped to app token and session keypair)
149
- * Returns session data with Google profile info - call setSession() to activate it
150
- *
151
- * The session must be approved by the app beforehand.
152
- *
153
- * @param appKey - The app's public key
154
- * @param token - App token from app server
155
- * @param session - Session keypair (generated via generateSessionKeypair)
156
- * @param googleIdToken - Google ID token from Google Sign-In
157
- * @returns GoogleAuthSession with username, JWT token, and Google profile info
158
- */
159
- loginWithGoogle(appKey: string, token: string, session: SessionKeypair, googleIdToken: string): Promise<GoogleAuthSession>;
160
144
  /**
161
145
  * Get the underlying WalletServerCore (for testing/inspection)
162
146
  */
@@ -307,4 +291,4 @@ interface TestEnvironment {
307
291
  */
308
292
  declare function createTestEnvironment(config?: TestEnvironmentConfig): Promise<TestEnvironment>;
309
293
 
310
- export { AuthSession, GoogleAuthSession, HealthResponse, MemoryWalletClient, type MemoryWalletClientConfig, PasswordResetToken, ProxyReadMultiRequest, ProxyReadMultiResponse, ProxyReadRequest, ProxyReadResponse, ProxyWriteRequest, ProxyWriteResponse, SessionKeypair, type TestEnvironment, type TestEnvironmentConfig, UserCredentials, UserPublicKeys, createTestEnvironment, generateTestServerKeys };
294
+ export { AuthSession, HealthResponse, MemoryWalletClient, type MemoryWalletClientConfig, PasswordResetToken, ProxyReadMultiRequest, ProxyReadMultiResponse, ProxyReadRequest, ProxyReadResponse, ProxyWriteRequest, ProxyWriteResponse, SessionKeypair, type TestEnvironment, type TestEnvironmentConfig, UserCredentials, UserPublicKeys, createTestEnvironment, generateTestServerKeys };
@@ -4,10 +4,10 @@ import {
4
4
  createTestEnvironment,
5
5
  generateSessionKeypair,
6
6
  generateTestServerKeys
7
- } from "../chunk-FDJZ4P2M.js";
8
- import "../chunk-EF5ZUB4O.js";
9
- import "../chunk-OY4CDOHY.js";
7
+ } from "../chunk-NEYGL7RS.js";
8
+ import "../chunk-B4VAPGAO.js";
10
9
  import "../chunk-JN75UL5C.js";
10
+ import "../chunk-OY4CDOHY.js";
11
11
  import "../chunk-O53KW746.js";
12
12
  import "../chunk-MLKGABMK.js";
13
13
  export {
@@ -2,9 +2,9 @@ import {
2
2
  ConfigEnvironment,
3
3
  MemoryFileStorage,
4
4
  WalletServerCore
5
- } from "../../chunk-EF5ZUB4O.js";
6
- import "../../chunk-OY4CDOHY.js";
5
+ } from "../../chunk-B4VAPGAO.js";
7
6
  import "../../chunk-JN75UL5C.js";
7
+ import "../../chunk-OY4CDOHY.js";
8
8
  import {
9
9
  LocalStorageClient
10
10
  } from "../../chunk-PZFEKQ7F.js";
@@ -34,9 +34,9 @@ import {
34
34
  userExists,
35
35
  verifyGoogleIdToken,
36
36
  verifyJwt
37
- } from "../chunk-EF5ZUB4O.js";
38
- import "../chunk-OY4CDOHY.js";
37
+ } from "../chunk-B4VAPGAO.js";
39
38
  import "../chunk-JN75UL5C.js";
39
+ import "../chunk-OY4CDOHY.js";
40
40
  import "../chunk-MLKGABMK.js";
41
41
  export {
42
42
  ConfigEnvironment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bandeira-tech/b3nd-web",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Browser-focused B3nd SDK bundle",
5
5
  "type": "module",
6
6
  "main": "./dist/src/mod.web.js",
@@ -1,6 +1,3 @@
1
- import {
2
- HttpClient
3
- } from "./chunk-OY4CDOHY.js";
4
1
  import {
5
2
  createAuthenticatedMessage,
6
3
  createSignedEncryptedMessage,
@@ -11,6 +8,9 @@ import {
11
8
  verify,
12
9
  verifyPayload
13
10
  } from "./chunk-JN75UL5C.js";
11
+ import {
12
+ HttpClient
13
+ } from "./chunk-OY4CDOHY.js";
14
14
 
15
15
  // wallet-server/interfaces.ts
16
16
  var defaultLogger = {