@koolbase/js 12.0.0 → 12.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,33 @@ 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
+ ## 12.1.0
11
+
12
+ ### Added
13
+
14
+ - **Sign in with an emailed code.** `auth.requestEmailCode({ email })` sends a
15
+ six-digit code; `auth.signInWithEmailCode({ email, code })` signs in and
16
+ stores the session exactly as `login()` does. An unknown address becomes an
17
+ account only while the project accepts sign-ups. Each code works once and
18
+ allows three attempts. The request resolves the same way whether or not the
19
+ address has an account. A project can switch this off; requests then throw
20
+ `EmailCodeDisabledError`.
21
+ - **Fiscal.** `KoolbaseFiscal` with `submit()` and `status()`, and
22
+ `KoolbaseFiscalError`. A timeout on `submit` means poll `status()` with the
23
+ same `clientRef` — do not submit again, or the sale may be recorded twice.
24
+ - **Reference errors are catchable.** `KoolbaseReferenceInvalidError`,
25
+ `KoolbaseReferenceInUseError`, `KoolbaseDanglingReferencesError` (carrying
26
+ the offending records) and `KoolbaseCollectionReferencedError`.
27
+
28
+ ### Changed
29
+
30
+ - The OTP errors (`OtpInvalidError`, `OtpExpiredError`,
31
+ `OtpMaxAttemptsError`) now come from the shared error mapping, so every path
32
+ that returns them throws the class an app catches.
33
+ - `oauthLogin()`'s deprecation now points to `signInWithGoogle()` and
34
+ `signInWithApple()`. It said OAuth was not yet shipped and to use email and
35
+ password instead, which had long stopped being true.
36
+
10
37
  ## 12.0.0
11
38
 
12
39
  ### Breaking
package/README.md CHANGED
@@ -98,6 +98,17 @@ If your app needs a different trade-off — an httpOnly cookie set by your own
98
98
  backend, say — implement `KoolbaseAuthStorage` and pass it as
99
99
  `config.authStorage`. The SDK will use yours instead of its own.
100
100
 
101
+ ### Email code
102
+
103
+ ```typescript
104
+ await Koolbase.auth.requestEmailCode({ email: 'user@example.com' });
105
+ await Koolbase.auth.signInWithEmailCode({ email: 'user@example.com', code: '123456' });
106
+ ```
107
+
108
+ A new address becomes an account only while sign-ups are open. Each code works
109
+ once, allows three attempts, and expires after ten minutes. Projects can switch
110
+ this off in auth settings.
111
+
101
112
  ### Phone + OTP
102
113
 
103
114
  ```typescript
@@ -1,12 +1,13 @@
1
1
  export * from '@koolbase/core';
2
2
  export { BrowserAuthStorage } from './auth-storage.js';
3
3
  export { browserPlatform } from './platform.js';
4
- import { KoolbaseAuth, KoolbaseDatabase, KoolbaseStorage, KoolbaseRealtime, KoolbaseFunctions, KoolbaseAnalytics, type KoolbaseConfig, type VersionCheckResult } from '@koolbase/core';
4
+ import { KoolbaseAuth, KoolbaseDatabase, KoolbaseFiscal, KoolbaseStorage, KoolbaseRealtime, KoolbaseFunctions, KoolbaseAnalytics, type KoolbaseConfig, type VersionCheckResult } from '@koolbase/core';
5
5
  export declare const Koolbase: {
6
6
  initialize(config: KoolbaseConfig): Promise<void>;
7
7
  readonly auth: KoolbaseAuth;
8
8
  readonly db: KoolbaseDatabase;
9
9
  readonly storage: KoolbaseStorage;
10
+ readonly fiscal: KoolbaseFiscal;
10
11
  readonly realtime: KoolbaseRealtime;
11
12
  readonly functions: KoolbaseFunctions;
12
13
  readonly analytics: KoolbaseAnalytics;
package/dist/cjs/index.js CHANGED
@@ -33,6 +33,7 @@ const platform_js_2 = require("./platform.js");
33
33
  let _auth = null;
34
34
  let _db = null;
35
35
  let _storage = null;
36
+ let _fiscal = null;
36
37
  let _realtime = null;
37
38
  let _functions = null;
38
39
  let _flags = null;
@@ -63,6 +64,7 @@ exports.Koolbase = {
63
64
  _auth = new core_1.KoolbaseAuth(config);
64
65
  _db = new core_1.KoolbaseDatabase(config, () => _auth?.currentUser?.id ?? null, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
65
66
  _storage = new core_1.KoolbaseStorage(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
67
+ _fiscal = new core_1.KoolbaseFiscal(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
66
68
  _realtime = new core_1.KoolbaseRealtime(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), () => _auth?.currentUser?.id ?? null);
67
69
  _functions = new core_1.KoolbaseFunctions(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
68
70
  const deviceId = await (0, core_1.getOrCreateDeviceId)();
@@ -85,6 +87,7 @@ exports.Koolbase = {
85
87
  get auth() { ensureInitialized(); return _auth; },
86
88
  get db() { ensureInitialized(); return _db; },
87
89
  get storage() { ensureInitialized(); return _storage; },
90
+ get fiscal() { ensureInitialized(); return _fiscal; },
88
91
  get realtime() { ensureInitialized(); return _realtime; },
89
92
  get functions() { ensureInitialized(); return _functions; },
90
93
  get analytics() {
@@ -1,12 +1,13 @@
1
1
  export * from '@koolbase/core';
2
2
  export { BrowserAuthStorage } from './auth-storage.js';
3
3
  export { browserPlatform } from './platform.js';
4
- import { KoolbaseAuth, KoolbaseDatabase, KoolbaseStorage, KoolbaseRealtime, KoolbaseFunctions, KoolbaseAnalytics, type KoolbaseConfig, type VersionCheckResult } from '@koolbase/core';
4
+ import { KoolbaseAuth, KoolbaseDatabase, KoolbaseFiscal, KoolbaseStorage, KoolbaseRealtime, KoolbaseFunctions, KoolbaseAnalytics, type KoolbaseConfig, type VersionCheckResult } from '@koolbase/core';
5
5
  export declare const Koolbase: {
6
6
  initialize(config: KoolbaseConfig): Promise<void>;
7
7
  readonly auth: KoolbaseAuth;
8
8
  readonly db: KoolbaseDatabase;
9
9
  readonly storage: KoolbaseStorage;
10
+ readonly fiscal: KoolbaseFiscal;
10
11
  readonly realtime: KoolbaseRealtime;
11
12
  readonly functions: KoolbaseFunctions;
12
13
  readonly analytics: KoolbaseAnalytics;
package/dist/esm/index.js CHANGED
@@ -9,11 +9,12 @@
9
9
  export * from '@koolbase/core';
10
10
  export { BrowserAuthStorage } from './auth-storage.js';
11
11
  export { browserPlatform } from './platform.js';
12
- import { KoolbaseAuth, KoolbaseDatabase, KoolbaseStorage, KoolbaseRealtime, KoolbaseFunctions, KoolbaseFlags, KoolbaseAnalytics, getOrCreateDeviceId, setPlatform, } from '@koolbase/core';
12
+ import { KoolbaseAuth, KoolbaseDatabase, KoolbaseFiscal, KoolbaseStorage, KoolbaseRealtime, KoolbaseFunctions, KoolbaseFlags, KoolbaseAnalytics, getOrCreateDeviceId, setPlatform, } from '@koolbase/core';
13
13
  import { browserPlatform } from './platform.js';
14
14
  let _auth = null;
15
15
  let _db = null;
16
16
  let _storage = null;
17
+ let _fiscal = null;
17
18
  let _realtime = null;
18
19
  let _functions = null;
19
20
  let _flags = null;
@@ -44,6 +45,7 @@ export const Koolbase = {
44
45
  _auth = new KoolbaseAuth(config);
45
46
  _db = new KoolbaseDatabase(config, () => _auth?.currentUser?.id ?? null, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
46
47
  _storage = new KoolbaseStorage(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
48
+ _fiscal = new KoolbaseFiscal(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
47
49
  _realtime = new KoolbaseRealtime(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), () => _auth?.currentUser?.id ?? null);
48
50
  _functions = new KoolbaseFunctions(config, () => _auth?.validAccessToken() ?? Promise.resolve(null), async () => { await _auth?.clearStoredSession(); });
49
51
  const deviceId = await getOrCreateDeviceId();
@@ -66,6 +68,7 @@ export const Koolbase = {
66
68
  get auth() { ensureInitialized(); return _auth; },
67
69
  get db() { ensureInitialized(); return _db; },
68
70
  get storage() { ensureInitialized(); return _storage; },
71
+ get fiscal() { ensureInitialized(); return _fiscal; },
69
72
  get realtime() { ensureInitialized(); return _realtime; },
70
73
  get functions() { ensureInitialized(); return _functions; },
71
74
  get analytics() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koolbase/js",
3
- "version": "12.0.0",
3
+ "version": "12.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": "12.0.0"
28
+ "@koolbase/core": "12.1.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"