jazz-tools 0.10.6 → 0.10.8
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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +18 -0
- package/dist/{chunk-DPW23T6J.js → chunk-6OJCOJJ6.js} +46 -9
- package/dist/chunk-6OJCOJJ6.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/testing.js +21 -13
- package/dist/testing.js.map +1 -1
- package/package.json +2 -2
- package/src/auth/AuthSecretStorage.ts +9 -2
- package/src/coValues/deepLoading.ts +25 -2
- package/src/coValues/interfaces.ts +1 -0
- package/src/implementation/ContextManager.ts +23 -4
- package/src/implementation/createContext.ts +0 -3
- package/src/testing.ts +22 -12
- package/src/tests/AuthSecretStorage.test.ts +192 -66
- package/src/tests/ContextManager.test.ts +14 -9
- package/src/tests/coMap.test.ts +2 -2
- package/src/tests/deepLoading.test.ts +85 -1
- package/src/tests/subscribe.test.ts +39 -0
- package/src/types.ts +2 -0
- package/dist/chunk-DPW23T6J.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.10.
|
2
|
+
> jazz-tools@0.10.8 build /home/runner/_work/jazz/jazz/packages/jazz-tools
|
3
3
|
> tsup
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
|
@@ -10,9 +10,9 @@
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
11
11
|
[34mESM[39m Build start
|
12
12
|
[32mESM[39m [1mdist/index.js [22m[32m1.50 KB[39m
|
13
|
-
[32mESM[39m [1mdist/testing.js [22m[32m6.
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
13
|
+
[32mESM[39m [1mdist/testing.js [22m[32m6.28 KB[39m
|
14
|
+
[32mESM[39m [1mdist/chunk-6OJCOJJ6.js [22m[32m113.88 KB[39m
|
15
15
|
[32mESM[39m [1mdist/index.js.map [22m[32m259.00 B[39m
|
16
|
-
[32mESM[39m [1mdist/testing.js.map [22m[32m12.
|
17
|
-
[32mESM[39m [1mdist/chunk-
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
16
|
+
[32mESM[39m [1mdist/testing.js.map [22m[32m12.41 KB[39m
|
17
|
+
[32mESM[39m [1mdist/chunk-6OJCOJJ6.js.map [22m[32m273.01 KB[39m
|
18
|
+
[32mESM[39m ⚡️ Build success in 40ms
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# jazz-tools
|
2
2
|
|
3
|
+
## 0.10.8
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 2fb6428: Allow explicit keys when loading values from a CoMap.Record and throw when a required ref is undefined
|
8
|
+
- Updated dependencies [153dc99]
|
9
|
+
- cojson@0.10.8
|
10
|
+
|
11
|
+
## 0.10.7
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- 1136d9b: Fixed isAuthenticated out-of-sync with the account state during the logOut and authenticate flows
|
16
|
+
- 0eed228: Fixes clerk auth flow
|
17
|
+
- Updated dependencies [0f83320]
|
18
|
+
- Updated dependencies [012022d]
|
19
|
+
- cojson@0.10.7
|
20
|
+
|
3
21
|
## 0.10.6
|
4
22
|
|
5
23
|
### Patch Changes
|
@@ -58,8 +58,28 @@ function fulfillsDepth(depth, value) {
|
|
58
58
|
} else {
|
59
59
|
for (const key of Object.keys(depth)) {
|
60
60
|
const map = value;
|
61
|
-
if (
|
62
|
-
|
61
|
+
if (map._raw.get(key) === void 0) {
|
62
|
+
if (!map._schema?.[key]) {
|
63
|
+
if (map._schema?.[ItemsSym]) {
|
64
|
+
if (map._schema[ItemsSym].optional) {
|
65
|
+
continue;
|
66
|
+
} else {
|
67
|
+
throw new Error(
|
68
|
+
`The ref ${key} requested on ${map.constructor.name} is missing`
|
69
|
+
);
|
70
|
+
}
|
71
|
+
} else {
|
72
|
+
throw new Error(
|
73
|
+
`The ref ${key} requested on ${map.constructor.name} is not defined in the schema`
|
74
|
+
);
|
75
|
+
}
|
76
|
+
} else if (map._schema[key].optional) {
|
77
|
+
continue;
|
78
|
+
} else {
|
79
|
+
throw new Error(
|
80
|
+
`The ref ${key} on ${map.constructor.name} is required but missing`
|
81
|
+
);
|
82
|
+
}
|
63
83
|
}
|
64
84
|
if (!map[key]) {
|
65
85
|
return false;
|
@@ -528,7 +548,6 @@ async function createJazzContext(options) {
|
|
528
548
|
authSecretStorage.clear();
|
529
549
|
}
|
530
550
|
});
|
531
|
-
authSecretStorage.emitUpdate(credentials);
|
532
551
|
} else {
|
533
552
|
const secretSeed = options.crypto.newRandomSecretSeed();
|
534
553
|
const initialAgentSecret = options.newAccountProps?.secret ?? crypto.agentSecretFromSecretSeed(secretSeed);
|
@@ -811,6 +830,7 @@ function subscribeToCoValue(cls, id, as, depth, listener, onUnavailable, syncRes
|
|
811
830
|
} else {
|
812
831
|
ref2.load().then((value) => subscribe(value)).catch((e) => {
|
813
832
|
console.error("Failed to load / subscribe to CoValue", e);
|
833
|
+
onUnavailable?.();
|
814
834
|
});
|
815
835
|
}
|
816
836
|
return function unsubscribeAtAnyPoint() {
|
@@ -3437,6 +3457,7 @@ var KvStoreContext_default = KvStoreContext;
|
|
3437
3457
|
var STORAGE_KEY = "jazz-logged-in-secret";
|
3438
3458
|
var AuthSecretStorage = class {
|
3439
3459
|
constructor() {
|
3460
|
+
this.notify = false;
|
3440
3461
|
this.listeners = /* @__PURE__ */ new Set();
|
3441
3462
|
this.isAuthenticated = false;
|
3442
3463
|
}
|
@@ -3512,7 +3533,9 @@ var AuthSecretStorage = class {
|
|
3512
3533
|
provider: payload.provider
|
3513
3534
|
})
|
3514
3535
|
);
|
3515
|
-
this.
|
3536
|
+
if (this.notify) {
|
3537
|
+
this.emitUpdate(payload);
|
3538
|
+
}
|
3516
3539
|
}
|
3517
3540
|
getIsAuthenticated(data) {
|
3518
3541
|
if (!data) return false;
|
@@ -3535,7 +3558,9 @@ var AuthSecretStorage = class {
|
|
3535
3558
|
async clear() {
|
3536
3559
|
const kvStore = KvStoreContext_default.getInstance().getStorage();
|
3537
3560
|
await kvStore.delete(STORAGE_KEY);
|
3538
|
-
this.
|
3561
|
+
if (this.notify) {
|
3562
|
+
this.emitUpdate(null);
|
3563
|
+
}
|
3539
3564
|
}
|
3540
3565
|
};
|
3541
3566
|
|
@@ -3565,13 +3590,17 @@ import { cojsonInternals as cojsonInternals4 } from "cojson";
|
|
3565
3590
|
var JazzContextManager = class {
|
3566
3591
|
constructor() {
|
3567
3592
|
this.authSecretStorage = new AuthSecretStorage();
|
3593
|
+
this.authSecretStorageWithNotify = Object.assign(
|
3594
|
+
Object.create(this.authSecretStorage),
|
3595
|
+
{ notify: true }
|
3596
|
+
);
|
3568
3597
|
this.authenticating = false;
|
3569
3598
|
this.logOut = async () => {
|
3570
3599
|
if (!this.context || !this.props) {
|
3571
3600
|
return;
|
3572
3601
|
}
|
3602
|
+
await this.props.onLogOut?.();
|
3573
3603
|
await this.context.logOut();
|
3574
|
-
this.props.onLogOut?.();
|
3575
3604
|
return this.createContext(this.props);
|
3576
3605
|
};
|
3577
3606
|
this.done = () => {
|
@@ -3580,6 +3609,9 @@ var JazzContextManager = class {
|
|
3580
3609
|
}
|
3581
3610
|
this.context.done();
|
3582
3611
|
};
|
3612
|
+
/**
|
3613
|
+
* Authenticates the user with the given credentials
|
3614
|
+
*/
|
3583
3615
|
this.authenticate = async (credentials) => {
|
3584
3616
|
if (!this.props) {
|
3585
3617
|
throw new Error("Props required");
|
@@ -3631,7 +3663,7 @@ var JazzContextManager = class {
|
|
3631
3663
|
authProps;
|
3632
3664
|
throw new Error("Not implemented");
|
3633
3665
|
}
|
3634
|
-
updateContext(props, context) {
|
3666
|
+
async updateContext(props, context, authProps) {
|
3635
3667
|
if (!this.authenticating) {
|
3636
3668
|
this.context?.done();
|
3637
3669
|
}
|
@@ -3643,6 +3675,11 @@ var JazzContextManager = class {
|
|
3643
3675
|
authenticate: this.authenticate,
|
3644
3676
|
logOut: this.logOut
|
3645
3677
|
};
|
3678
|
+
if (authProps?.credentials) {
|
3679
|
+
this.authSecretStorage.emitUpdate(authProps.credentials);
|
3680
|
+
} else {
|
3681
|
+
this.authSecretStorage.emitUpdate(await this.authSecretStorage.get());
|
3682
|
+
}
|
3646
3683
|
this.notify();
|
3647
3684
|
}
|
3648
3685
|
propsChanged(props) {
|
@@ -3653,7 +3690,7 @@ var JazzContextManager = class {
|
|
3653
3690
|
return this.value;
|
3654
3691
|
}
|
3655
3692
|
getAuthSecretStorage() {
|
3656
|
-
return this.
|
3693
|
+
return this.authSecretStorageWithNotify;
|
3657
3694
|
}
|
3658
3695
|
notify() {
|
3659
3696
|
for (const listener of this.listeners) {
|
@@ -3956,4 +3993,4 @@ export {
|
|
3956
3993
|
consumeInviteLink
|
3957
3994
|
};
|
3958
3995
|
/* istanbul ignore file -- @preserve */
|
3959
|
-
//# sourceMappingURL=chunk-
|
3996
|
+
//# sourceMappingURL=chunk-6OJCOJJ6.js.map
|