@koolbase/js 12.0.0 → 12.2.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 +42 -0
- package/README.md +27 -0
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +3 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +4 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,48 @@ 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.2.0
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Two-step sign-in (MFA).** Every sign-in method now throws `MfaRequiredError`
|
|
15
|
+
carrying a `challengeToken` when the person's account has an authenticator on
|
|
16
|
+
— including phone, Google and Apple, whose error parsers all map it, enforced
|
|
17
|
+
by a source test for any parser added later. `verifyMfa({ challengeToken, code
|
|
18
|
+
})` and `verifyRecoveryCode({ challengeToken, code })` finish sign-in and
|
|
19
|
+
store the session, returning `{ session, recoveryCodesRemaining }` for the
|
|
20
|
+
latter.
|
|
21
|
+
- `enrollMfa()`, `confirmMfaEnrollment(code)`, `mfaStatus()`, `stepUpMfa(…)`,
|
|
22
|
+
`disableMfa()`, and `regenerateRecoveryCodes()` manage it. Six new error
|
|
23
|
+
classes in the mapping table and fidelity list.
|
|
24
|
+
|
|
25
|
+
## 12.1.0
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- **Sign in with an emailed code.** `auth.requestEmailCode({ email })` sends a
|
|
30
|
+
six-digit code; `auth.signInWithEmailCode({ email, code })` signs in and
|
|
31
|
+
stores the session exactly as `login()` does. An unknown address becomes an
|
|
32
|
+
account only while the project accepts sign-ups. Each code works once and
|
|
33
|
+
allows three attempts. The request resolves the same way whether or not the
|
|
34
|
+
address has an account. A project can switch this off; requests then throw
|
|
35
|
+
`EmailCodeDisabledError`.
|
|
36
|
+
- **Fiscal.** `KoolbaseFiscal` with `submit()` and `status()`, and
|
|
37
|
+
`KoolbaseFiscalError`. A timeout on `submit` means poll `status()` with the
|
|
38
|
+
same `clientRef` — do not submit again, or the sale may be recorded twice.
|
|
39
|
+
- **Reference errors are catchable.** `KoolbaseReferenceInvalidError`,
|
|
40
|
+
`KoolbaseReferenceInUseError`, `KoolbaseDanglingReferencesError` (carrying
|
|
41
|
+
the offending records) and `KoolbaseCollectionReferencedError`.
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
|
|
45
|
+
- The OTP errors (`OtpInvalidError`, `OtpExpiredError`,
|
|
46
|
+
`OtpMaxAttemptsError`) now come from the shared error mapping, so every path
|
|
47
|
+
that returns them throws the class an app catches.
|
|
48
|
+
- `oauthLogin()`'s deprecation now points to `signInWithGoogle()` and
|
|
49
|
+
`signInWithApple()`. It said OAuth was not yet shipped and to use email and
|
|
50
|
+
password instead, which had long stopped being true.
|
|
51
|
+
|
|
10
52
|
## 12.0.0
|
|
11
53
|
|
|
12
54
|
### Breaking
|
package/README.md
CHANGED
|
@@ -98,6 +98,33 @@ 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
|
+
### Two-step sign-in (MFA)
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// After login() throws MfaRequiredError:
|
|
105
|
+
const session = await Koolbase.auth.verifyMfa({
|
|
106
|
+
challengeToken: err.challengeToken,
|
|
107
|
+
code: '123456', // from the person's authenticator app
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Enrol (within 10 minutes of signing in):
|
|
111
|
+
const { otpauthUri, secret } = await Koolbase.auth.enrollMfa();
|
|
112
|
+
// show otpauthUri as a QR code, then:
|
|
113
|
+
const codes = await Koolbase.auth.confirmMfaEnrollment('123456');
|
|
114
|
+
// save the recovery codes — shown this once only
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Email code
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
await Koolbase.auth.requestEmailCode({ email: 'user@example.com' });
|
|
121
|
+
await Koolbase.auth.signInWithEmailCode({ email: 'user@example.com', code: '123456' });
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
A new address becomes an account only while sign-ups are open. Each code works
|
|
125
|
+
once, allows three attempts, and expires after ten minutes. Projects can switch
|
|
126
|
+
this off in auth settings.
|
|
127
|
+
|
|
101
128
|
### Phone + OTP
|
|
102
129
|
|
|
103
130
|
```typescript
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -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() {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "12.2.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.
|
|
28
|
+
"@koolbase/core": "12.2.0"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|