@koolbase/react-native 12.14.0 → 12.15.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.
package/dist/cjs/index.js CHANGED
@@ -66,16 +66,19 @@ exports.Koolbase = {
66
66
  // the network. Tests leave this unset and run on the in-memory default.
67
67
  (0, core_1.setPlatform)(config.platform ?? (0, platform_js_2.reactNativePlatform)());
68
68
  _auth = new core_1.KoolbaseAuth(config);
69
+ // A data request refused with the signed-in person's token renews the
70
+ // session once and goes again (#96); only a refused renewal ends it.
71
+ (0, core_1.setSessionRenewal)((refused) => (_auth ? _auth.renewRejected(refused) : Promise.resolve(null)));
69
72
  _db = new core_1.KoolbaseDatabase(config, () => _auth?.currentUser?.id ?? null, () => _auth?.validAccessToken() ?? Promise.resolve(null),
70
73
  // A session the server refuses is not a session. Clearing it here means an
71
74
  // app catching KoolbaseUnauthenticatedError is already signed out and can
72
75
  // route to login, rather than looping on a dead token.
73
- async () => { await _auth?.clearStoredSession(); });
74
- _storage = new core_1.KoolbaseStorage(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); },
76
+ async () => { await _auth?.sessionRejected(); });
77
+ _storage = new core_1.KoolbaseStorage(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.sessionRejected(); },
75
78
  // Project identity for publicUrlFor, from the bootstrap payload; a
76
79
  // missing one nudges a refresh (as Flutter's storage client).
77
80
  () => _flags?.projectId() ?? '', () => { void _flags?.refresh(); });
78
- _fiscal = new core_1.KoolbaseFiscal(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
81
+ _fiscal = new core_1.KoolbaseFiscal(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.sessionRejected(); });
79
82
  _realtime = new core_1.KoolbaseRealtime(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), () => _auth?.currentUser?.id ?? null);
80
83
  // Signed in, signed out, another user: the realtime connection is
81
84
  // replaced to match (signed out, collections anyone can read only).
@@ -87,7 +90,7 @@ exports.Koolbase = {
87
90
  // Whether the device reports a connection: unknown until it first answers.
88
91
  _connectivity = new core_1.KoolbaseConnectivity();
89
92
  _connectivity.start();
90
- _functions = new core_1.KoolbaseFunctions(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
93
+ _functions = new core_1.KoolbaseFunctions(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.sessionRejected(); });
91
94
  // One anonymous device id for the whole SDK — bucketing (flags), targeting
92
95
  // (code push), and registration keying (messaging) must all agree on it.
93
96
  const deviceId = await (0, core_1.getOrCreateDeviceId)();
package/dist/esm/index.js CHANGED
@@ -7,7 +7,7 @@ import { Platform } from 'react-native';
7
7
  // React Native platform adapter and keychain-backed session storage.
8
8
  export * from '@koolbase/core';
9
9
  export { reactNativePlatform } from './platform.js';
10
- import { KoolbaseAuth, KoolbaseDatabase, KoolbaseFiscal, KoolbaseStorage, KoolbaseRealtime, KoolbaseFunctions, KoolbaseConnectivity, KoolbaseFlags, KoolbaseAnalytics, disabledAnalytics, KoolbaseMessaging, getOrCreateDeviceId, setPlatform, } from '@koolbase/core';
10
+ import { KoolbaseAuth, KoolbaseDatabase, KoolbaseFiscal, KoolbaseStorage, KoolbaseRealtime, KoolbaseFunctions, KoolbaseConnectivity, KoolbaseFlags, KoolbaseAnalytics, disabledAnalytics, KoolbaseMessaging, getOrCreateDeviceId, setPlatform, setSessionRenewal } from '@koolbase/core';
11
11
  import { reactNativePlatform } from './platform.js';
12
12
  import { createUseCollection, createUseRecord } from '@koolbase/core/react';
13
13
  let _auth = null;
@@ -48,16 +48,19 @@ export const Koolbase = {
48
48
  // the network. Tests leave this unset and run on the in-memory default.
49
49
  setPlatform(config.platform ?? reactNativePlatform());
50
50
  _auth = new KoolbaseAuth(config);
51
+ // A data request refused with the signed-in person's token renews the
52
+ // session once and goes again (#96); only a refused renewal ends it.
53
+ setSessionRenewal((refused) => (_auth ? _auth.renewRejected(refused) : Promise.resolve(null)));
51
54
  _db = new KoolbaseDatabase(config, () => _auth?.currentUser?.id ?? null, () => _auth?.validAccessToken() ?? Promise.resolve(null),
52
55
  // A session the server refuses is not a session. Clearing it here means an
53
56
  // app catching KoolbaseUnauthenticatedError is already signed out and can
54
57
  // route to login, rather than looping on a dead token.
55
- async () => { await _auth?.clearStoredSession(); });
56
- _storage = new KoolbaseStorage(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); },
58
+ async () => { await _auth?.sessionRejected(); });
59
+ _storage = new KoolbaseStorage(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.sessionRejected(); },
57
60
  // Project identity for publicUrlFor, from the bootstrap payload; a
58
61
  // missing one nudges a refresh (as Flutter's storage client).
59
62
  () => _flags?.projectId() ?? '', () => { void _flags?.refresh(); });
60
- _fiscal = new KoolbaseFiscal(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
63
+ _fiscal = new KoolbaseFiscal(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.sessionRejected(); });
61
64
  _realtime = new KoolbaseRealtime(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), () => _auth?.currentUser?.id ?? null);
62
65
  // Signed in, signed out, another user: the realtime connection is
63
66
  // replaced to match (signed out, collections anyone can read only).
@@ -69,7 +72,7 @@ export const Koolbase = {
69
72
  // Whether the device reports a connection: unknown until it first answers.
70
73
  _connectivity = new KoolbaseConnectivity();
71
74
  _connectivity.start();
72
- _functions = new KoolbaseFunctions(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
75
+ _functions = new KoolbaseFunctions(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.sessionRejected(); });
73
76
  // One anonymous device id for the whole SDK — bucketing (flags), targeting
74
77
  // (code push), and registration keying (messaging) must all agree on it.
75
78
  const deviceId = await getOrCreateDeviceId();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koolbase/react-native",
3
- "version": "12.14.0",
3
+ "version": "12.15.0",
4
4
  "description": "React Native SDK for Koolbase \u2014 auth, database, storage, realtime, feature flags, and functions in one package.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/koolbase/koolbase-react-native"
25
25
  },
26
26
  "dependencies": {
27
- "@koolbase/core": "12.14.0"
27
+ "@koolbase/core": "12.15.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@react-native-async-storage/async-storage": "^2.2.0 || ^3.0.2",