@dogeos/dogeos-sdk 4.0.0-beta.7 → 4.0.0-beta.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.
Files changed (2) hide show
  1. package/dist/index.js +25 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -40707,24 +40707,31 @@ function YH(e) {
40707
40707
  function VH(e) {
40708
40708
  const t = bf(e);
40709
40709
  if (t.inFlight) return t.inFlight;
40710
- let r, n;
40711
- try {
40712
- n = Promise.resolve(e.getSession());
40713
- } catch (a) {
40714
- n = Promise.reject(a);
40715
- }
40716
- const i = new Promise((a) => {
40717
- r = setTimeout(
40718
- () => a({ kind: "unavailable" }),
40710
+ const r = t.generation;
40711
+ let n;
40712
+ const i = Promise.resolve().then(
40713
+ async () => {
40714
+ if (t.generation !== r)
40715
+ throw new Error("Provider session reconciliation was invalidated");
40716
+ const c = await e.getSession();
40717
+ if (c === null || Date.parse(c.expiresAt) > Date.now())
40718
+ return c;
40719
+ if (t.generation !== r)
40720
+ throw new Error("Provider session reconciliation was invalidated");
40721
+ return await e.refresh();
40722
+ }
40723
+ ), s = new Promise((c) => {
40724
+ n = setTimeout(
40725
+ () => c({ kind: "unavailable" }),
40719
40726
  jH
40720
40727
  );
40721
- }), s = n.then(
40722
- (a) => !a || Date.parse(a.expiresAt) <= Date.now() ? { kind: "anonymous" } : { kind: "authenticated", session: a },
40723
- () => ({ kind: "unavailable" })
40724
- ), o = Promise.race([s, i]).finally(() => {
40725
- r !== void 0 && clearTimeout(r), t.inFlight === o && (t.inFlight = null);
40728
+ }), o = i.then(
40729
+ (c) => c ? { kind: "authenticated", session: c } : { kind: "anonymous" },
40730
+ (c) => c instanceof $ && c.code === "session_revoked" ? { kind: "anonymous" } : { kind: "unavailable" }
40731
+ ), a = Promise.race([o, s]).finally(() => {
40732
+ n !== void 0 && clearTimeout(n), t.inFlight === a && (t.inFlight = null);
40726
40733
  });
40727
- return t.inFlight = o, o;
40734
+ return t.inFlight = a, a;
40728
40735
  }
40729
40736
  function fx(e) {
40730
40737
  if (!e) return !1;
@@ -41205,10 +41212,10 @@ function rX(e) {
41205
41212
  return e.walletReinitializationRequired || e.walletOperationActive ? null : e.pendingWalletCompletion ? o4(
41206
41213
  e.pendingWalletCompletion,
41207
41214
  e.snapshot
41208
- ) ? "pending_completion" : null : e.embeddedCustodyConnected && (e.establishedWalletAccount === null || e.snapshot.kind === "anonymous" || e.snapshot.kind === "authenticated" && (Date.parse(e.snapshot.session.expiresAt) <= Date.now() || !ig(
41215
+ ) ? "pending_completion" : null : e.embeddedCustodyConnected && (e.establishedWalletAccount === null || e.snapshot.kind === "anonymous" || e.snapshot.kind === "authenticated" && !ig(
41209
41216
  e.establishedWalletAccount,
41210
41217
  e.snapshot.session
41211
- ))) ? "established_custody" : null;
41218
+ )) ? "established_custody" : null;
41212
41219
  }
41213
41220
  function nX(e) {
41214
41221
  if (e.pendingWalletCompletion.current = null, e.establishedWalletAccount.current = null, e.resetWalletState(), !e.embeddedWallet) return Promise.resolve();
@@ -41251,7 +41258,7 @@ function iX(e, t) {
41251
41258
  m(), d += 1, Date.parse(q.session.expiresAt) > Date.now() ? c({
41252
41259
  kind: "authenticated",
41253
41260
  session: q.session
41254
- }) : f({ kind: "anonymous" });
41261
+ }) : b();
41255
41262
  else if (q.kind === "anonymous") {
41256
41263
  if (i?.()) {
41257
41264
  h = 0, b();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dogeos/dogeos-sdk",
3
3
  "private": false,
4
- "version": "4.0.0-beta.7",
4
+ "version": "4.0.0-beta.8",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",