jazz-tools 0.10.6 → 0.10.7

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.10.6 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.10.7 build /home/runner/_work/jazz/jazz/packages/jazz-tools
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
@@ -10,9 +10,9 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  ESM dist/index.js 1.50 KB
13
- ESM dist/testing.js 6.18 KB
14
- ESM dist/chunk-DPW23T6J.js 112.71 KB
13
+ ESM dist/testing.js 6.28 KB
14
+ ESM dist/chunk-TSEO4KAO.js 113.17 KB
15
15
  ESM dist/index.js.map 259.00 B
16
- ESM dist/testing.js.map 12.19 KB
17
- ESM dist/chunk-DPW23T6J.js.map 270.82 KB
18
- ESM ⚡️ Build success in 47ms
16
+ ESM dist/testing.js.map 12.41 KB
17
+ ESM dist/chunk-TSEO4KAO.js.map 271.81 KB
18
+ ESM ⚡️ Build success in 42ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.10.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 1136d9b: Fixed isAuthenticated out-of-sync with the account state during the logOut and authenticate flows
8
+ - 0eed228: Fixes clerk auth flow
9
+ - Updated dependencies [0f83320]
10
+ - Updated dependencies [012022d]
11
+ - cojson@0.10.7
12
+
3
13
  ## 0.10.6
4
14
 
5
15
  ### Patch Changes
@@ -528,7 +528,6 @@ async function createJazzContext(options) {
528
528
  authSecretStorage.clear();
529
529
  }
530
530
  });
531
- authSecretStorage.emitUpdate(credentials);
532
531
  } else {
533
532
  const secretSeed = options.crypto.newRandomSecretSeed();
534
533
  const initialAgentSecret = options.newAccountProps?.secret ?? crypto.agentSecretFromSecretSeed(secretSeed);
@@ -3437,6 +3436,7 @@ var KvStoreContext_default = KvStoreContext;
3437
3436
  var STORAGE_KEY = "jazz-logged-in-secret";
3438
3437
  var AuthSecretStorage = class {
3439
3438
  constructor() {
3439
+ this.notify = false;
3440
3440
  this.listeners = /* @__PURE__ */ new Set();
3441
3441
  this.isAuthenticated = false;
3442
3442
  }
@@ -3512,7 +3512,9 @@ var AuthSecretStorage = class {
3512
3512
  provider: payload.provider
3513
3513
  })
3514
3514
  );
3515
- this.emitUpdate(payload);
3515
+ if (this.notify) {
3516
+ this.emitUpdate(payload);
3517
+ }
3516
3518
  }
3517
3519
  getIsAuthenticated(data) {
3518
3520
  if (!data) return false;
@@ -3535,7 +3537,9 @@ var AuthSecretStorage = class {
3535
3537
  async clear() {
3536
3538
  const kvStore = KvStoreContext_default.getInstance().getStorage();
3537
3539
  await kvStore.delete(STORAGE_KEY);
3538
- this.emitUpdate(null);
3540
+ if (this.notify) {
3541
+ this.emitUpdate(null);
3542
+ }
3539
3543
  }
3540
3544
  };
3541
3545
 
@@ -3565,13 +3569,17 @@ import { cojsonInternals as cojsonInternals4 } from "cojson";
3565
3569
  var JazzContextManager = class {
3566
3570
  constructor() {
3567
3571
  this.authSecretStorage = new AuthSecretStorage();
3572
+ this.authSecretStorageWithNotify = Object.assign(
3573
+ Object.create(this.authSecretStorage),
3574
+ { notify: true }
3575
+ );
3568
3576
  this.authenticating = false;
3569
3577
  this.logOut = async () => {
3570
3578
  if (!this.context || !this.props) {
3571
3579
  return;
3572
3580
  }
3581
+ await this.props.onLogOut?.();
3573
3582
  await this.context.logOut();
3574
- this.props.onLogOut?.();
3575
3583
  return this.createContext(this.props);
3576
3584
  };
3577
3585
  this.done = () => {
@@ -3580,6 +3588,9 @@ var JazzContextManager = class {
3580
3588
  }
3581
3589
  this.context.done();
3582
3590
  };
3591
+ /**
3592
+ * Authenticates the user with the given credentials
3593
+ */
3583
3594
  this.authenticate = async (credentials) => {
3584
3595
  if (!this.props) {
3585
3596
  throw new Error("Props required");
@@ -3631,7 +3642,7 @@ var JazzContextManager = class {
3631
3642
  authProps;
3632
3643
  throw new Error("Not implemented");
3633
3644
  }
3634
- updateContext(props, context) {
3645
+ async updateContext(props, context, authProps) {
3635
3646
  if (!this.authenticating) {
3636
3647
  this.context?.done();
3637
3648
  }
@@ -3643,6 +3654,11 @@ var JazzContextManager = class {
3643
3654
  authenticate: this.authenticate,
3644
3655
  logOut: this.logOut
3645
3656
  };
3657
+ if (authProps?.credentials) {
3658
+ this.authSecretStorage.emitUpdate(authProps.credentials);
3659
+ } else {
3660
+ this.authSecretStorage.emitUpdate(await this.authSecretStorage.get());
3661
+ }
3646
3662
  this.notify();
3647
3663
  }
3648
3664
  propsChanged(props) {
@@ -3653,7 +3669,7 @@ var JazzContextManager = class {
3653
3669
  return this.value;
3654
3670
  }
3655
3671
  getAuthSecretStorage() {
3656
- return this.authSecretStorage;
3672
+ return this.authSecretStorageWithNotify;
3657
3673
  }
3658
3674
  notify() {
3659
3675
  for (const listener of this.listeners) {
@@ -3956,4 +3972,4 @@ export {
3956
3972
  consumeInviteLink
3957
3973
  };
3958
3974
  /* istanbul ignore file -- @preserve */
3959
- //# sourceMappingURL=chunk-DPW23T6J.js.map
3975
+ //# sourceMappingURL=chunk-TSEO4KAO.js.map