@tempoxyz/id 0.0.0-pr-723.sha-e2f626f → 0.0.0-pr-670.sha-e3c7fc8

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.
@@ -4,8 +4,8 @@ import {
4
4
  name,
5
5
  parseName,
6
6
  pending
7
- } from "./chunk-K4WPSEXZ.js";
8
- import "./chunk-AOIGHDXR.js";
7
+ } from "./chunk-7JMEEUUA.js";
8
+ import "./chunk-MTJSZT4S.js";
9
9
  import "./chunk-YW5DUQT3.js";
10
10
  import "./chunk-MLKGABMK.js";
11
11
  export {
@@ -4,7 +4,7 @@ import {
4
4
  machines,
5
5
  prompt,
6
6
  waiting
7
- } from "./chunk-AOIGHDXR.js";
7
+ } from "./chunk-MTJSZT4S.js";
8
8
  import "./chunk-MLKGABMK.js";
9
9
  export {
10
10
  create,
@@ -5,7 +5,7 @@ import {
5
5
  expired,
6
6
  from,
7
7
  revokeAccessKey
8
- } from "./chunk-AOIGHDXR.js";
8
+ } from "./chunk-MTJSZT4S.js";
9
9
  import {
10
10
  from as from2
11
11
  } from "./chunk-YW5DUQT3.js";
@@ -308,7 +308,6 @@ async function clientAuthentication(auth) {
308
308
  if (auth.clientSecret) return { client_secret: auth.clientSecret };
309
309
  return {};
310
310
  }
311
- var revokeTimeout = 1e4;
312
311
  async function revoke(auth, options) {
313
312
  const body = new URLSearchParams({
314
313
  client_id: auth.clientId,
@@ -316,38 +315,29 @@ async function revoke(auth, options) {
316
315
  token_type_hint: "refresh_token",
317
316
  ...await clientAuthentication(auth)
318
317
  });
319
- const controller = new AbortController();
320
- const timer = setTimeout(() => controller.abort(), revokeTimeout);
321
- try {
322
- const response = await (auth.fetch ?? fetch)(
323
- new URL("/oauth2/revoke", auth.url),
324
- {
325
- body,
326
- // A session cookie fails the issuer's origin check, and the revocation needs none.
327
- credentials: "omit",
328
- method: "POST",
329
- // A redirect would send the refresh token and the client authentication to another origin.
330
- redirect: "manual",
331
- signal: controller.signal
332
- }
333
- ).catch((error3) => {
334
- if (controller.signal.aborted) return void 0;
335
- throw new RequestError({
336
- cause: error3,
337
- code: "server_error",
338
- message: "The revocation received no response. Check the connection, and sign out again.",
339
- status: 0
340
- });
341
- });
342
- if (!response) return;
343
- if (response.ok) {
344
- await response.body?.cancel();
345
- return;
318
+ const response = await (auth.fetch ?? fetch)(
319
+ new URL("/oauth2/revoke", auth.url),
320
+ {
321
+ body,
322
+ // A session cookie fails the issuer's origin check, and the revocation needs none.
323
+ credentials: "omit",
324
+ method: "POST",
325
+ // A redirect would send the refresh token and the client authentication to another origin.
326
+ redirect: "manual"
346
327
  }
347
- await json(response);
348
- } finally {
349
- clearTimeout(timer);
328
+ ).catch((error3) => {
329
+ throw new RequestError({
330
+ cause: error3,
331
+ code: "server_error",
332
+ message: "The revocation received no response. Check the connection, and sign out again.",
333
+ status: 0
334
+ });
335
+ });
336
+ if (response.ok) {
337
+ await response.body?.cancel();
338
+ return;
350
339
  }
340
+ await json(response);
351
341
  }
352
342
  var clientAssertionType = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
353
343
  async function tokenHeaders(auth, options) {
@@ -369,16 +359,6 @@ function requestHeaders(init, options) {
369
359
  function bound(token2) {
370
360
  return jkt(token2) !== void 0;
371
361
  }
372
- function lifetime(token2) {
373
- try {
374
- const claims = JSON.parse(Base642.toString(token2.split(".")[1] ?? ""));
375
- if (typeof claims.exp !== "number" || typeof claims.iat !== "number")
376
- return void 0;
377
- return (claims.exp - claims.iat) * 1e3;
378
- } catch {
379
- return void 0;
380
- }
381
- }
382
362
  function jkt(token2) {
383
363
  try {
384
364
  const claims = JSON.parse(Base642.toString(token2.split(".")[1] ?? ""));
@@ -1025,9 +1005,9 @@ async function authorizeUrl(auth, options) {
1025
1005
  if (!accessKey2 && options.challenge !== void 0)
1026
1006
  throw new ChallengeWithoutKeyError();
1027
1007
  const redirectUri = options.redirectUri ?? auth.redirectUri ?? `${window.location.origin}/`;
1028
- const key = accessKey2 && !("address" in accessKey2) ? await resolve(accessKey2) : void 0;
1008
+ const key = accessKey2 ? await resolve(accessKey2) : void 0;
1029
1009
  const pending = from2({
1030
- ...key ? key.material : accessKey2 ? {} : { key: false },
1010
+ ...key ? key.material : { key: false },
1031
1011
  chainId: auth.chainId,
1032
1012
  clientId: auth.clientId,
1033
1013
  redirectUri,
@@ -1035,13 +1015,9 @@ async function authorizeUrl(auth, options) {
1035
1015
  state: Base644.fromBytes(Bytes2.random(16), base64url),
1036
1016
  verifier: Base644.fromBytes(Bytes2.random(32), base64url)
1037
1017
  });
1038
- const authorization2 = (() => {
1039
- if (!accessKey2) return void 0;
1040
- if ("address" in accessKey2) return keyAuthorization(auth, { accessKey: accessKey2 });
1041
- return keyAuthorization(auth, {
1042
- accessKey: { ...accessKey2, account: key.accessKey }
1043
- });
1044
- })();
1018
+ const authorization2 = key && accessKey2 ? keyAuthorization(auth, {
1019
+ accessKey: { ...accessKey2, account: key.accessKey }
1020
+ }) : void 0;
1045
1021
  const url = new URL("/oauth2/authorize", auth.url);
1046
1022
  const parameters = new URLSearchParams({
1047
1023
  ...options.challenge === void 0 ? {} : { challenge: options.challenge },
@@ -1098,39 +1074,23 @@ function request(auth, options) {
1098
1074
  };
1099
1075
  }
1100
1076
  function keyAuthorization(auth, options) {
1101
- const { accessKey: accessKey2 } = options;
1102
- const permissions2 = resolve2(accessKey2, {
1077
+ const { account: signer } = options.accessKey;
1078
+ const permissions2 = resolve2(options.accessKey, {
1103
1079
  chainId: auth.chainId
1104
1080
  });
1105
- const named = (() => {
1106
- if ("address" in accessKey2)
1107
- return {
1108
- account: options.account ?? accessKey2.access,
1109
- address: accessKey2.address,
1110
- keyType: accessKey2.type ?? "secp256k1",
1111
- witness: accessKey2.witness
1112
- };
1113
- const { account: signer } = accessKey2;
1114
- return {
1115
- account: options.account ?? (signer.accessKeyAddress ? signer.address : void 0),
1116
- address: signer.accessKeyAddress ?? signer.address,
1117
- keyType: signer.keyType,
1118
- witness: void 0
1119
- };
1120
- })();
1081
+ const account2 = options.account ?? (signer.accessKeyAddress ? signer.address : void 0);
1121
1082
  return {
1122
- ...named.account ? { account: named.account } : {},
1123
- address: named.address,
1083
+ ...account2 ? { account: account2 } : {},
1084
+ address: signer.accessKeyAddress ?? signer.address,
1124
1085
  chainId: Hex2.fromNumber(permissions2.chainId),
1125
1086
  expiry: permissions2.expiry,
1126
- keyType: named.keyType,
1087
+ keyType: signer.keyType,
1127
1088
  limits: permissions2.limits?.map(({ limit, period, token: token2 }) => ({
1128
1089
  limit: Hex2.fromNumber(limit),
1129
1090
  ...period ? { period } : {},
1130
1091
  token: token2
1131
1092
  })),
1132
- scopes: permissions2.scopes,
1133
- ...named.witness ? { witness: named.witness } : {}
1093
+ scopes: permissions2.scopes
1134
1094
  };
1135
1095
  }
1136
1096
  function funding(options) {
@@ -1712,7 +1672,6 @@ var funding_exports = {};
1712
1672
  __export(funding_exports, {
1713
1673
  BlockedError: () => BlockedError,
1714
1674
  OriginError: () => OriginError,
1715
- PageRequiredError: () => PageRequiredError,
1716
1675
  complete: () => complete2,
1717
1676
  open: () => open
1718
1677
  });
@@ -1732,14 +1691,6 @@ var OriginError = class extends Error {
1732
1691
  );
1733
1692
  }
1734
1693
  };
1735
- var PageRequiredError = class extends Error {
1736
- name = "Actions.funding.PageRequiredError";
1737
- constructor() {
1738
- super(
1739
- "No browser window: the deposit page opens only from a page. On a server, pass `funding` to `accounts.backend.start`. In a CLI, pass it to `accounts.device.signIn`."
1740
- );
1741
- }
1742
- };
1743
1694
  function complete2(auth, options = {}) {
1744
1695
  const own2 = options.url === void 0;
1745
1696
  const url = new URL(options.url ?? window.location.href);
@@ -1765,10 +1716,6 @@ function complete2(auth, options = {}) {
1765
1716
  }
1766
1717
  async function open(auth, options) {
1767
1718
  const { amount, currency, signal, token: token2 } = options;
1768
- if (typeof options.address === "object")
1769
- Promise.resolve(options.address).catch(() => void 0);
1770
- signal?.throwIfAborted();
1771
- if (typeof document === "undefined") throw new PageRequiredError();
1772
1719
  const mode = (() => {
1773
1720
  const value = options.mode ?? "frame";
1774
1721
  if (value !== "frame") return value;
@@ -1780,6 +1727,8 @@ async function open(auth, options) {
1780
1727
  return "popup";
1781
1728
  return value;
1782
1729
  })();
1730
+ if (options.address instanceof Promise) options.address.catch(() => void 0);
1731
+ signal?.throwIfAborted();
1783
1732
  const redirectUri = options.redirectUri ?? auth.redirectUri ?? `${window.location.origin}/`;
1784
1733
  const toUrl = (address2, entry = { mode }) => {
1785
1734
  const url = new URL(
@@ -1819,7 +1768,7 @@ async function open(auth, options) {
1819
1768
  throw new OriginError({ origin: window.location.origin, redirectUri });
1820
1769
  if (mode === "popup" && options.mode !== "popup" && !activated()) {
1821
1770
  const address2 = await abortable(read2(), { signal });
1822
- const Sheet = await import("./Sheet-GQPH2MUR.js");
1771
+ const Sheet = await import("./Sheet-II5IGP5J.js");
1823
1772
  return await new Promise((resolve3, reject) => {
1824
1773
  const abort = () => {
1825
1774
  close();
@@ -1870,7 +1819,7 @@ async function watch(auth, options) {
1870
1819
  try {
1871
1820
  return await new Promise(
1872
1821
  (resolve3, reject) => {
1873
- void import("./Sheet-GQPH2MUR.js").then(
1822
+ void import("./Sheet-II5IGP5J.js").then(
1874
1823
  (Sheet) => {
1875
1824
  if (settled) return;
1876
1825
  unblock = Sheet.waiting({
@@ -1935,7 +1884,7 @@ function parse(url, options) {
1935
1884
  async function frame(auth, options) {
1936
1885
  const { redirectUri, signal, toUrl } = options;
1937
1886
  const address2 = await abortable(options.address, { signal });
1938
- const Sheet = await import("./Sheet-GQPH2MUR.js");
1887
+ const Sheet = await import("./Sheet-II5IGP5J.js");
1939
1888
  signal?.throwIfAborted();
1940
1889
  let close;
1941
1890
  let abort;
@@ -2103,7 +2052,7 @@ function complete3(auth, options = {}) {
2103
2052
  removed
2104
2053
  ]);
2105
2054
  return finish({
2106
- accessKey: options.accessKey,
2055
+ accessKey: own(options.accessKey),
2107
2056
  body,
2108
2057
  pending: stored
2109
2058
  });
@@ -2116,7 +2065,7 @@ async function createUrl(auth, options = {}) {
2116
2065
  }
2117
2066
  async function handleCallback(auth, options) {
2118
2067
  return finish({
2119
- accessKey: options.accessKey,
2068
+ accessKey: own(options.accessKey),
2120
2069
  body: await redeem(auth, {
2121
2070
  pending: options.pending,
2122
2071
  url: new URL(options.url)
@@ -2145,7 +2094,7 @@ function handleResult(options) {
2145
2094
  status: 400
2146
2095
  });
2147
2096
  return finish({
2148
- accessKey: options.accessKey,
2097
+ accessKey: own(options.accessKey),
2149
2098
  body: authorization2,
2150
2099
  pending: options.pending
2151
2100
  });
@@ -2223,24 +2172,13 @@ function finish(options) {
2223
2172
  signedIn: true,
2224
2173
  status: 400
2225
2174
  });
2226
- if (options.accessKey && "address" in options.accessKey) {
2227
- const tokens3 = tokens(body);
2228
- return {
2229
- ...tokens3,
2230
- key: from({
2231
- account: body.account,
2232
- keyAuthorization: body.key_authorization
2233
- }),
2234
- user: user(tokens3)
2235
- };
2236
- }
2237
2175
  return authorization(
2238
2176
  {
2239
2177
  account: body.account,
2240
2178
  key_authorization: body.key_authorization,
2241
2179
  tokens: body
2242
2180
  },
2243
- { accessKey: own(options.accessKey), material }
2181
+ { accessKey: options.accessKey, material }
2244
2182
  );
2245
2183
  }
2246
2184
  async function prefetch(auth) {
@@ -2266,28 +2204,16 @@ async function prefetch(auth) {
2266
2204
  return urls;
2267
2205
  }
2268
2206
  async function start(auth, options = {}) {
2207
+ const { pending, url } = await createUrl(auth, options);
2269
2208
  const store2 = get2(auth.store);
2270
- const [{ pending, url }, stored] = await Promise.all([
2271
- createUrl(auth, options),
2272
- (async () => store2.getItem(indexKey))()
2273
- ]);
2274
- const index = stored ?? [];
2275
2209
  const now = Date.now();
2276
2210
  const expiresAt = now + pendingLifetime;
2277
- const page = [
2278
- ...(written.get(store2) ?? []).filter((entry) => entry.expiresAt > now),
2279
- { expiresAt, state: pending.state }
2280
- ];
2281
- written.set(store2, page);
2282
- const rows = [
2283
- ...index,
2284
- ...page.filter((entry) => !index.some((row) => row.state === entry.state))
2285
- ];
2286
- const expired3 = rows.filter((entry) => entry.expiresAt <= now);
2287
- const kept = rows.filter((entry) => entry.expiresAt > now);
2211
+ const index = await store2.getItem(indexKey) ?? [];
2212
+ const expired3 = index.filter((entry) => entry.expiresAt <= now);
2213
+ const kept = index.filter((entry) => entry.expiresAt > now);
2288
2214
  await Promise.all([
2289
2215
  ...expired3.map((entry) => store2.removeItem(storeKey(entry.state))),
2290
- store2.setItem(indexKey, kept, {
2216
+ store2.setItem(indexKey, [...kept, { expiresAt, state: pending.state }], {
2291
2217
  expiresAt
2292
2218
  }),
2293
2219
  store2.setItem(storeKey(pending.state), pending, { expiresAt })
@@ -2296,7 +2222,6 @@ async function start(auth, options = {}) {
2296
2222
  window.location.assign(url);
2297
2223
  }
2298
2224
  var completed = /* @__PURE__ */ new WeakMap();
2299
- var written = /* @__PURE__ */ new WeakMap();
2300
2225
  var indexKey = "tempo-id:redirects";
2301
2226
  var pendingLifetime = 60 * 60 * 1e3;
2302
2227
  var legacyStoreKey = "tempo-id:redirect";
@@ -2488,7 +2413,7 @@ async function authorize3(auth, options) {
2488
2413
  let broadcast;
2489
2414
  let name;
2490
2415
  let unwatch;
2491
- let written2;
2416
+ let written;
2492
2417
  let sheet = reused;
2493
2418
  try {
2494
2419
  const { pending, url: popupUrl } = await Promise.race([
@@ -2510,8 +2435,8 @@ async function authorize3(auth, options) {
2510
2435
  if (mode === "iframe")
2511
2436
  sheet ??= create2({ url: frameUrl(auth, { redirectUri }) });
2512
2437
  name = channel({ state: pending.state });
2513
- written2 = Promise.resolve(store2.setItem(name, true));
2514
- await Promise.race([written2, aborted, closed, replaced]);
2438
+ written = Promise.resolve(store2.setItem(name, true));
2439
+ await Promise.race([written, aborted, closed, replaced]);
2515
2440
  if (popup?.closed)
2516
2441
  throw new DOMException("The user closed the sign-in.", "AbortError");
2517
2442
  const listener = new BroadcastChannel(name);
@@ -2594,7 +2519,7 @@ async function authorize3(auth, options) {
2594
2519
  popup?.close();
2595
2520
  if (name) {
2596
2521
  const item = name;
2597
- void (written2 ?? Promise.resolve()).then(() => store2.removeItem(item)).catch(() => {
2522
+ void (written ?? Promise.resolve()).then(() => store2.removeItem(item)).catch(() => {
2598
2523
  });
2599
2524
  }
2600
2525
  }
@@ -2741,10 +2666,10 @@ __export(email_exports2, {
2741
2666
  import { Authentication as Authentication3 } from "ox/webauthn";
2742
2667
 
2743
2668
  // ../../accounts/src/internal/Registration.ts
2744
- var lifetime2 = 4 * 60 * 1e3;
2669
+ var lifetime = 4 * 60 * 1e3;
2745
2670
  function from3(value, options) {
2746
2671
  return {
2747
- expiresAt: options.requestedAt + lifetime2,
2672
+ expiresAt: options.requestedAt + lifetime,
2748
2673
  options: value.options,
2749
2674
  ...value.proof ? { proof: value.proof } : {}
2750
2675
  };
@@ -3390,10 +3315,9 @@ function create3(options) {
3390
3315
  // The message names a sign-out, which other tabs count as one. Another empty write,
3391
3316
  // such as a renewal of an expired session, empties their session as `set` does.
3392
3317
  save: (args) => {
3393
- const signOut3 = args.event.type.startsWith("signOut");
3394
3318
  const message = {
3395
- everywhere: signOut3 && args.context.signingOut?.everywhere,
3396
- signOut: signOut3
3319
+ everywhere: args.context.signingOut?.everywhere,
3320
+ signOut: args.event.type.startsWith("signOut")
3397
3321
  };
3398
3322
  writes?.save(name, args.context.session).then(() => channel2?.postMessage(message)).catch(() => void 0);
3399
3323
  }
@@ -3401,13 +3325,11 @@ function create3(options) {
3401
3325
  })
3402
3326
  ).start() : void 0;
3403
3327
  let obtained = 0;
3404
- let obtainedLogouts = 0;
3405
3328
  let held = actor?.getSnapshot().context.session;
3406
3329
  actor?.subscribe((snapshot) => {
3407
3330
  if (snapshot.context.session === held) return;
3408
3331
  held = snapshot.context.session;
3409
3332
  obtained = Date.now();
3410
- obtainedLogouts = snapshot.context.logouts.remote;
3411
3333
  });
3412
3334
  const context = () => actor.getSnapshot().context;
3413
3335
  function set(session2, options2 = {}) {
@@ -3538,17 +3460,9 @@ function create3(options) {
3538
3460
  (entry) => typeof entry === "string"
3539
3461
  ) : [];
3540
3462
  },
3541
- /**
3542
- * Returns the tokens that the entry holds once the store took the write, at most the latest 16,
3543
- * or `undefined` when the store refused it.
3544
- */
3545
3463
  async write(tokens3) {
3546
3464
  const key = `${name}:unanswered`;
3547
- const held2 = tokens3.slice(-16);
3548
- return (async () => {
3549
- await (held2.length === 0 ? store2?.removeItem(key) : store2?.setItem(key, held2));
3550
- return held2;
3551
- })().catch(() => void 0);
3465
+ await (async () => tokens3.length === 0 ? store2?.removeItem(key) : store2?.setItem(key, tokens3.slice(-16)))().catch(() => void 0);
3552
3466
  }
3553
3467
  };
3554
3468
  const revoked = {
@@ -3759,7 +3673,6 @@ function create3(options) {
3759
3673
  return () => subscription.unsubscribe();
3760
3674
  }
3761
3675
  const rotated = /* @__PURE__ */ new Map();
3762
- const retained = /* @__PURE__ */ new Map();
3763
3676
  const authorizations = /* @__PURE__ */ new Set();
3764
3677
  return {
3765
3678
  actor,
@@ -4025,41 +3938,19 @@ function create3(options) {
4025
3938
  await hydrate();
4026
3939
  await writes?.flush().catch(() => void 0);
4027
3940
  const local = actor ? context().session : void 0;
4028
- const unsaved = !!local && writes?.unsaved() === local;
4029
- const logouts = obtainedLogouts;
4030
- const since = obtained;
4031
3941
  const before = await read2();
4032
3942
  actor?.send({ type: "signOut" });
4033
3943
  const ownSignIns = actor ? context().signIns : 0;
4034
3944
  rotated.clear();
4035
3945
  const emptied = settle(writes?.flush());
4036
3946
  return exclusive(async () => {
4037
- const [{ failed, stored }, earlier, digests, entries] = await Promise.all(
4038
- [
4039
- emptied.then(async (failed2) => ({ failed: failed2, stored: await read2() })),
4040
- unanswered2.read(),
4041
- revoked.read(),
4042
- unsaved ? rotations.read() : void 0
4043
- ]
4044
- );
4045
- const held2 = !before || !local || before.user.id !== local.user.id;
4046
- const revocable = (token2) => machines2.revocable({
4047
- entries,
4048
- held: held2,
4049
- live: token2 && entries ? rotations.successor(entries, token2) : void 0,
4050
- remote: !!actor && context().logouts.remote !== logouts,
4051
- revoked: options2.revoked,
4052
- since,
4053
- token: token2
4054
- });
3947
+ const [{ failed, stored }, earlier, digests] = await Promise.all([
3948
+ emptied.then(async (failed2) => ({ failed: failed2, stored: await read2() })),
3949
+ unanswered2.read(),
3950
+ revoked.read()
3951
+ ]);
4055
3952
  const current = actor ? context().session : void 0;
4056
- const ending = machines2.ending({
4057
- before,
4058
- current,
4059
- failed: unsaved,
4060
- local,
4061
- stored
4062
- });
3953
+ const ending = machines2.ending({ before, current, local, stored });
4063
3954
  if (ending.empty)
4064
3955
  actor?.send({ type: current ? "save" : "signOut.empty" });
4065
3956
  const saved = ending.empty ? await settle(writes?.flush()) : void 0;
@@ -4068,24 +3959,11 @@ function create3(options) {
4068
3959
  const skipped = ended?.refreshToken ? rotated.get(ended.refreshToken) : void 0;
4069
3960
  const signIns = actor ? context().signIns : 0;
4070
3961
  const known = !!ended?.refreshToken && ended.refreshToken === options2.revoked;
4071
- const stale = unsaved && ended === local && !revocable(ended?.refreshToken);
4072
- const revoking = known || stale || ended?.refreshToken && rotated.has(ended.refreshToken) || revoked.has(digests, ended) ? void 0 : ended;
4073
- const unsavedToken = revocable(ending.unsaved?.refreshToken) ? ending.unsaved?.refreshToken : void 0;
4074
- const resent = machines2.resent({
4075
- remote: actor ? context().logouts.remote : void 0,
4076
- retained
4077
- });
4078
- const pending = [
4079
- .../* @__PURE__ */ new Set([
4080
- ...earlier ?? [],
4081
- ...resent,
4082
- ...unsavedToken ? [unsavedToken] : []
4083
- ])
4084
- ].filter(
3962
+ const revoking = known || ended?.refreshToken && rotated.has(ended.refreshToken) || revoked.has(digests, ended) ? void 0 : ended;
3963
+ const pending = (earlier ?? []).filter(
4085
3964
  (token2) => token2 !== revoking?.refreshToken && !revoked.has(digests, { refreshToken: token2 })
4086
3965
  );
4087
3966
  const answered2 = /* @__PURE__ */ new Set();
4088
- const errors = /* @__PURE__ */ new Map();
4089
3967
  const signedOut = await settle(
4090
3968
  signOut2(revoking, {
4091
3969
  logout: machines2.logout({
@@ -4105,9 +3983,6 @@ function create3(options) {
4105
3983
  answered2.add(refreshToken);
4106
3984
  return Promise.resolve();
4107
3985
  },
4108
- onUnanswered: (error3) => {
4109
- errors.set(refreshToken, error3);
4110
- },
4111
3986
  refreshToken
4112
3987
  })),
4113
3988
  unrevoked: skipped
@@ -4121,47 +3996,22 @@ function create3(options) {
4121
3996
  ...pending.filter((token2) => answered2.has(token2)),
4122
3997
  ...revoking?.refreshToken && answered2.has(revoking.refreshToken) ? [revoking.refreshToken] : []
4123
3998
  ];
4124
- const [, persisted] = await Promise.all([
3999
+ await Promise.all([
4125
4000
  revoked.write(digests, marks),
4126
4001
  (async () => {
4127
4002
  if (earlier === void 0) {
4128
4003
  const again = live.length > 0 ? await unanswered2.read() : void 0;
4129
- if (!again) return live.length === 0 ? [] : void 0;
4130
- return unanswered2.write([
4131
- ...again.filter((token2) => !live.includes(token2)),
4132
- ...live
4133
- ]);
4134
- }
4135
- if (earlier.length > 0 || live.length > 0)
4136
- return unanswered2.write(live);
4137
- return [];
4004
+ if (again)
4005
+ await unanswered2.write([
4006
+ ...again.filter((token2) => !live.includes(token2)),
4007
+ ...live
4008
+ ]);
4009
+ } else if (earlier.length > 0 || live.length > 0)
4010
+ await unanswered2.write(live);
4138
4011
  })()
4139
4012
  ]);
4140
- const kept = machines2.retains({
4141
- live,
4142
- logouts,
4143
- persisted,
4144
- retained,
4145
- unsaved: [
4146
- ...unsavedToken ? [unsavedToken] : [],
4147
- ...unsaved && local?.refreshToken ? [local.refreshToken] : []
4148
- ]
4149
- });
4150
- retained.clear();
4151
- for (const [token2, remote] of kept) retained.set(token2, remote);
4152
4013
  if (erased) throw erased.error;
4153
4014
  if (signedOut) throw signedOut.error;
4154
- const unsent = [...unsavedToken ? [unsavedToken] : [], ...resent];
4155
- const failing = unsent.find(
4156
- (token2) => pending.includes(token2) && !answered2.has(token2)
4157
- );
4158
- if (failing && errors.has(failing)) throw errors.get(failing);
4159
- if (failing)
4160
- throw new RequestError({
4161
- code: "server_error",
4162
- message: "Revocation failed: no response for the refresh token of the unsaved session. Sign out again once online.",
4163
- status: 0
4164
- });
4165
4015
  });
4166
4016
  }
4167
4017
  }
@@ -4192,16 +4042,13 @@ function settle(promise) {
4192
4042
  function queue(store2, options = {}) {
4193
4043
  let pending = Promise.resolve();
4194
4044
  let failed = false;
4195
- let unsaved;
4196
- const enqueue = (write, session2) => {
4045
+ const enqueue = (write) => {
4197
4046
  const next = pending.catch(() => void 0).then(write).then(
4198
4047
  () => {
4199
4048
  failed = false;
4200
- unsaved = void 0;
4201
4049
  },
4202
4050
  (error3) => {
4203
4051
  failed = true;
4204
- unsaved = session2;
4205
4052
  throw error3;
4206
4053
  }
4207
4054
  );
@@ -4218,8 +4065,6 @@ function queue(store2, options = {}) {
4218
4065
  };
4219
4066
  return {
4220
4067
  failed: () => failed,
4221
- /** Returns the session that the last write failed to save, or `undefined` after a saved write. */
4222
- unsaved: () => unsaved,
4223
4068
  /**
4224
4069
  * Resolves when every earlier write completed. It reads the queue after a microtask, since a
4225
4070
  * change that a subscriber sends during another change is processed only once that change's
@@ -4234,8 +4079,7 @@ function queue(store2, options = {}) {
4234
4079
  () => store2.setItem(name, {
4235
4080
  state: { session: toSaved(session2) },
4236
4081
  version: 0
4237
- }),
4238
- session2
4082
+ })
4239
4083
  ),
4240
4084
  storage
4241
4085
  };
@@ -4319,7 +4163,6 @@ var machines2;
4319
4163
  logout: assign2((args) => ({
4320
4164
  logouts: {
4321
4165
  ...args.context.logouts,
4322
- remote: args.context.logouts.remote + 1,
4323
4166
  started: args.context.logouts.started + 1
4324
4167
  }
4325
4168
  })),
@@ -4356,11 +4199,7 @@ var machines2;
4356
4199
  const { logouts, signingOut } = args.context;
4357
4200
  const { everywhere } = args.event;
4358
4201
  return {
4359
- logouts: everywhere ? {
4360
- ...logouts,
4361
- running: logouts.running + 1,
4362
- started: logouts.started + 1
4363
- } : logouts,
4202
+ logouts: everywhere ? { running: logouts.running + 1, started: logouts.started + 1 } : logouts,
4364
4203
  marked: !everywhere,
4365
4204
  signingOut: { everywhere, runs: (signingOut?.runs ?? 0) + 1 }
4366
4205
  };
@@ -4401,7 +4240,7 @@ var machines2;
4401
4240
  authorizations: 0,
4402
4241
  delegations: 0,
4403
4242
  loaded: false,
4404
- logouts: { remote: 0, running: 0, started: 0 },
4243
+ logouts: { running: 0, started: 0 },
4405
4244
  marked: false,
4406
4245
  refusals: 0,
4407
4246
  renewing: void 0,
@@ -4459,24 +4298,17 @@ var machines2;
4459
4298
  }
4460
4299
  machines4.adoptable = adoptable;
4461
4300
  function ending(options) {
4462
- const { before, current, failed, local, stored } = options;
4463
- const ended2 = (() => {
4464
- if (failed && !before) return local;
4465
- return machines4.newer(before, local) ? before : local;
4466
- })();
4467
- const unsaved = failed && before && local && before.user.id !== local.user.id ? local : void 0;
4468
- if (!stored || !ended2)
4469
- return { empty: false, kept: false, session: ended2, unsaved };
4470
- const held = !(failed && !before);
4301
+ const { before, current, local, stored } = options;
4302
+ const ended2 = machines4.newer(before, local) ? before : local;
4303
+ if (!stored || !ended2) return { empty: false, kept: false, session: ended2 };
4471
4304
  const own2 = stored.refreshToken === current?.refreshToken;
4472
- const later = held && !own2 && stored.user.id === ended2.user.id && stored.key?.keyAuthorization.keyId === ended2.key?.keyAuthorization.keyId && stored.refreshToken !== ended2.refreshToken && stored.expiresAt >= ended2.expiresAt;
4473
- const stale = held && !own2 && stored.refreshToken === ended2.refreshToken;
4305
+ const later = !own2 && stored.user.id === ended2.user.id && stored.key?.keyAuthorization.keyId === ended2.key?.keyAuthorization.keyId && stored.refreshToken !== ended2.refreshToken && stored.expiresAt >= ended2.expiresAt;
4306
+ const stale = !own2 && stored.refreshToken === ended2.refreshToken;
4474
4307
  const kept = !own2 && !later && !stale && stored.user.id !== ended2.user.id;
4475
4308
  return {
4476
4309
  empty: later || stale,
4477
4310
  kept,
4478
- session: later ? stored : ended2,
4479
- unsaved
4311
+ session: later ? stored : ended2
4480
4312
  };
4481
4313
  }
4482
4314
  machines4.ending = ending;
@@ -4495,32 +4327,6 @@ var machines2;
4495
4327
  return first.at > since - 1e3;
4496
4328
  }
4497
4329
  machines4.lacks = lacks;
4498
- function resent(options) {
4499
- const { remote, retained } = options;
4500
- return [...retained].filter(([, entered]) => remote === void 0 || remote === entered).map(([token2]) => token2);
4501
- }
4502
- machines4.resent = resent;
4503
- function retains(options) {
4504
- const { live, logouts, persisted, retained, unsaved } = options;
4505
- const result = /* @__PURE__ */ new Map();
4506
- for (const token2 of live) {
4507
- if (persisted?.includes(token2)) continue;
4508
- const entered = retained.get(token2);
4509
- if (entered !== void 0) result.set(token2, entered);
4510
- else if (unsaved.includes(token2)) result.set(token2, logouts);
4511
- }
4512
- return result;
4513
- }
4514
- machines4.retains = retains;
4515
- function revocable(options) {
4516
- const { entries, held, live, remote, revoked, since, token: token2 } = options;
4517
- if (!token2 || token2 === revoked) return false;
4518
- if (remote) return false;
4519
- if (!held) return true;
4520
- if (!entries || machines4.lacks({ entries, since })) return false;
4521
- return live === token2;
4522
- }
4523
- machines4.revocable = revocable;
4524
4330
  function loggedOut(options) {
4525
4331
  const { current, started } = options;
4526
4332
  if (current.logouts.started !== started.logouts.started) return true;
@@ -4612,13 +4418,11 @@ var machines2;
4612
4418
  }
4613
4419
  machines4.declined = declined;
4614
4420
  function rotated(options) {
4615
- const { current, lifetime: lifetime3, now, started, startedAt } = options;
4616
- if (started && !started.refreshToken) return false;
4617
- if (started && current.user.id !== started.user.id) return false;
4421
+ const { current, now, started } = options;
4422
+ if (!started?.refreshToken) return false;
4423
+ if (current.user.id !== started.user.id) return false;
4618
4424
  if (current.expiresAt <= now) return false;
4619
- if (lifetime3 === void 0) return false;
4620
- if (current.expiresAt - lifetime3 <= startedAt) return false;
4621
- return current.refreshToken !== started?.refreshToken;
4425
+ return current.refreshToken !== started.refreshToken;
4622
4426
  }
4623
4427
  machines4.rotated = rotated;
4624
4428
  function switches(options) {
@@ -4702,11 +4506,13 @@ async function run(context, parameters) {
4702
4506
  }
4703
4507
  function refresh3(context, options = {}) {
4704
4508
  const { margin } = options;
4705
- const started = context.session.get();
4706
- const startedAt = Date.now();
4509
+ const started = margin === void 0 ? context.session.reload().catch(() => void 0) : void 0;
4707
4510
  return context.session.exclusive(async () => {
4708
4511
  await context.session.load({ locked: true });
4709
- const current = await context.session.reload();
4512
+ const [current, before] = await Promise.all([
4513
+ context.session.reload(),
4514
+ started
4515
+ ]);
4710
4516
  const refreshToken = current?.refreshToken;
4711
4517
  if (!current || !refreshToken) return void 0;
4712
4518
  checkBound(context.config, { accessToken: current.accessToken });
@@ -4714,12 +4520,10 @@ function refresh3(context, options = {}) {
4714
4520
  await context.session.change({ update: true }).commit(current);
4715
4521
  return context.session.get();
4716
4522
  }
4717
- if (margin === void 0 && machines2.rotated({
4523
+ if (machines2.rotated({
4718
4524
  current,
4719
- lifetime: lifetime(current.accessToken),
4720
4525
  now: Date.now(),
4721
- started,
4722
- startedAt
4526
+ started: before
4723
4527
  })) {
4724
4528
  await context.session.change({ update: true }).commit(current);
4725
4529
  return context.session.get();
@@ -4908,7 +4712,7 @@ var signInIds = /* @__PURE__ */ new Set([
4908
4712
  function plugin() {
4909
4713
  let loading;
4910
4714
  function load() {
4911
- loading ??= import("./dialog-TGNSW7U4.js").then((module) => module.dialog()).catch((error3) => {
4715
+ loading ??= import("./dialog-FFLTODHO.js").then((module) => module.dialog()).catch((error3) => {
4912
4716
  loading = void 0;
4913
4717
  throw error3;
4914
4718
  });
@@ -5222,15 +5026,7 @@ function create4(options = {}) {
5222
5026
  return void 0;
5223
5027
  return revoke2(ended.refreshToken, onRevoked);
5224
5028
  })(),
5225
- ...pending.map(async (entry) => {
5226
- const result = await revoke2(entry.refreshToken, entry.onRevoked);
5227
- if (result) {
5228
- if (typeof result.error === "object" && result.error)
5229
- unanswered2.add(result.error);
5230
- entry.onUnanswered?.(result.error);
5231
- }
5232
- return void 0;
5233
- })
5029
+ ...pending.map((entry) => revoke2(entry.refreshToken, entry.onRevoked))
5234
5030
  ]);
5235
5031
  const loggedOut = logout && !thirdParty(config.clientId);
5236
5032
  if (loggedOut) {
@@ -5283,7 +5079,6 @@ function create4(options = {}) {
5283
5079
  plugin2.setup?.(context);
5284
5080
  }
5285
5081
  let refreshing;
5286
- let rotating;
5287
5082
  async function ownAccessToken() {
5288
5083
  if (typeof document !== "undefined" || "WorkerGlobalScope" in globalThis)
5289
5084
  return void 0;
@@ -5321,7 +5116,7 @@ function create4(options = {}) {
5321
5116
  function connections2() {
5322
5117
  if (!connectionsOptions)
5323
5118
  return Promise.reject(new ConnectionsRequiredError());
5324
- attached ??= import("./Connections-GTESLWTN.js").then(
5119
+ attached ??= import("./Connections-DLVOXLEL.js").then(
5325
5120
  (module) => module.attach(config, connectionsOptions)
5326
5121
  );
5327
5122
  return attached;
@@ -5407,9 +5202,7 @@ function create4(options = {}) {
5407
5202
  },
5408
5203
  signedOut: session2.signedOut
5409
5204
  }),
5410
- refresh: () => rotating ??= refresh3(context).finally(() => {
5411
- rotating = void 0;
5412
- }),
5205
+ refresh: () => refresh3(context),
5413
5206
  status: session2.status,
5414
5207
  subscribe: session2.subscribe
5415
5208
  },
@@ -2,7 +2,7 @@ import {
2
2
  AccessKey_exports,
3
3
  Accounts_exports,
4
4
  Actions_exports
5
- } from "./chunk-AOIGHDXR.js";
5
+ } from "./chunk-MTJSZT4S.js";
6
6
 
7
7
  // src/Session.ts
8
8
  import * as Fs from "node:fs/promises";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  env,
3
3
  login
4
- } from "../chunk-DN57D5UC.js";
5
- import "../chunk-K4WPSEXZ.js";
6
- import "../chunk-AOIGHDXR.js";
4
+ } from "../chunk-O3UAZSAM.js";
5
+ import "../chunk-7JMEEUUA.js";
6
+ import "../chunk-MTJSZT4S.js";
7
7
  import "../chunk-YW5DUQT3.js";
8
8
  import "../chunk-MLKGABMK.js";
9
9
 
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  env,
3
3
  remove
4
- } from "../chunk-DN57D5UC.js";
5
- import "../chunk-K4WPSEXZ.js";
6
- import "../chunk-AOIGHDXR.js";
4
+ } from "../chunk-O3UAZSAM.js";
5
+ import "../chunk-7JMEEUUA.js";
6
+ import "../chunk-MTJSZT4S.js";
7
7
  import "../chunk-YW5DUQT3.js";
8
8
  import "../chunk-MLKGABMK.js";
9
9
 
@@ -2,9 +2,9 @@ import {
2
2
  env,
3
3
  signedOut,
4
4
  whoami
5
- } from "../chunk-DN57D5UC.js";
6
- import "../chunk-K4WPSEXZ.js";
7
- import "../chunk-AOIGHDXR.js";
5
+ } from "../chunk-O3UAZSAM.js";
6
+ import "../chunk-7JMEEUUA.js";
7
+ import "../chunk-MTJSZT4S.js";
8
8
  import "../chunk-YW5DUQT3.js";
9
9
  import "../chunk-MLKGABMK.js";
10
10
 
@@ -4,7 +4,7 @@ import {
4
4
  expired2 as expired,
5
5
  from2 as from,
6
6
  toSession
7
- } from "./chunk-AOIGHDXR.js";
7
+ } from "./chunk-MTJSZT4S.js";
8
8
  import "./chunk-MLKGABMK.js";
9
9
 
10
10
  // ../../accounts/src/plugins/dialog.ts
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "node": ">=24.21"
10
10
  },
11
11
  "name": "@tempoxyz/id",
12
- "version": "0.0.0-pr-723.sha-e2f626f",
12
+ "version": "0.0.0-pr-670.sha-e3c7fc8",
13
13
  "description": "The tempo-id CLI: sign in to Tempo ID, and call its API and the Admin API.",
14
14
  "type": "module",
15
15
  "bin": {