@koolbase/js 10.4.0 → 11.1.0

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.
Files changed (2) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,109 @@ is based on [Keep a Changelog][kac], and this project adheres to
7
7
  [kac]: https://keepachangelog.com/en/1.1.0/
8
8
  [semver]: https://semver.org/
9
9
 
10
+ ## 11.1.0
11
+
12
+ ### Fixed
13
+
14
+ - **Fourteen error codes the API emits were not mapped**, so they arrived as
15
+ a generic error and an app's `instanceof` branch silently never ran. The
16
+ most consequential is `contact_not_verified` — in a project with verified
17
+ contact required, a user who registers, does not click the link, and comes
18
+ back is the *commonest* auth failure there is, and it had no type. Now:
19
+
20
+ | Code | Class |
21
+ |---|---|
22
+ | `contact_not_verified`, `email_not_verified` | `ContactNotVerifiedError` |
23
+ | `signups_disabled` | `SignupsDisabledError` |
24
+ | `weak_password` | `WeakPasswordError` (existed, never mapped from the server) |
25
+ | `account_exists` | `AccountExistsError` |
26
+ | `token_expired` | `TokenExpiredError` |
27
+ | `token_used` | `TokenAlreadyUsedError` |
28
+ | `invalid_token` | `UnlockTokenInvalidError` |
29
+ | `invalid_password` | `CurrentPasswordIncorrectError` |
30
+ | `oauth_only_account` | `OAuthOnlyAccountError` |
31
+ | `unsupported_oauth_provider` | `UnsupportedOAuthProviderError` |
32
+ | `session_required` | `SessionRequiredError` |
33
+ | `insufficient_authority` | `InsufficientAuthorityError` |
34
+ | `last_credential` | `LastCredentialError` |
35
+ | `hide_requires_verification` | `HideRequiresVerificationError` |
36
+
37
+ `CurrentPasswordIncorrectError` is named for the operation rather than the
38
+ code: the server calls it `invalid_password`, which reads like a rejected
39
+ new password and means the opposite.
40
+
41
+ - **`WeakPasswordError` carries the server's message** when there is one. The
42
+ SDK checks length before sending; a project may require more, and "must be
43
+ at least 8 characters" would then be both wrong and unhelpful. Its
44
+ constructor argument is optional, so existing code is unaffected.
45
+
46
+ ### Why these were missing
47
+
48
+ Nothing inside the SDK can tell that a code fell through — the generic error
49
+ is a valid object and the app's branch simply does not run. There is now a
50
+ test that asserts every code maps to its own class, so a new code added to the
51
+ API without a case here fails the build rather than a user's password reset.
52
+
53
+ ## 11.0.0
54
+
55
+ ### Read before upgrading
56
+
57
+ **`register()` returns a result, not a user.** One line changes in your app,
58
+ and the reason is a bug this fixes.
59
+
60
+ Registration succeeding and authentication succeeding are different outcomes.
61
+ A project with `require_verified_contact` enabled creates the account and
62
+ issues **no session** — the user verifies their email before their first
63
+ sign-in. The server has always answered that case correctly: 201 with
64
+ `verification_required`, deliberately not an error, because reporting failure
65
+ for a signup that worked is worse than either alternative.
66
+
67
+ The SDK ignored that field. It built a session from a response body with no
68
+ tokens in it, persisted it, and answered `currentUser` with a user whose every
69
+ authenticated request went out as `Bearer undefined` and came back 401 —
70
+ signed in as far as the app could tell, and unable to do anything. Silent, and
71
+ only in the configuration that requires verification.
72
+
73
+ ```ts
74
+ // Before
75
+ const user = await Koolbase.auth.register({ email, password });
76
+
77
+ // After
78
+ const result = await Koolbase.auth.register({ email, password });
79
+ switch (result.status) {
80
+ case 'authenticated':
81
+ // result.session is live, the user is signed in
82
+ break;
83
+ case 'verification_required':
84
+ // the account exists, result.session is null, they verify first
85
+ break;
86
+ }
87
+ ```
88
+
89
+ A discriminated union rather than a nullable session, so there is no path
90
+ where an app reads `result.user` and assumes it is signed in. That is how the
91
+ bug worked, and a nullable field would have allowed it at one remove.
92
+
93
+ ### Fixed
94
+
95
+ - **A session is never fabricated from a response without tokens.** Every
96
+ path that builds one — register, login, refresh, Google, Apple — now refuses
97
+ a body claiming authentication while omitting a token, throwing
98
+ `MalformedSessionResponseError`. Distinct from `verification_required`,
99
+ which is a legitimate session-less success: this is a protocol violation and
100
+ says so.
101
+
102
+ - **A pending signup no longer touches existing state.** It persists nothing,
103
+ fires no auth-state change, and leaves a session already on the device
104
+ alone — registering a second account does not sign out the first.
105
+
106
+ ### Migration
107
+
108
+ Assign the result, switch on `status`. If your project does not require
109
+ verified contact, the `authenticated` branch is the only one you will see —
110
+ but write both, because turning that setting on later should not break your
111
+ signup flow.
112
+
10
113
  ## 10.4.0
11
114
 
12
115
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koolbase/js",
3
- "version": "10.4.0",
3
+ "version": "11.1.0",
4
4
  "description": "Koolbase SDK for the browser \u2014 auth, database, storage, realtime, functions, flags and offline sync in one package.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "url": "https://github.com/koolbase/koolbase-react-native"
26
26
  },
27
27
  "dependencies": {
28
- "@koolbase/core": "10.4.0"
28
+ "@koolbase/core": "11.1.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"