@mdbase-dev/sdk 0.2.58 → 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.
@@ -15698,12 +15698,12 @@ function appReleaseTrust() {
15698
15698
  // src/application/asset-pins.json
15699
15699
  var asset_pins_default = {
15700
15700
  runtime: {
15701
- sha256: "4f663f240720f2198024cd50f375614fc49e0db203570359d1b1dadee83d1fca",
15702
- bytes: 4070905,
15703
- maxBytes: 4070905,
15701
+ sha256: "18f9cc9ce4e613f23c8d4120fcdd58c7c0865224737e30f905a7173fdb8ada2d",
15702
+ bytes: 4093898,
15703
+ maxBytes: 4093898,
15704
15704
  source: {
15705
15705
  repository: "mdbase-dev/mdbase-connect",
15706
- commit: "7eecb8284a0b1c7ceeda4bee46fe4b3be8526fb0"
15706
+ commit: "2da2b0bc84ee9ecd0ecdef79ea0e2e1ef334bccd"
15707
15707
  }
15708
15708
  },
15709
15709
  sqlite: {
@@ -33966,20 +33966,11 @@ function decode2(value2, scope, depth = 0) {
33966
33966
  if (prior.version !== 4) break;
33967
33967
  prior = prior.previous;
33968
33968
  }
33969
- const plan = modelResourcePlan(v.plan);
33970
- if (plan.resourceOps.some(
33971
- (op2) => op2.kind !== "resource_put" || !op2.mustNotExist && ![
33972
- "mdbase.yaml",
33973
- "mdbase.lock.yaml",
33974
- "mdbase.provisions.yaml"
33975
- ].includes(op2.path)
33976
- ))
33977
- fail8("binding");
33978
33969
  const intent2 = Object.freeze({
33979
33970
  version: 4,
33980
33971
  scope: bound,
33981
33972
  mutationId: v.mutationId,
33982
- plan,
33973
+ plan: modelResourcePlan(v.plan),
33983
33974
  phase: v.phase,
33984
33975
  previous
33985
33976
  });
@@ -38962,7 +38953,7 @@ var AppWebSignInSession = class {
38962
38953
  * sign-in gesture; a pending ledger keeps its SAME request for authorize(). */
38963
38954
  start() {
38964
38955
  return this.operation(async () => {
38965
- 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();
38966
38957
  this.publish({ status: "starting", problem: null, signOutResult: null });
38967
38958
  const p = this.options;
38968
38959
  this.flow ??= await AppProtectedInstallationSignIn.open({
@@ -38999,6 +38990,7 @@ var AppWebSignInSession = class {
38999
38990
  * exchange, confirmation or attestation controls are needed by consumers. */
39000
38991
  authorize(options = {}) {
39001
38992
  this.check();
38993
+ if (this.base.problem === "installation_removed") return Promise.reject(failure("refused"));
39002
38994
  if (this.authorizationRateLimit && Date.now() < this.authorizationRetryAt) return Promise.reject(this.authorizationRateLimit);
39003
38995
  const poll = this.pending !== null && this.pending === this.polling ? this.pending : null;
39004
38996
  if (!this.flow || this.pending && !poll) return Promise.reject(failure("busy"));
@@ -39036,7 +39028,14 @@ var AppWebSignInSession = class {
39036
39028
  await this.openDevice();
39037
39029
  this.check();
39038
39030
  await this.abandonUnfinishedNativeChoice();
39039
- 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
+ }
39040
39039
  this.check();
39041
39040
  this.consentPending = true;
39042
39041
  portal.navigate(consent.verificationUri);
@@ -39432,7 +39431,13 @@ var AppWebSignInSession = class {
39432
39431
  /** `kept`: this installation's last listing instead of a read. It is not an
39433
39432
  * accepted inventory, so an approval missing from it is not a removal. */
39434
39433
  async refreshCollections(kept = null) {
39435
- 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
+ }
39436
39441
  this.check();
39437
39442
  this.listCached = kept !== null;
39438
39443
  if (!kept) {
@@ -39458,6 +39463,25 @@ var AppWebSignInSession = class {
39458
39463
  if (this.freshApproval && picked && visible.some((c) => c.collectionId === picked)) await this.openSlot(picked, true);
39459
39464
  else if (visible.length === 1) await this.openSlot(visible[0].collectionId, true);
39460
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
+ }
39461
39485
  schedulePoll() {
39462
39486
  if (this.pending && !this.closing && !this.options.signal.aborted) return;
39463
39487
  const read = this.foregroundRead;
@@ -39923,8 +39947,8 @@ var AppWebSignInSession = class {
39923
39947
  collectionListCached() {
39924
39948
  return this.listCached;
39925
39949
  }
39926
- /** Accepted COMPLETE inventory omission or terminal native/log refusal only.
39927
- * 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. */
39928
39952
  scopeWasRemoved(collectionId) {
39929
39953
  return this.removedScopes.has(collectionId);
39930
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 {
@@ -30737,20 +30727,11 @@ ${end.comment}` : end.comment;
30737
30727
  if (prior.version !== 4) break;
30738
30728
  prior = prior.previous;
30739
30729
  }
30740
- const plan = modelResourcePlan(v.plan);
30741
- if (plan.resourceOps.some(
30742
- (op2) => op2.kind !== "resource_put" || !op2.mustNotExist && ![
30743
- "mdbase.yaml",
30744
- "mdbase.lock.yaml",
30745
- "mdbase.provisions.yaml"
30746
- ].includes(op2.path)
30747
- ))
30748
- fail7("binding");
30749
30730
  const intent2 = Object.freeze({
30750
30731
  version: 4,
30751
30732
  scope: bound,
30752
30733
  mutationId: v.mutationId,
30753
- plan,
30734
+ plan: modelResourcePlan(v.plan),
30754
30735
  phase: v.phase,
30755
30736
  previous
30756
30737
  });
@@ -38923,6 +38904,18 @@ ${end.comment}` : end.comment;
38923
38904
  }
38924
38905
  });
38925
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
+
38926
38919
  // src/application/sign-out.ts
38927
38920
  function pendingWrites(connection) {
38928
38921
  let status = 0, ledger = 0;
@@ -49805,7 +49798,9 @@ ${end.comment}` : end.comment;
49805
49798
  var init_runtime = __esm({
49806
49799
  "src/application/runtime.ts"() {
49807
49800
  "use strict";
49801
+ init_opening_progress();
49808
49802
  init_errors();
49803
+ init_performance_mark();
49809
49804
  init_worker_protocol();
49810
49805
  init_sign_out();
49811
49806
  init_scope();
@@ -49996,7 +49991,12 @@ ${end.comment}` : end.comment;
49996
49991
  }
49997
49992
  } else if (status !== "blocked") this.loggedProblem = null;
49998
49993
  const { problemDetail: _native, ...raw } = this.raw;
49999
- 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
+ }
50000
50000
  }
50001
50001
  for (const listener of [...this.listeners]) try {
50002
50002
  listener();
@@ -51079,12 +51079,12 @@ ${end.comment}` : end.comment;
51079
51079
  // src/application/asset-pins.json
51080
51080
  var asset_pins_default = {
51081
51081
  runtime: {
51082
- sha256: "4f663f240720f2198024cd50f375614fc49e0db203570359d1b1dadee83d1fca",
51083
- bytes: 4070905,
51084
- maxBytes: 4070905,
51082
+ sha256: "18f9cc9ce4e613f23c8d4120fcdd58c7c0865224737e30f905a7173fdb8ada2d",
51083
+ bytes: 4093898,
51084
+ maxBytes: 4093898,
51085
51085
  source: {
51086
51086
  repository: "mdbase-dev/mdbase-connect",
51087
- commit: "7eecb8284a0b1c7ceeda4bee46fe4b3be8526fb0"
51087
+ commit: "2da2b0bc84ee9ecd0ecdef79ea0e2e1ef334bccd"
51088
51088
  }
51089
51089
  },
51090
51090
  sqlite: {
@@ -51138,7 +51138,6 @@ ${end.comment}` : end.comment;
51138
51138
  }
51139
51139
 
51140
51140
  // src/application/startup-timing.ts
51141
- init_opening_progress();
51142
51141
  init_performance_mark();
51143
51142
  var PREFIX = "mdbase:startup:";
51144
51143
  var WAITS = /* @__PURE__ */ new Set(["signed_out", "authorizing", "choosing", "needs_approval", "needs_setup", "problem", "unavailable", "closed"]);
@@ -51191,10 +51190,6 @@ ${end.comment}` : end.comment;
51191
51190
  if (changed3) performanceMark("mdbase:open:requested");
51192
51191
  if (selection.requested.approved && (changed3 || !previous?.selection.requested.approved)) performanceMark("mdbase:open:approved");
51193
51192
  }
51194
- if (phase.kind === "opening" && isAppOpeningProgress(phase.progress)) {
51195
- const prev = previous?.phase.kind === "opening" && previous.phase.collectionId === phase.collectionId ? previous.phase.progress : null;
51196
- if (prev !== phase.progress) performanceMark(`mdbase:open:stage:${phase.progress}`);
51197
- }
51198
51193
  if (phase.kind === "ready" && (previous?.phase.kind !== "ready" || previous.phase.connection !== phase.connection)) performanceMark("mdbase:open:ready");
51199
51194
  }
51200
51195
 
@@ -55152,7 +55147,7 @@ ${end.comment}` : end.comment;
55152
55147
  * sign-in gesture; a pending ledger keeps its SAME request for authorize(). */
55153
55148
  start() {
55154
55149
  return this.operation(async () => {
55155
- 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();
55156
55151
  this.publish({ status: "starting", problem: null, signOutResult: null });
55157
55152
  const p = this.options;
55158
55153
  this.flow ??= await AppProtectedInstallationSignIn.open({
@@ -55189,6 +55184,7 @@ ${end.comment}` : end.comment;
55189
55184
  * exchange, confirmation or attestation controls are needed by consumers. */
55190
55185
  authorize(options = {}) {
55191
55186
  this.check();
55187
+ if (this.base.problem === "installation_removed") return Promise.reject(failure2("refused"));
55192
55188
  if (this.authorizationRateLimit && Date.now() < this.authorizationRetryAt) return Promise.reject(this.authorizationRateLimit);
55193
55189
  const poll = this.pending !== null && this.pending === this.polling ? this.pending : null;
55194
55190
  if (!this.flow || this.pending && !poll) return Promise.reject(failure2("busy"));
@@ -55226,7 +55222,14 @@ ${end.comment}` : end.comment;
55226
55222
  await this.openDevice();
55227
55223
  this.check();
55228
55224
  await this.abandonUnfinishedNativeChoice();
55229
- 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
+ }
55230
55233
  this.check();
55231
55234
  this.consentPending = true;
55232
55235
  portal.navigate(consent.verificationUri);
@@ -55622,7 +55625,13 @@ ${end.comment}` : end.comment;
55622
55625
  /** `kept`: this installation's last listing instead of a read. It is not an
55623
55626
  * accepted inventory, so an approval missing from it is not a removal. */
55624
55627
  async refreshCollections(kept = null) {
55625
- 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
+ }
55626
55635
  this.check();
55627
55636
  this.listCached = kept !== null;
55628
55637
  if (!kept) {
@@ -55648,6 +55657,25 @@ ${end.comment}` : end.comment;
55648
55657
  if (this.freshApproval && picked && visible.some((c) => c.collectionId === picked)) await this.openSlot(picked, true);
55649
55658
  else if (visible.length === 1) await this.openSlot(visible[0].collectionId, true);
55650
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
+ }
55651
55679
  schedulePoll() {
55652
55680
  if (this.pending && !this.closing && !this.options.signal.aborted) return;
55653
55681
  const read2 = this.foregroundRead;
@@ -56113,8 +56141,8 @@ ${end.comment}` : end.comment;
56113
56141
  collectionListCached() {
56114
56142
  return this.listCached;
56115
56143
  }
56116
- /** Accepted COMPLETE inventory omission or terminal native/log refusal only.
56117
- * 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. */
56118
56146
  scopeWasRemoved(collectionId) {
56119
56147
  return this.removedScopes.has(collectionId);
56120
56148
  }