@koolbase/js 10.4.0 → 11.0.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 +60 -0
  2. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,66 @@ 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.0.0
11
+
12
+ ### Read before upgrading
13
+
14
+ **`register()` returns a result, not a user.** One line changes in your app,
15
+ and the reason is a bug this fixes.
16
+
17
+ Registration succeeding and authentication succeeding are different outcomes.
18
+ A project with `require_verified_contact` enabled creates the account and
19
+ issues **no session** — the user verifies their email before their first
20
+ sign-in. The server has always answered that case correctly: 201 with
21
+ `verification_required`, deliberately not an error, because reporting failure
22
+ for a signup that worked is worse than either alternative.
23
+
24
+ The SDK ignored that field. It built a session from a response body with no
25
+ tokens in it, persisted it, and answered `currentUser` with a user whose every
26
+ authenticated request went out as `Bearer undefined` and came back 401 —
27
+ signed in as far as the app could tell, and unable to do anything. Silent, and
28
+ only in the configuration that requires verification.
29
+
30
+ ```ts
31
+ // Before
32
+ const user = await Koolbase.auth.register({ email, password });
33
+
34
+ // After
35
+ const result = await Koolbase.auth.register({ email, password });
36
+ switch (result.status) {
37
+ case 'authenticated':
38
+ // result.session is live, the user is signed in
39
+ break;
40
+ case 'verification_required':
41
+ // the account exists, result.session is null, they verify first
42
+ break;
43
+ }
44
+ ```
45
+
46
+ A discriminated union rather than a nullable session, so there is no path
47
+ where an app reads `result.user` and assumes it is signed in. That is how the
48
+ bug worked, and a nullable field would have allowed it at one remove.
49
+
50
+ ### Fixed
51
+
52
+ - **A session is never fabricated from a response without tokens.** Every
53
+ path that builds one — register, login, refresh, Google, Apple — now refuses
54
+ a body claiming authentication while omitting a token, throwing
55
+ `MalformedSessionResponseError`. Distinct from `verification_required`,
56
+ which is a legitimate session-less success: this is a protocol violation and
57
+ says so.
58
+
59
+ - **A pending signup no longer touches existing state.** It persists nothing,
60
+ fires no auth-state change, and leaves a session already on the device
61
+ alone — registering a second account does not sign out the first.
62
+
63
+ ### Migration
64
+
65
+ Assign the result, switch on `status`. If your project does not require
66
+ verified contact, the `authenticated` branch is the only one you will see —
67
+ but write both, because turning that setting on later should not break your
68
+ signup flow.
69
+
10
70
  ## 10.4.0
11
71
 
12
72
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koolbase/js",
3
- "version": "10.4.0",
3
+ "version": "11.0.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.0.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"