@koolbase/js 10.0.0 → 10.0.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.
- package/CHANGELOG.md +16 -0
- package/README.md +6 -2
- package/dist/cjs/platform.js +17 -2
- package/dist/esm/platform.js +17 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,22 @@ 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
|
+
## 10.0.1
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **`restoreSession()` threw in Node.** With no `indexedDB`, the adapter fell
|
|
15
|
+
through to `localStorage`, which does not exist on a server either — so a
|
|
16
|
+
Next.js server render, or any tooling that imports the SDK, crashed with
|
|
17
|
+
`ReferenceError: localStorage is not defined`. Storage now falls back to an
|
|
18
|
+
in-memory store when neither is present, and a server render reports
|
|
19
|
+
`NoSession` rather than failing.
|
|
20
|
+
|
|
21
|
+
Note what this is not: server-side authentication. This package holds one
|
|
22
|
+
session per process, which is correct for a browser tab and wrong for a
|
|
23
|
+
server handling many users. It renders without crashing; it is not a way to
|
|
24
|
+
sign users in on a server.
|
|
25
|
+
|
|
10
26
|
## 10.0.0
|
|
11
27
|
|
|
12
28
|
The first release. Numbered to match `@koolbase/react-native` and
|
package/README.md
CHANGED
|
@@ -11,7 +11,8 @@ feature flags, remote config, and an offline write queue with conflict
|
|
|
11
11
|
resolution — one package, one `initialize()` call, TypeScript throughout.
|
|
12
12
|
|
|
13
13
|
Same core as [`@koolbase/react-native`](https://www.npmjs.com/package/@koolbase/react-native).
|
|
14
|
-
Same behaviour, proven by the same test suite on both hosts.
|
|
14
|
+
Same behaviour, proven by the same test suite on both hosts. The whole SDK
|
|
15
|
+
is about 16 kB gzipped.
|
|
15
16
|
|
|
16
17
|
---
|
|
17
18
|
|
|
@@ -261,7 +262,10 @@ Stated here so nothing is discovered as a method that fails:
|
|
|
261
262
|
- **Code push** — a native-bundle concept. The web already ships on deploy.
|
|
262
263
|
- **Push messaging** — FCM device tokens come from a native module. Use Web
|
|
263
264
|
Push through your own service worker and your backend.
|
|
264
|
-
- **
|
|
265
|
+
- **The native sign-in libraries** — `signInWithGoogle` and
|
|
266
|
+
`signInWithApple` themselves are here and work; what a browser cannot do
|
|
267
|
+
is fetch the credential from a native module. Run the provider's web
|
|
268
|
+
OAuth flow and pass the ID token, as above.
|
|
265
269
|
|
|
266
270
|
---
|
|
267
271
|
|
package/dist/cjs/platform.js
CHANGED
|
@@ -94,10 +94,25 @@ function browserVersion() {
|
|
|
94
94
|
const m = /(Chrome|Firefox|Safari|Edg)\/([\d.]+)/.exec(ua);
|
|
95
95
|
return m ? `${m[1]} ${m[2]}` : '';
|
|
96
96
|
}
|
|
97
|
+
// Neither store exists during server-side rendering, in a Node tool, or in
|
|
98
|
+
// a worker without storage access. Persisting nothing is the correct answer
|
|
99
|
+
// there: a server render has no session to restore, and the client hydrates
|
|
100
|
+
// with the real one. Throwing instead — which it did — crashes the render.
|
|
101
|
+
function memoryStorage() {
|
|
102
|
+
const m = new Map();
|
|
103
|
+
return {
|
|
104
|
+
getItem: async (k) => m.get(k) ?? null,
|
|
105
|
+
setItem: async (k, v) => { m.set(k, v); },
|
|
106
|
+
removeItem: async (k) => { m.delete(k); },
|
|
107
|
+
getAllKeys: async () => Array.from(m.keys()),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
97
110
|
function browserPlatform() {
|
|
98
|
-
const
|
|
111
|
+
const storage = typeof indexedDB !== 'undefined' ? indexedDBStorage()
|
|
112
|
+
: typeof localStorage !== 'undefined' ? localStorageStorage()
|
|
113
|
+
: memoryStorage();
|
|
99
114
|
return {
|
|
100
|
-
storage
|
|
115
|
+
storage,
|
|
101
116
|
network: {
|
|
102
117
|
onChange: (cb) => {
|
|
103
118
|
// navigator.onLine is a hint that the interface is up, not that
|
package/dist/esm/platform.js
CHANGED
|
@@ -91,10 +91,25 @@ function browserVersion() {
|
|
|
91
91
|
const m = /(Chrome|Firefox|Safari|Edg)\/([\d.]+)/.exec(ua);
|
|
92
92
|
return m ? `${m[1]} ${m[2]}` : '';
|
|
93
93
|
}
|
|
94
|
+
// Neither store exists during server-side rendering, in a Node tool, or in
|
|
95
|
+
// a worker without storage access. Persisting nothing is the correct answer
|
|
96
|
+
// there: a server render has no session to restore, and the client hydrates
|
|
97
|
+
// with the real one. Throwing instead — which it did — crashes the render.
|
|
98
|
+
function memoryStorage() {
|
|
99
|
+
const m = new Map();
|
|
100
|
+
return {
|
|
101
|
+
getItem: async (k) => m.get(k) ?? null,
|
|
102
|
+
setItem: async (k, v) => { m.set(k, v); },
|
|
103
|
+
removeItem: async (k) => { m.delete(k); },
|
|
104
|
+
getAllKeys: async () => Array.from(m.keys()),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
94
107
|
export function browserPlatform() {
|
|
95
|
-
const
|
|
108
|
+
const storage = typeof indexedDB !== 'undefined' ? indexedDBStorage()
|
|
109
|
+
: typeof localStorage !== 'undefined' ? localStorageStorage()
|
|
110
|
+
: memoryStorage();
|
|
96
111
|
return {
|
|
97
|
-
storage
|
|
112
|
+
storage,
|
|
98
113
|
network: {
|
|
99
114
|
onChange: (cb) => {
|
|
100
115
|
// navigator.onLine is a hint that the interface is up, not that
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koolbase/js",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.1",
|
|
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.0.
|
|
28
|
+
"@koolbase/core": "10.0.1"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|