@mdbase-dev/sdk 0.2.59 → 0.2.61

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,4 +1,3 @@
1
- import { isAppOpeningProgress } from "../app-host/opening-progress.js";
2
1
  import { performanceMark } from "../performance-mark.js";
3
2
  const PREFIX = "mdbase:startup:";
4
3
  /** Phases that wait for the person: automatic startup ends there. */
@@ -67,11 +66,6 @@ export function markCollectionOpen(selection, phase, previous) {
67
66
  if (selection.requested.approved && (changed || !previous?.selection.requested.approved))
68
67
  performanceMark("mdbase:open:approved");
69
68
  }
70
- if (phase.kind === "opening" && isAppOpeningProgress(phase.progress)) {
71
- const prev = previous?.phase.kind === "opening" && previous.phase.collectionId === phase.collectionId ? previous.phase.progress : null;
72
- if (prev !== phase.progress)
73
- performanceMark(`mdbase:open:stage:${phase.progress}`);
74
- }
75
69
  if (phase.kind === "ready" && (previous?.phase.kind !== "ready" || previous.phase.connection !== phase.connection))
76
70
  performanceMark("mdbase:open:ready");
77
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"startup-timing.js","sourceRoot":"","sources":["../../src/application/startup-timing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAGvD,MAAM,MAAM,GAAC,iBAAiB,CAAC;AAC/B,qEAAqE;AACrE,MAAM,KAAK,GAAkC,IAAI,GAAG,CAAC,CAAC,YAAY,EAAC,aAAa,EAAC,UAAU,EAAC,gBAAgB,EAAC,aAAa,EAAC,SAAS,EAAC,aAAa,EAAC,QAAQ,CAAC,CAAC,CAAC;AAE9J,SAAS,KAAK;IACZ,MAAM,KAAK,GAAE,UAA4C,CAAC,WAAW,CAAC;IACtE,OAAO,OAAO,KAAK,EAAE,GAAG,KAAG,UAAU,IAAE,OAAO,KAAK,CAAC,OAAO,KAAG,UAAU,CAAA,CAAC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C,mBAAmB,CAAC,CAAC;AAC/I,CAAC"}
@@ -15698,12 +15698,12 @@ function appReleaseTrust() {
15698
15698
  // src/application/asset-pins.json
15699
15699
  var asset_pins_default = {
15700
15700
  runtime: {
15701
- sha256: "051bc364e712b4ad25f58d4649a90624c10a910e35a9066221be4e95cfbfdeaa",
15702
- bytes: 4071435,
15703
- maxBytes: 4071435,
15701
+ sha256: "18f9cc9ce4e613f23c8d4120fcdd58c7c0865224737e30f905a7173fdb8ada2d",
15702
+ bytes: 4093898,
15703
+ maxBytes: 4093898,
15704
15704
  source: {
15705
15705
  repository: "mdbase-dev/mdbase-connect",
15706
- commit: "84f9cec4a0a9f22443a8e0f5b16b682503da0620"
15706
+ commit: "2da2b0bc84ee9ecd0ecdef79ea0e2e1ef334bccd"
15707
15707
  }
15708
15708
  },
15709
15709
  sqlite: {
@@ -38953,7 +38953,7 @@ var AppWebSignInSession = class {
38953
38953
  * sign-in gesture; a pending ledger keeps its SAME request for authorize(). */
38954
38954
  start() {
38955
38955
  return this.operation(async () => {
38956
- if (this.flow && this.base.status !== "blocked") return this.getSnapshot();
38956
+ if (this.flow && (this.base.status !== "blocked" || this.base.problem === "installation_removed")) return this.getSnapshot();
38957
38957
  this.publish({ status: "starting", problem: null, signOutResult: null });
38958
38958
  const p = this.options;
38959
38959
  this.flow ??= await AppProtectedInstallationSignIn.open({
@@ -38990,6 +38990,7 @@ var AppWebSignInSession = class {
38990
38990
  * exchange, confirmation or attestation controls are needed by consumers. */
38991
38991
  authorize(options = {}) {
38992
38992
  this.check();
38993
+ if (this.base.problem === "installation_removed") return Promise.reject(failure("refused"));
38993
38994
  if (this.authorizationRateLimit && Date.now() < this.authorizationRetryAt) return Promise.reject(this.authorizationRateLimit);
38994
38995
  const poll = this.pending !== null && this.pending === this.polling ? this.pending : null;
38995
38996
  if (!this.flow || this.pending && !poll) return Promise.reject(failure("busy"));
@@ -39027,7 +39028,14 @@ var AppWebSignInSession = class {
39027
39028
  await this.openDevice();
39028
39029
  this.check();
39029
39030
  await this.abandonUnfinishedNativeChoice();
39030
- const consent = await this.flow.startCollectionConsent(this.installation, this.options.requestedCreateCollections ?? this.options.freshRequestedCreateCollections ?? false, hint, this.options.freshRequestedPrivateDevice === true);
39031
+ let consent;
39032
+ try {
39033
+ consent = await this.flow.startCollectionConsent(this.installation, this.options.requestedCreateCollections ?? this.options.freshRequestedCreateCollections ?? false, hint, this.options.freshRequestedPrivateDevice === true);
39034
+ } catch (error4) {
39035
+ if (!await this.handleRemovedInstallation(error4)) throw error4;
39036
+ portal.close();
39037
+ return this.getSnapshot();
39038
+ }
39031
39039
  this.check();
39032
39040
  this.consentPending = true;
39033
39041
  portal.navigate(consent.verificationUri);
@@ -39423,7 +39431,13 @@ var AppWebSignInSession = class {
39423
39431
  /** `kept`: this installation's last listing instead of a read. It is not an
39424
39432
  * accepted inventory, so an approval missing from it is not a removal. */
39425
39433
  async refreshCollections(kept = null) {
39426
- const collections = kept ?? await this.flow.listApprovedCollections(this.installation);
39434
+ let collections;
39435
+ try {
39436
+ collections = kept ?? await this.flow.listApprovedCollections(this.installation);
39437
+ } catch (error4) {
39438
+ if (await this.handleRemovedInstallation(error4)) return;
39439
+ throw error4;
39440
+ }
39427
39441
  this.check();
39428
39442
  this.listCached = kept !== null;
39429
39443
  if (!kept) {
@@ -39449,6 +39463,25 @@ var AppWebSignInSession = class {
39449
39463
  if (this.freshApproval && picked && visible.some((c) => c.collectionId === picked)) await this.openSlot(picked, true);
39450
39464
  else if (visible.length === 1) await this.openSlot(visible[0].collectionId, true);
39451
39465
  }
39466
+ /** Only Connect's exact refusal of this installation's own bearer ends
39467
+ * access across its scopes. Keep the ledger for explicit, per-scope recovery. */
39468
+ async handleRemovedInstallation(error4) {
39469
+ if (!(error4 instanceof AppInstallationSignInError) || !isAppServerProblem(error4.server) || error4.server.status !== 401 || error4.server.code !== "invalid_connector") return false;
39470
+ this.check();
39471
+ this.listCached = false;
39472
+ for (const id4 of this.flow.view().collectionIds) this.removedScopes.add(id4);
39473
+ this.consentPending = false;
39474
+ this.closeApprovalWindow();
39475
+ for (const slot of this.slots.values()) {
39476
+ slot.usable = false;
39477
+ slot.lifetime?.abort();
39478
+ }
39479
+ this.publish({ status: "blocked", problem: "installation_removed", problemDetail: webSignInProblem(error4).detail, collections: Object.freeze([]) });
39480
+ await this.closeSlots();
39481
+ this.check();
39482
+ this.changed();
39483
+ return true;
39484
+ }
39452
39485
  schedulePoll() {
39453
39486
  if (this.pending && !this.closing && !this.options.signal.aborted) return;
39454
39487
  const read = this.foregroundRead;
@@ -39914,8 +39947,8 @@ var AppWebSignInSession = class {
39914
39947
  collectionListCached() {
39915
39948
  return this.listCached;
39916
39949
  }
39917
- /** Accepted COMPLETE inventory omission or terminal native/log refusal only.
39918
- * Local Forget, failed GETs and transient transport failures do not qualify. */
39950
+ /** A complete inventory omission, a terminal scope refusal, or rejection of
39951
+ * the installation's bearer. Transport and unrelated HTTP failures stay separate. */
39919
39952
  scopeWasRemoved(collectionId) {
39920
39953
  return this.removedScopes.has(collectionId);
39921
39954
  }
@@ -9761,6 +9761,7 @@ var MdbaseSDK = (() => {
9761
9761
  "approval_window_closed",
9762
9762
  "account_confirmation_required",
9763
9763
  "recovery_required",
9764
+ "installation_removed",
9764
9765
  "open_failed",
9765
9766
  "device_keys_unavailable",
9766
9767
  "busy",
@@ -9868,7 +9869,7 @@ var MdbaseSDK = (() => {
9868
9869
  old_connector_running: ["Quit the old mdbase Connect app", "The old mdbase Connect app is still running on the computer that has this collection. Quit it there (including its menu-bar or tray icon), then open the mdbase desktop app.", "retry", "warning"],
9869
9870
  sync_required: ["Give this app access again", "Access to this collection changed since you approved this app. Approve it again to keep using the collection.", "approve", "warning", false, "Approve again"],
9870
9871
  no_device_registered: ["Turn on sync for this collection", "No computer is offering this collection to apps. Open the mdbase desktop app on the computer that has it and turn on sync. Web apps can reach a collection once sync is on.", "retry", "info"],
9871
- installation_scope_removed: ["Access was removed", "This app's previous installation cannot regain access to this collection. Request access again to approve a new installation for this collection. Your other collections keep their access.", "approve", "warning", false, "Request access again"],
9872
+ installation_scope_removed: ["Access was removed", "This app's previous installation cannot regain access to this collection. Request access again to approve a new installation for this collection.", "approve", "warning", false, "Request access again"],
9872
9873
  access_removed: ["You no longer have access", "You were removed from this collection, so this app can't open it. Ask its owner to add you again, or choose another collection.", "choose_collection", "warning"],
9873
9874
  collection_deleted: ["Collection deleted", "This collection was deleted, so it can't be opened any more. Choose another collection.", "choose_collection", "info"],
9874
9875
  collection_unavailable: ["Collection not available", "This collection can't be opened from this app right now. It may no longer be shared with this app, or the computer that offered it stopped. Choose another collection, or try again later.", "choose_collection", "warning"],
@@ -9895,6 +9896,7 @@ var MdbaseSDK = (() => {
9895
9896
  outcome_unknown: ["Not sure that worked", "The connection dropped before mdbase confirmed it. Check whether it went through before trying again.", "resolve_outcome", "warning"],
9896
9897
  internal: GENERIC,
9897
9898
  refused: ["Sign-in didn't go through", "mdbase didn't accept this sign-in. Try signing in again.", "sign_in", "warning"],
9899
+ installation_removed: ["This app's access was removed", "Sign out of this app on this device, then sign in to approve a new installation.", "none", "warning"],
9898
9900
  expired: ["Sign-in timed out", "The sign-in request expired. Start again to get a new one.", "sign_in", "warning"],
9899
9901
  approval_window_closed: ["Sign-in wasn't finished", "The mdbase window was closed before access was approved. Sign in again to continue.", "sign_in", "info"],
9900
9902
  account_confirmation_required: ["Confirm your account", "Confirm which mdbase account to use, then continue.", "sign_in", "info"],
@@ -26359,18 +26361,6 @@ ${end.comment}` : end.comment;
26359
26361
  }
26360
26362
  });
26361
26363
 
26362
- // src/app-host/opening-progress.ts
26363
- function isAppOpeningProgress(value2) {
26364
- return typeof value2 === "string" && stages.includes(value2);
26365
- }
26366
- var stages;
26367
- var init_opening_progress = __esm({
26368
- "src/app-host/opening-progress.ts"() {
26369
- "use strict";
26370
- stages = ["joining", "opening_store", "connecting_log", "syncing", "loading_snapshot", "replaying", "waiting_for_key", "verifying_read", "checking_setup"];
26371
- }
26372
- });
26373
-
26374
26364
  // src/transport/inprocess.ts
26375
26365
  function inProcessConnector(runtime2, options = {}) {
26376
26366
  return {
@@ -38914,6 +38904,18 @@ ${end.comment}` : end.comment;
38914
38904
  }
38915
38905
  });
38916
38906
 
38907
+ // src/app-host/opening-progress.ts
38908
+ function isAppOpeningProgress(value2) {
38909
+ return typeof value2 === "string" && stages.includes(value2);
38910
+ }
38911
+ var stages;
38912
+ var init_opening_progress = __esm({
38913
+ "src/app-host/opening-progress.ts"() {
38914
+ "use strict";
38915
+ stages = ["joining", "opening_store", "connecting_log", "syncing", "loading_snapshot", "replaying", "waiting_for_key", "verifying_read", "checking_setup"];
38916
+ }
38917
+ });
38918
+
38917
38919
  // src/application/sign-out.ts
38918
38920
  function pendingWrites(connection) {
38919
38921
  let status = 0, ledger = 0;
@@ -49796,7 +49798,9 @@ ${end.comment}` : end.comment;
49796
49798
  var init_runtime = __esm({
49797
49799
  "src/application/runtime.ts"() {
49798
49800
  "use strict";
49801
+ init_opening_progress();
49799
49802
  init_errors();
49803
+ init_performance_mark();
49800
49804
  init_worker_protocol();
49801
49805
  init_sign_out();
49802
49806
  init_scope();
@@ -49987,7 +49991,12 @@ ${end.comment}` : end.comment;
49987
49991
  }
49988
49992
  } else if (status !== "blocked") this.loggedProblem = null;
49989
49993
  const { problemDetail: _native, ...raw } = this.raw;
49990
- this.snapshot = Object.freeze({ ...raw, ...native ? { problemDetail: native } : {}, status, problem: problem7, openingProgress: status === "opening" ? readiness3.checking ? "checking_setup" : this.raw.openingProgress ?? null : null, collections: Object.freeze(this.raw.collections.map((value2) => Object.freeze({ ...value2 }))), readiness: readiness3 });
49994
+ const openingProgress = status === "opening" ? raw.status === "opening" ? raw.openingProgress ?? null : readiness3.checking ? "checking_setup" : null : null;
49995
+ const previous = this.snapshot;
49996
+ this.snapshot = Object.freeze({ ...raw, ...native ? { problemDetail: native } : {}, status, problem: problem7, openingProgress, collections: Object.freeze(this.raw.collections.map((value2) => Object.freeze({ ...value2 }))), readiness: readiness3 });
49997
+ if (id6 !== null && isAppOpeningProgress(openingProgress) && (previous.selectedCollectionId !== id6 || previous.openingProgress !== openingProgress)) {
49998
+ performanceMark(`mdbase:open:stage:${openingProgress}`);
49999
+ }
49991
50000
  }
49992
50001
  for (const listener of [...this.listeners]) try {
49993
50002
  listener();
@@ -51070,12 +51079,12 @@ ${end.comment}` : end.comment;
51070
51079
  // src/application/asset-pins.json
51071
51080
  var asset_pins_default = {
51072
51081
  runtime: {
51073
- sha256: "051bc364e712b4ad25f58d4649a90624c10a910e35a9066221be4e95cfbfdeaa",
51074
- bytes: 4071435,
51075
- maxBytes: 4071435,
51082
+ sha256: "18f9cc9ce4e613f23c8d4120fcdd58c7c0865224737e30f905a7173fdb8ada2d",
51083
+ bytes: 4093898,
51084
+ maxBytes: 4093898,
51076
51085
  source: {
51077
51086
  repository: "mdbase-dev/mdbase-connect",
51078
- commit: "84f9cec4a0a9f22443a8e0f5b16b682503da0620"
51087
+ commit: "2da2b0bc84ee9ecd0ecdef79ea0e2e1ef334bccd"
51079
51088
  }
51080
51089
  },
51081
51090
  sqlite: {
@@ -51129,7 +51138,6 @@ ${end.comment}` : end.comment;
51129
51138
  }
51130
51139
 
51131
51140
  // src/application/startup-timing.ts
51132
- init_opening_progress();
51133
51141
  init_performance_mark();
51134
51142
  var PREFIX = "mdbase:startup:";
51135
51143
  var WAITS = /* @__PURE__ */ new Set(["signed_out", "authorizing", "choosing", "needs_approval", "needs_setup", "problem", "unavailable", "closed"]);
@@ -51182,10 +51190,6 @@ ${end.comment}` : end.comment;
51182
51190
  if (changed3) performanceMark("mdbase:open:requested");
51183
51191
  if (selection.requested.approved && (changed3 || !previous?.selection.requested.approved)) performanceMark("mdbase:open:approved");
51184
51192
  }
51185
- if (phase.kind === "opening" && isAppOpeningProgress(phase.progress)) {
51186
- const prev = previous?.phase.kind === "opening" && previous.phase.collectionId === phase.collectionId ? previous.phase.progress : null;
51187
- if (prev !== phase.progress) performanceMark(`mdbase:open:stage:${phase.progress}`);
51188
- }
51189
51193
  if (phase.kind === "ready" && (previous?.phase.kind !== "ready" || previous.phase.connection !== phase.connection)) performanceMark("mdbase:open:ready");
51190
51194
  }
51191
51195
 
@@ -55143,7 +55147,7 @@ ${end.comment}` : end.comment;
55143
55147
  * sign-in gesture; a pending ledger keeps its SAME request for authorize(). */
55144
55148
  start() {
55145
55149
  return this.operation(async () => {
55146
- if (this.flow && this.base.status !== "blocked") return this.getSnapshot();
55150
+ if (this.flow && (this.base.status !== "blocked" || this.base.problem === "installation_removed")) return this.getSnapshot();
55147
55151
  this.publish({ status: "starting", problem: null, signOutResult: null });
55148
55152
  const p = this.options;
55149
55153
  this.flow ??= await AppProtectedInstallationSignIn.open({
@@ -55180,6 +55184,7 @@ ${end.comment}` : end.comment;
55180
55184
  * exchange, confirmation or attestation controls are needed by consumers. */
55181
55185
  authorize(options = {}) {
55182
55186
  this.check();
55187
+ if (this.base.problem === "installation_removed") return Promise.reject(failure2("refused"));
55183
55188
  if (this.authorizationRateLimit && Date.now() < this.authorizationRetryAt) return Promise.reject(this.authorizationRateLimit);
55184
55189
  const poll = this.pending !== null && this.pending === this.polling ? this.pending : null;
55185
55190
  if (!this.flow || this.pending && !poll) return Promise.reject(failure2("busy"));
@@ -55217,7 +55222,14 @@ ${end.comment}` : end.comment;
55217
55222
  await this.openDevice();
55218
55223
  this.check();
55219
55224
  await this.abandonUnfinishedNativeChoice();
55220
- const consent = await this.flow.startCollectionConsent(this.installation, this.options.requestedCreateCollections ?? this.options.freshRequestedCreateCollections ?? false, hint, this.options.freshRequestedPrivateDevice === true);
55225
+ let consent;
55226
+ try {
55227
+ consent = await this.flow.startCollectionConsent(this.installation, this.options.requestedCreateCollections ?? this.options.freshRequestedCreateCollections ?? false, hint, this.options.freshRequestedPrivateDevice === true);
55228
+ } catch (error5) {
55229
+ if (!await this.handleRemovedInstallation(error5)) throw error5;
55230
+ portal.close();
55231
+ return this.getSnapshot();
55232
+ }
55221
55233
  this.check();
55222
55234
  this.consentPending = true;
55223
55235
  portal.navigate(consent.verificationUri);
@@ -55613,7 +55625,13 @@ ${end.comment}` : end.comment;
55613
55625
  /** `kept`: this installation's last listing instead of a read. It is not an
55614
55626
  * accepted inventory, so an approval missing from it is not a removal. */
55615
55627
  async refreshCollections(kept = null) {
55616
- const collections = kept ?? await this.flow.listApprovedCollections(this.installation);
55628
+ let collections;
55629
+ try {
55630
+ collections = kept ?? await this.flow.listApprovedCollections(this.installation);
55631
+ } catch (error5) {
55632
+ if (await this.handleRemovedInstallation(error5)) return;
55633
+ throw error5;
55634
+ }
55617
55635
  this.check();
55618
55636
  this.listCached = kept !== null;
55619
55637
  if (!kept) {
@@ -55639,6 +55657,25 @@ ${end.comment}` : end.comment;
55639
55657
  if (this.freshApproval && picked && visible.some((c) => c.collectionId === picked)) await this.openSlot(picked, true);
55640
55658
  else if (visible.length === 1) await this.openSlot(visible[0].collectionId, true);
55641
55659
  }
55660
+ /** Only Connect's exact refusal of this installation's own bearer ends
55661
+ * access across its scopes. Keep the ledger for explicit, per-scope recovery. */
55662
+ async handleRemovedInstallation(error5) {
55663
+ if (!(error5 instanceof AppInstallationSignInError) || !isAppServerProblem(error5.server) || error5.server.status !== 401 || error5.server.code !== "invalid_connector") return false;
55664
+ this.check();
55665
+ this.listCached = false;
55666
+ for (const id6 of this.flow.view().collectionIds) this.removedScopes.add(id6);
55667
+ this.consentPending = false;
55668
+ this.closeApprovalWindow();
55669
+ for (const slot of this.slots.values()) {
55670
+ slot.usable = false;
55671
+ slot.lifetime?.abort();
55672
+ }
55673
+ this.publish({ status: "blocked", problem: "installation_removed", problemDetail: webSignInProblem(error5).detail, collections: Object.freeze([]) });
55674
+ await this.closeSlots();
55675
+ this.check();
55676
+ this.changed();
55677
+ return true;
55678
+ }
55642
55679
  schedulePoll() {
55643
55680
  if (this.pending && !this.closing && !this.options.signal.aborted) return;
55644
55681
  const read2 = this.foregroundRead;
@@ -56104,8 +56141,8 @@ ${end.comment}` : end.comment;
56104
56141
  collectionListCached() {
56105
56142
  return this.listCached;
56106
56143
  }
56107
- /** Accepted COMPLETE inventory omission or terminal native/log refusal only.
56108
- * Local Forget, failed GETs and transient transport failures do not qualify. */
56144
+ /** A complete inventory omission, a terminal scope refusal, or rejection of
56145
+ * the installation's bearer. Transport and unrelated HTTP failures stay separate. */
56109
56146
  scopeWasRemoved(collectionId) {
56110
56147
  return this.removedScopes.has(collectionId);
56111
56148
  }