@palbase/web 7.1.0 → 7.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -245,6 +245,15 @@ interface PasswordChangeParams {
245
245
  current_password: string;
246
246
  new_password: string;
247
247
  }
248
+ /**
249
+ * Body of POST /auth/password/set — a passwordless account's FIRST password.
250
+ *
251
+ * No current password on purpose: the accounts this serves (passkey-first,
252
+ * social-only) do not have one, which is why `changePassword` answers them 401.
253
+ */
254
+ interface PasswordSetParams {
255
+ new_password: string;
256
+ }
248
257
  interface MFAEnrollParams {
249
258
  type: 'totp' | 'email';
250
259
  }
@@ -435,6 +444,18 @@ declare class AuthClient {
435
444
  changePassword(params: PasswordChangeParams): Promise<PalbaseResponse<{
436
445
  success: boolean;
437
446
  }>>;
447
+ /**
448
+ * Give a PASSWORDLESS account its first password.
449
+ *
450
+ * Separate from `changePassword` because that one cannot serve the case: it
451
+ * sends a current password and palauth answers an account that has none with
452
+ * 401. Requires a RECENT sign-in (403 `reauthentication_required` otherwise,
453
+ * the same gate passkey enrollment carries); an account that already has a
454
+ * password gets 409 `password_already_set`.
455
+ */
456
+ setPassword(params: PasswordSetParams): Promise<PalbaseResponse<{
457
+ success: boolean;
458
+ }>>;
438
459
  refresh(): Promise<PalbaseResponse<TokenResponse>>;
439
460
  getAccessToken(): string | null;
440
461
  onTokenChange(callback: (tokens: {
@@ -1826,6 +1847,24 @@ declare class PalbeAuth {
1826
1847
  currentPassword: string;
1827
1848
  newPassword: string;
1828
1849
  }): Promise<void>;
1850
+ /**
1851
+ * Give a passwordless account its FIRST password, in-app.
1852
+ *
1853
+ * For accounts created with a passkey or a social provider: they have no
1854
+ * current password, so `updatePassword` cannot serve them — it sends one and
1855
+ * the server answers 401. Before this existed the only route was the
1856
+ * password-RESET e-mail, which asks someone already signed in to go find
1857
+ * their inbox.
1858
+ *
1859
+ * Requires a RECENT sign-in, not merely a session: a first password is a
1860
+ * credential that outlives the rest, so the server answers 403
1861
+ * `reauthentication_required` on a stale one — the same gate
1862
+ * `registerPasskey` carries. An account that already has a password gets 409
1863
+ * `password_already_set`; change it with `updatePassword` instead.
1864
+ *
1865
+ * The session stays valid — no re-login.
1866
+ */
1867
+ setPassword(newPassword: string): Promise<void>;
1829
1868
  verifyEmail(params: {
1830
1869
  token: string;
1831
1870
  } | {
@@ -245,6 +245,15 @@ interface PasswordChangeParams {
245
245
  current_password: string;
246
246
  new_password: string;
247
247
  }
248
+ /**
249
+ * Body of POST /auth/password/set — a passwordless account's FIRST password.
250
+ *
251
+ * No current password on purpose: the accounts this serves (passkey-first,
252
+ * social-only) do not have one, which is why `changePassword` answers them 401.
253
+ */
254
+ interface PasswordSetParams {
255
+ new_password: string;
256
+ }
248
257
  interface MFAEnrollParams {
249
258
  type: 'totp' | 'email';
250
259
  }
@@ -435,6 +444,18 @@ declare class AuthClient {
435
444
  changePassword(params: PasswordChangeParams): Promise<PalbaseResponse<{
436
445
  success: boolean;
437
446
  }>>;
447
+ /**
448
+ * Give a PASSWORDLESS account its first password.
449
+ *
450
+ * Separate from `changePassword` because that one cannot serve the case: it
451
+ * sends a current password and palauth answers an account that has none with
452
+ * 401. Requires a RECENT sign-in (403 `reauthentication_required` otherwise,
453
+ * the same gate passkey enrollment carries); an account that already has a
454
+ * password gets 409 `password_already_set`.
455
+ */
456
+ setPassword(params: PasswordSetParams): Promise<PalbaseResponse<{
457
+ success: boolean;
458
+ }>>;
438
459
  refresh(): Promise<PalbaseResponse<TokenResponse>>;
439
460
  getAccessToken(): string | null;
440
461
  onTokenChange(callback: (tokens: {
@@ -1826,6 +1847,24 @@ declare class PalbeAuth {
1826
1847
  currentPassword: string;
1827
1848
  newPassword: string;
1828
1849
  }): Promise<void>;
1850
+ /**
1851
+ * Give a passwordless account its FIRST password, in-app.
1852
+ *
1853
+ * For accounts created with a passkey or a social provider: they have no
1854
+ * current password, so `updatePassword` cannot serve them — it sends one and
1855
+ * the server answers 401. Before this existed the only route was the
1856
+ * password-RESET e-mail, which asks someone already signed in to go find
1857
+ * their inbox.
1858
+ *
1859
+ * Requires a RECENT sign-in, not merely a session: a first password is a
1860
+ * credential that outlives the rest, so the server answers 403
1861
+ * `reauthentication_required` on a stale one — the same gate
1862
+ * `registerPasskey` carries. An account that already has a password gets 409
1863
+ * `password_already_set`; change it with `updatePassword` instead.
1864
+ *
1865
+ * The session stays valid — no re-login.
1866
+ */
1867
+ setPassword(newPassword: string): Promise<void>;
1829
1868
  verifyEmail(params: {
1830
1869
  token: string;
1831
1870
  } | {
@@ -512,6 +512,20 @@ var AuthClient = class {
512
512
  body: params
513
513
  });
514
514
  }
515
+ /**
516
+ * Give a PASSWORDLESS account its first password.
517
+ *
518
+ * Separate from `changePassword` because that one cannot serve the case: it
519
+ * sends a current password and palauth answers an account that has none with
520
+ * 401. Requires a RECENT sign-in (403 `reauthentication_required` otherwise,
521
+ * the same gate passkey enrollment carries); an account that already has a
522
+ * password gets 409 `password_already_set`.
523
+ */
524
+ async setPassword(params) {
525
+ return this.httpClient.request("POST", "/auth/password/set", {
526
+ body: params
527
+ });
528
+ }
515
529
  // ── Token ───────────────────────────────────────────────
516
530
  async refresh() {
517
531
  const refreshToken = this.tokenManager.getRefreshToken();
@@ -1535,6 +1549,26 @@ var PalbeAuth = class {
1535
1549
  })
1536
1550
  );
1537
1551
  }
1552
+ /**
1553
+ * Give a passwordless account its FIRST password, in-app.
1554
+ *
1555
+ * For accounts created with a passkey or a social provider: they have no
1556
+ * current password, so `updatePassword` cannot serve them — it sends one and
1557
+ * the server answers 401. Before this existed the only route was the
1558
+ * password-RESET e-mail, which asks someone already signed in to go find
1559
+ * their inbox.
1560
+ *
1561
+ * Requires a RECENT sign-in, not merely a session: a first password is a
1562
+ * credential that outlives the rest, so the server answers 403
1563
+ * `reauthentication_required` on a stale one — the same gate
1564
+ * `registerPasskey` carries. An account that already has a password gets 409
1565
+ * `password_already_set`; change it with `updatePassword` instead.
1566
+ *
1567
+ * The session stays valid — no re-login.
1568
+ */
1569
+ async setPassword(newPassword) {
1570
+ unwrap(await this.rt.authClient.setPassword({ new_password: newPassword }));
1571
+ }
1538
1572
  async verifyEmail(params) {
1539
1573
  unwrap(await this.rt.authClient.verifyEmail(params));
1540
1574
  }
@@ -8839,7 +8873,7 @@ function defaultSessionStorage(key) {
8839
8873
  }
8840
8874
 
8841
8875
  // src/version.ts
8842
- var VERSION = "7.1.0";
8876
+ var VERSION = "7.2.1";
8843
8877
 
8844
8878
  // src/runtime.ts
8845
8879
  function buildRuntime(config) {
@@ -9264,4 +9298,4 @@ export {
9264
9298
  pb,
9265
9299
  createBoundClient
9266
9300
  };
9267
- //# sourceMappingURL=chunk-P6TWUWZC.js.map
9301
+ //# sourceMappingURL=chunk-GITHW5JK.js.map