@mdbase-dev/sdk 0.1.0-beta.226 → 0.1.0-beta.228

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.
@@ -15687,12 +15687,12 @@ function appReleaseTrust() {
15687
15687
  // src/application/asset-pins.json
15688
15688
  var asset_pins_default = {
15689
15689
  runtime: {
15690
- sha256: "f63b67f7d68f2bbd653eca8cf10a365dd302b6ef1c2781e77583cb8e123148d5",
15691
- bytes: 3912697,
15692
- maxBytes: 3912697,
15690
+ sha256: "4920cd466a3d246f38c9b7fb3efe13eb48bde6f1b4c0392c3484b2e34c804c97",
15691
+ bytes: 3921681,
15692
+ maxBytes: 3921681,
15693
15693
  source: {
15694
15694
  repository: "mdbase-dev/mdbase-connect",
15695
- commit: "6383ea5d2627ac3334bebfc5f8a10c2587c687a2"
15695
+ commit: "039c7253e12af2710b9ab8be64f4c037766bf1ef"
15696
15696
  }
15697
15697
  },
15698
15698
  sqlite: {
@@ -17775,7 +17775,9 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
17775
17775
  }
17776
17776
  const attempt = async () => {
17777
17777
  check3();
17778
- if (this.state.recoveryFor || typeof requestedCreateCollections !== "boolean" || typeof requestedPrivateDevice !== "boolean") throw fail3("binding");
17778
+ if (typeof requestedCreateCollections !== "boolean" || typeof requestedPrivateDevice !== "boolean") throw fail3("binding");
17779
+ const recovery2 = this.state.recoveryFor;
17780
+ if (recovery2 && (hint !== recovery2.collectionId || requestedCreateCollections || requestedPrivateDevice && !(this.state.requestedPrivateDevice === true && this.state.privateDeviceCollectionIds?.includes(recovery2.collectionId) === true))) throw fail3("binding");
17779
17781
  let r = this.state.consentRequest;
17780
17782
  if (!r || r.completed) {
17781
17783
  const bytes10 = crypto.getRandomValues(new Uint8Array(32));
@@ -17791,7 +17793,7 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
17791
17793
  const s = this.state, token = s.token, req = r;
17792
17794
  let reply;
17793
17795
  try {
17794
- reply = await this.consentWindow(req.requestId, () => this.json("/v1/pairing-requests", false, { installation: { app_id: s.appId, request_id: req.requestId, pairing_secret: req.secret, installation_id: s.installationId, device_id: s.deviceId, kind: s.kind, requested_create_collections: req.requestedCreateCollections, ...req.requestedPrivateDevice === true ? { requested_private_device: true } : {}, reconsent: true }, ...hint ? { collection_hint: hint } : {} }, { bearer: token }));
17796
+ reply = await this.consentWindow(req.requestId, () => this.json("/v1/pairing-requests", false, { installation: { app_id: s.appId, request_id: req.requestId, pairing_secret: req.secret, installation_id: s.installationId, device_id: s.deviceId, kind: s.kind, requested_create_collections: req.requestedCreateCollections, ...req.requestedPrivateDevice === true ? { requested_private_device: true } : {}, ...s.recoveryFor ? { recovery_collection_id: s.recoveryFor.collectionId } : {}, reconsent: true }, ...hint ? { collection_hint: hint } : {} }, { bearer: token }));
17795
17797
  } catch (error4) {
17796
17798
  if (req.requestedPrivateDevice !== true || !(error4 instanceof AppInstallationSignInError) || !privateDeviceFieldRefused.has(error4)) throw error4;
17797
17799
  check3();
@@ -17802,7 +17804,8 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
17802
17804
  }
17803
17805
  check3();
17804
17806
  const { status, value: v } = reply;
17805
- object2(v, "pairing_id,pairing_secret,verification_uri,expires_in,installation_device,app_id,app_origin,app_name");
17807
+ object2(v, `pairing_id,pairing_secret,verification_uri,expires_in,installation_device,app_id,app_origin,app_name${this.recoveryTargetKeys()}`);
17808
+ this.assertRecoveryTarget(v);
17806
17809
  let uri = null;
17807
17810
  if (status !== 200 && status !== 201 || v.pairing_id !== r.requestId || v.pairing_secret !== r.secret || (uri = verificationUri(v.verification_uri, `${s.cpOrigin}/pair/${r.requestId}`, hint)) === null || v.installation_device !== true || v.app_id !== s.appId || v.app_origin !== s.origin || v.app_name !== this.options.appName || !Number.isSafeInteger(v.expires_in) || v.expires_in < 0 || v.expires_in > 600 || token !== this.state.token) throw fail3("response");
17808
17811
  return Object.freeze({ ...this.collectionConsentView(), verificationUri: uri });
@@ -17829,12 +17832,13 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
17829
17832
  const { status, value: v } = await this.consentWindow(r.requestId, () => this.json(`/v1/pairing-requests/${r.requestId}/exchange`, false, void 0, { bearer: r.secret }));
17830
17833
  check3();
17831
17834
  const portal = portalKeys(v);
17832
- const keys2 = `status,request_id,account_id,connector_id,device_id,installation_id,kind,challenge,approval_mode,app_id,app_origin,expires_at${portal}`;
17835
+ const keys2 = `status,request_id,account_id,connector_id,device_id,installation_id,kind,challenge,approval_mode,app_id,app_origin,expires_at${portal}${this.recoveryTargetKeys()}`;
17833
17836
  const done = v.status === "scope_updated";
17834
17837
  const picked = done && (Object.hasOwn(v, "selected_collection_id") || Object.hasOwn(v, "created_collection_ids"));
17835
17838
  const native = done && Object.hasOwn(v, "native_selection");
17836
17839
  const deviceKey = !done ? null : Object.hasOwn(v, "added_private_device_collection_ids") ? "added_private_device_collection_ids" : Object.hasOwn(v, "private_device_collection_ids") ? "private_device_collection_ids" : null;
17837
17840
  object2(v, `${keys2}${done ? ",added_collection_ids,approved_create_collections" : ""}${deviceKey ? `,${deviceKey}` : ""}${picked ? ",selected_collection_id,created_collection_ids" : ""}${native ? ",native_selection" : ""}${done ? timerKeys(v) : ""}`);
17841
+ this.assertRecoveryTarget(v);
17838
17842
  if (!done && (status !== 202 || v.status !== "awaiting_approval") || done && status !== 200 || v.request_id !== r.requestId || v.account_id !== s.selection.accountId || v.connector_id !== s.selection.connectorId || v.device_id !== s.deviceId || v.installation_id !== s.installationId || v.kind !== s.kind || v.app_id !== s.appId || v.app_origin !== s.origin || v.approval_mode !== s.selection.approvalMode || !Number.isSafeInteger(v.expires_at) || v.expires_at < 0) throw fail3("binding");
17839
17843
  const confirmation2 = portalMetadata(v);
17840
17844
  if (r.portalConfirmed && !portal) throw fail3("response");
@@ -17860,7 +17864,9 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
17860
17864
  if (v.timer_consent === true && !collectionSelection) throw fail3("response");
17861
17865
  const timerScope = collectionSelection ? [.../* @__PURE__ */ new Set([...addedCollectionIds, collectionSelection.selectedCollectionId])] : addedCollectionIds;
17862
17866
  const reminder = timerConsent(v, r.requestId, timerScope, confirmation2.portalConfirmed === true, collectionSelection?.selectedCollectionId);
17863
- await this.save({ ...s, collectionIds, privateDeviceCollectionIds: privateDeviceCollectionIds.length ? privateDeviceCollectionIds : void 0, nativeSelection, ...nativeSelection || !collectionSelection && addedPrivateIds.length > 0 ? { collectionSelection: void 0 } : collectionSelection ? { collectionSelection } : {}, ...reminder ? { timerConsent: reminder } : {}, createCollections: s.createCollections || v.approved_create_collections, consentRequest: { ...r, ...confirmation2, challenge, completed: true, addedCollectionIds, approvedCreateCollections: v.approved_create_collections } });
17867
+ const nextSelection = nativeSelection || !collectionSelection && addedPrivateIds.length > 0 ? void 0 : collectionSelection ?? s.collectionSelection;
17868
+ if (s.recoveryFor && (native || v.approved_create_collections || !_AppProtectedInstallationSignIn.recovered(s.recoveryFor.collectionId, collectionIds, privateDeviceCollectionIds, nextSelection))) throw fail3("binding");
17869
+ await this.save({ ...s, collectionIds, privateDeviceCollectionIds: privateDeviceCollectionIds.length ? privateDeviceCollectionIds : void 0, nativeSelection, collectionSelection: nextSelection, ...reminder ? { timerConsent: reminder } : {}, createCollections: s.createCollections || v.approved_create_collections, consentRequest: { ...r, ...confirmation2, challenge, completed: true, addedCollectionIds, approvedCreateCollections: v.approved_create_collections } });
17864
17870
  check3();
17865
17871
  return this.collectionConsentView();
17866
17872
  });
@@ -37433,6 +37439,20 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
37433
37439
  }
37434
37440
  return this.peopleMetadata.view;
37435
37441
  }
37442
+ /** The reminder consent a timer port for `collection` is bound to, or null
37443
+ * when no port would be opened for it. A port stays current only while
37444
+ * this is unchanged, so an open collection compares it to learn that its
37445
+ * ports carry a timer state the consent no longer gives. */
37446
+ timerConsentKey(collection) {
37447
+ const granted = this.timerGrant(collection);
37448
+ return granted ? JSON.stringify(granted.consent) : null;
37449
+ }
37450
+ timerGrant(collection) {
37451
+ const callback = this.source.timerConsent, consent = callback?.call(this.source);
37452
+ if (!consent?.approved) return null;
37453
+ const grant = consent.grants.find((reference) => reference.collectionId === collection);
37454
+ return grant ? { callback, consent, grant } : null;
37455
+ }
37436
37456
  /** SAME Worker host/scope/child lifetime. Only the original chosen receipt
37437
37457
  * selects a fixed native CP receiver; no session or bearer leaves Worker. */
37438
37458
  openTimersPort(options) {
@@ -37440,10 +37460,9 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
37440
37460
  if (!this.readVerified || !this.logRequest || !this.collectionScope || options.signal.aborted) throw fail15("binding");
37441
37461
  const { scope, generation, signal } = options, original = this.collectionScope;
37442
37462
  if (scope.account !== original.account || scope.installation !== original.installation || scope.collection !== original.collection || uuidToBytes(generation).every((value2) => value2 === 0)) throw fail15("binding");
37443
- const callback = this.source.timerConsent, consent = callback?.call(this.source);
37444
- if (!consent?.approved) return null;
37445
- const grant = consent.grants.find((reference) => reference.collectionId === scope.collection);
37446
- if (!grant) return null;
37463
+ const granted = this.timerGrant(scope.collection);
37464
+ if (!granted) return null;
37465
+ const { callback, consent, grant } = granted;
37447
37466
  const WorkerScope2 = globalThis.WorkerGlobalScope;
37448
37467
  if (typeof WorkerScope2 !== "function" || !(globalThis instanceof WorkerScope2)) throw fail15("binding");
37449
37468
  if (uuidToBytes(grant.grantId).every((value2) => value2 === 0) || !/^[0-9a-f]{64}$/.test(grant.declarationDigest)) throw fail15("binding");
@@ -40726,6 +40745,14 @@ function createAppWebCollectionAdapter(source) {
40726
40745
  let push = null, paused = false, pausing = null, kicked = false;
40727
40746
  let ended = null;
40728
40747
  const attached = /* @__PURE__ */ new Map();
40748
+ const timerKeys2 = /* @__PURE__ */ new Map();
40749
+ const timerKey = () => {
40750
+ try {
40751
+ return host.timerConsentKey(scope.collection);
40752
+ } catch {
40753
+ return void 0;
40754
+ }
40755
+ };
40729
40756
  let problem4 = null;
40730
40757
  const listeners = /* @__PURE__ */ new Set();
40731
40758
  const current2 = () => {
@@ -41183,6 +41210,7 @@ function createAppWebCollectionAdapter(source) {
41183
41210
  const generation = crypto.randomUUID();
41184
41211
  let attachOpened = null;
41185
41212
  let detachOpened = null;
41213
+ let renewOpened = null;
41186
41214
  if (isPrivate) {
41187
41215
  report("syncing");
41188
41216
  const key3 = await host.settlePrivateKey({ signal: life.signal });
@@ -41263,11 +41291,13 @@ function createAppWebCollectionAdapter(source) {
41263
41291
  });
41264
41292
  timers = host.openTimersPort({ scope, generation, signal: life.signal });
41265
41293
  check3();
41294
+ const openedKey = timerKey() ?? null;
41266
41295
  data = new MessageChannel();
41267
41296
  command = new MessageChannel();
41268
41297
  control = controlFor(data.port1, command.port1, setForeground, abort);
41269
41298
  check3();
41270
41299
  const detach = (handoff) => {
41300
+ timerKeys2.delete(handoff.dataPort);
41271
41301
  if (data && command && handoff.dataPort === data.port2) {
41272
41302
  const own = { data, command, control, timers };
41273
41303
  data = null;
@@ -41308,13 +41338,14 @@ function createAppWebCollectionAdapter(source) {
41308
41338
  }
41309
41339
  }
41310
41340
  };
41311
- const attach = () => {
41341
+ const attach = (mode = setupMode === "reconcile-original" ? setupMode : "inspect") => {
41312
41342
  if (!current2() || ended !== null) return null;
41313
41343
  const d = new MessageChannel(), c = new MessageChannel();
41314
41344
  let t = null, ctl = null;
41315
41345
  try {
41316
41346
  t = host.openTimersPort({ scope, generation, signal: life.signal });
41317
41347
  let value2 = null;
41348
+ const key3 = timerKey() ?? null;
41318
41349
  ctl = controlFor(d.port1, c.port1, () => {
41319
41350
  }, () => {
41320
41351
  if (value2) detach(value2);
@@ -41324,13 +41355,14 @@ function createAppWebCollectionAdapter(source) {
41324
41355
  scope,
41325
41356
  generation,
41326
41357
  displayName,
41327
- setupMode: setupMode === "reconcile-original" ? setupMode : "inspect",
41358
+ setupMode: mode,
41328
41359
  dataPort: d.port2,
41329
41360
  controlPort: c.port2,
41330
41361
  ...people,
41331
41362
  ...t ? { timerPort: t.port } : {}
41332
41363
  });
41333
41364
  attached.set(d.port2, { data: d, command: c, control: ctl, timers: t });
41365
+ timerKeys2.set(d.port2, key3);
41334
41366
  return value2;
41335
41367
  } catch {
41336
41368
  try {
@@ -41345,8 +41377,18 @@ function createAppWebCollectionAdapter(source) {
41345
41377
  return null;
41346
41378
  }
41347
41379
  };
41380
+ const renew = (handoff) => {
41381
+ if (!current2() || !timerKeys2.has(handoff.dataPort)) return null;
41382
+ const key3 = timerKey();
41383
+ if (key3 === void 0 || key3 === timerKeys2.get(handoff.dataPort)) return null;
41384
+ const value2 = attach(handoff.setupMode);
41385
+ if (value2) detach(handoff);
41386
+ return value2;
41387
+ };
41348
41388
  attachOpened = attach;
41349
41389
  detachOpened = detach;
41390
+ renewOpened = renew;
41391
+ timerKeys2.set(data.port2, openedKey);
41350
41392
  options.handoff(Object.freeze({
41351
41393
  schema: "mdbn-app-collection/1",
41352
41394
  scope,
@@ -41369,7 +41411,8 @@ function createAppWebCollectionAdapter(source) {
41369
41411
  attach: () => attachOpened ? attachOpened() : null,
41370
41412
  detach: (handoff) => {
41371
41413
  detachOpened?.(handoff);
41372
- }
41414
+ },
41415
+ renewTimers: (handoff) => renewOpened ? renewOpened(handoff) : null
41373
41416
  });
41374
41417
  const unlock = async (secret) => {
41375
41418
  check3();
@@ -42439,14 +42482,16 @@ var ApplicationWorkerHost = class {
42439
42482
  } catch {
42440
42483
  }
42441
42484
  }
42442
- /** Give every tab without ports for its open collection its own. */
42485
+ /** Give every tab without ports for its open collection its own, and new
42486
+ * ones to a tab whose ports were made under a reminder consent that has
42487
+ * since changed (an approval granted reminders while it was open). */
42443
42488
  reconcile() {
42444
42489
  if (this.stopping) return;
42445
42490
  for (const client of [...this.clients.values()]) {
42446
42491
  if (client.gone || client.selected === null) continue;
42447
42492
  const connection = this.connectionOf(client.selected);
42448
- if (!connection?.isCurrent() || typeof connection.attach !== "function" || client.generation === connection.generation) continue;
42449
- const value2 = connection.attach();
42493
+ if (!connection?.isCurrent() || typeof connection.attach !== "function") continue;
42494
+ const value2 = client.generation !== connection.generation ? connection.attach() : client.handoff ? connection.renewTimers?.(client.handoff) ?? null : null;
42450
42495
  if (!value2) continue;
42451
42496
  client.generation = connection.generation;
42452
42497
  client.handoff = value2;
@@ -42799,10 +42844,8 @@ var ApplicationWorkerHost = class {
42799
42844
  break;
42800
42845
  case "select": {
42801
42846
  const id4 = payload;
42802
- if (client.selected !== id4) {
42803
- this.leave(client);
42804
- client.selected = id4;
42805
- }
42847
+ this.leave(client);
42848
+ client.selected = id4;
42806
42849
  try {
42807
42850
  await this.session.openCollection(id4);
42808
42851
  } finally {
@@ -27385,7 +27385,9 @@ ${end.comment}` : end.comment;
27385
27385
  }
27386
27386
  const attempt = async () => {
27387
27387
  check3();
27388
- if (this.state.recoveryFor || typeof requestedCreateCollections !== "boolean" || typeof requestedPrivateDevice !== "boolean") throw fail3("binding");
27388
+ if (typeof requestedCreateCollections !== "boolean" || typeof requestedPrivateDevice !== "boolean") throw fail3("binding");
27389
+ const recovery2 = this.state.recoveryFor;
27390
+ if (recovery2 && (hint !== recovery2.collectionId || requestedCreateCollections || requestedPrivateDevice && !(this.state.requestedPrivateDevice === true && this.state.privateDeviceCollectionIds?.includes(recovery2.collectionId) === true))) throw fail3("binding");
27389
27391
  let r = this.state.consentRequest;
27390
27392
  if (!r || r.completed) {
27391
27393
  const bytes10 = crypto.getRandomValues(new Uint8Array(32));
@@ -27401,7 +27403,7 @@ ${end.comment}` : end.comment;
27401
27403
  const s = this.state, token = s.token, req = r;
27402
27404
  let reply;
27403
27405
  try {
27404
- reply = await this.consentWindow(req.requestId, () => this.json("/v1/pairing-requests", false, { installation: { app_id: s.appId, request_id: req.requestId, pairing_secret: req.secret, installation_id: s.installationId, device_id: s.deviceId, kind: s.kind, requested_create_collections: req.requestedCreateCollections, ...req.requestedPrivateDevice === true ? { requested_private_device: true } : {}, reconsent: true }, ...hint ? { collection_hint: hint } : {} }, { bearer: token }));
27406
+ reply = await this.consentWindow(req.requestId, () => this.json("/v1/pairing-requests", false, { installation: { app_id: s.appId, request_id: req.requestId, pairing_secret: req.secret, installation_id: s.installationId, device_id: s.deviceId, kind: s.kind, requested_create_collections: req.requestedCreateCollections, ...req.requestedPrivateDevice === true ? { requested_private_device: true } : {}, ...s.recoveryFor ? { recovery_collection_id: s.recoveryFor.collectionId } : {}, reconsent: true }, ...hint ? { collection_hint: hint } : {} }, { bearer: token }));
27405
27407
  } catch (error5) {
27406
27408
  if (req.requestedPrivateDevice !== true || !(error5 instanceof AppInstallationSignInError) || !privateDeviceFieldRefused.has(error5)) throw error5;
27407
27409
  check3();
@@ -27412,7 +27414,8 @@ ${end.comment}` : end.comment;
27412
27414
  }
27413
27415
  check3();
27414
27416
  const { status, value: v } = reply;
27415
- object5(v, "pairing_id,pairing_secret,verification_uri,expires_in,installation_device,app_id,app_origin,app_name");
27417
+ object5(v, `pairing_id,pairing_secret,verification_uri,expires_in,installation_device,app_id,app_origin,app_name${this.recoveryTargetKeys()}`);
27418
+ this.assertRecoveryTarget(v);
27416
27419
  let uri = null;
27417
27420
  if (status !== 200 && status !== 201 || v.pairing_id !== r.requestId || v.pairing_secret !== r.secret || (uri = verificationUri(v.verification_uri, `${s.cpOrigin}/pair/${r.requestId}`, hint)) === null || v.installation_device !== true || v.app_id !== s.appId || v.app_origin !== s.origin || v.app_name !== this.options.appName || !Number.isSafeInteger(v.expires_in) || v.expires_in < 0 || v.expires_in > 600 || token !== this.state.token) throw fail3("response");
27418
27421
  return Object.freeze({ ...this.collectionConsentView(), verificationUri: uri });
@@ -27439,12 +27442,13 @@ ${end.comment}` : end.comment;
27439
27442
  const { status, value: v } = await this.consentWindow(r.requestId, () => this.json(`/v1/pairing-requests/${r.requestId}/exchange`, false, void 0, { bearer: r.secret }));
27440
27443
  check3();
27441
27444
  const portal = portalKeys(v);
27442
- const keys2 = `status,request_id,account_id,connector_id,device_id,installation_id,kind,challenge,approval_mode,app_id,app_origin,expires_at${portal}`;
27445
+ const keys2 = `status,request_id,account_id,connector_id,device_id,installation_id,kind,challenge,approval_mode,app_id,app_origin,expires_at${portal}${this.recoveryTargetKeys()}`;
27443
27446
  const done = v.status === "scope_updated";
27444
27447
  const picked = done && (Object.hasOwn(v, "selected_collection_id") || Object.hasOwn(v, "created_collection_ids"));
27445
27448
  const native = done && Object.hasOwn(v, "native_selection");
27446
27449
  const deviceKey = !done ? null : Object.hasOwn(v, "added_private_device_collection_ids") ? "added_private_device_collection_ids" : Object.hasOwn(v, "private_device_collection_ids") ? "private_device_collection_ids" : null;
27447
27450
  object5(v, `${keys2}${done ? ",added_collection_ids,approved_create_collections" : ""}${deviceKey ? `,${deviceKey}` : ""}${picked ? ",selected_collection_id,created_collection_ids" : ""}${native ? ",native_selection" : ""}${done ? timerKeys(v) : ""}`);
27451
+ this.assertRecoveryTarget(v);
27448
27452
  if (!done && (status !== 202 || v.status !== "awaiting_approval") || done && status !== 200 || v.request_id !== r.requestId || v.account_id !== s.selection.accountId || v.connector_id !== s.selection.connectorId || v.device_id !== s.deviceId || v.installation_id !== s.installationId || v.kind !== s.kind || v.app_id !== s.appId || v.app_origin !== s.origin || v.approval_mode !== s.selection.approvalMode || !Number.isSafeInteger(v.expires_at) || v.expires_at < 0) throw fail3("binding");
27449
27453
  const confirmation2 = portalMetadata(v);
27450
27454
  if (r.portalConfirmed && !portal) throw fail3("response");
@@ -27470,7 +27474,9 @@ ${end.comment}` : end.comment;
27470
27474
  if (v.timer_consent === true && !collectionSelection) throw fail3("response");
27471
27475
  const timerScope = collectionSelection ? [.../* @__PURE__ */ new Set([...addedCollectionIds, collectionSelection.selectedCollectionId])] : addedCollectionIds;
27472
27476
  const reminder = timerConsent(v, r.requestId, timerScope, confirmation2.portalConfirmed === true, collectionSelection?.selectedCollectionId);
27473
- await this.save({ ...s, collectionIds, privateDeviceCollectionIds: privateDeviceCollectionIds.length ? privateDeviceCollectionIds : void 0, nativeSelection, ...nativeSelection || !collectionSelection && addedPrivateIds.length > 0 ? { collectionSelection: void 0 } : collectionSelection ? { collectionSelection } : {}, ...reminder ? { timerConsent: reminder } : {}, createCollections: s.createCollections || v.approved_create_collections, consentRequest: { ...r, ...confirmation2, challenge, completed: true, addedCollectionIds, approvedCreateCollections: v.approved_create_collections } });
27477
+ const nextSelection = nativeSelection || !collectionSelection && addedPrivateIds.length > 0 ? void 0 : collectionSelection ?? s.collectionSelection;
27478
+ if (s.recoveryFor && (native || v.approved_create_collections || !_AppProtectedInstallationSignIn.recovered(s.recoveryFor.collectionId, collectionIds, privateDeviceCollectionIds, nextSelection))) throw fail3("binding");
27479
+ await this.save({ ...s, collectionIds, privateDeviceCollectionIds: privateDeviceCollectionIds.length ? privateDeviceCollectionIds : void 0, nativeSelection, collectionSelection: nextSelection, ...reminder ? { timerConsent: reminder } : {}, createCollections: s.createCollections || v.approved_create_collections, consentRequest: { ...r, ...confirmation2, challenge, completed: true, addedCollectionIds, approvedCreateCollections: v.approved_create_collections } });
27474
27480
  check3();
27475
27481
  return this.collectionConsentView();
27476
27482
  });
@@ -44962,6 +44968,20 @@ ${end.comment}` : end.comment;
44962
44968
  }
44963
44969
  return this.peopleMetadata.view;
44964
44970
  }
44971
+ /** The reminder consent a timer port for `collection` is bound to, or null
44972
+ * when no port would be opened for it. A port stays current only while
44973
+ * this is unchanged, so an open collection compares it to learn that its
44974
+ * ports carry a timer state the consent no longer gives. */
44975
+ timerConsentKey(collection2) {
44976
+ const granted = this.timerGrant(collection2);
44977
+ return granted ? JSON.stringify(granted.consent) : null;
44978
+ }
44979
+ timerGrant(collection2) {
44980
+ const callback = this.source.timerConsent, consent = callback?.call(this.source);
44981
+ if (!consent?.approved) return null;
44982
+ const grant = consent.grants.find((reference) => reference.collectionId === collection2);
44983
+ return grant ? { callback, consent, grant } : null;
44984
+ }
44965
44985
  /** SAME Worker host/scope/child lifetime. Only the original chosen receipt
44966
44986
  * selects a fixed native CP receiver; no session or bearer leaves Worker. */
44967
44987
  openTimersPort(options) {
@@ -44969,10 +44989,9 @@ ${end.comment}` : end.comment;
44969
44989
  if (!this.readVerified || !this.logRequest || !this.collectionScope || options.signal.aborted) throw fail16("binding");
44970
44990
  const { scope, generation, signal } = options, original = this.collectionScope;
44971
44991
  if (scope.account !== original.account || scope.installation !== original.installation || scope.collection !== original.collection || uuidToBytes(generation).every((value2) => value2 === 0)) throw fail16("binding");
44972
- const callback = this.source.timerConsent, consent = callback?.call(this.source);
44973
- if (!consent?.approved) return null;
44974
- const grant = consent.grants.find((reference) => reference.collectionId === scope.collection);
44975
- if (!grant) return null;
44992
+ const granted = this.timerGrant(scope.collection);
44993
+ if (!granted) return null;
44994
+ const { callback, consent, grant } = granted;
44976
44995
  const WorkerScope = globalThis.WorkerGlobalScope;
44977
44996
  if (typeof WorkerScope !== "function" || !(globalThis instanceof WorkerScope)) throw fail16("binding");
44978
44997
  if (uuidToBytes(grant.grantId).every((value2) => value2 === 0) || !/^[0-9a-f]{64}$/.test(grant.declarationDigest)) throw fail16("binding");
@@ -45760,6 +45779,14 @@ ${end.comment}` : end.comment;
45760
45779
  let push = null, paused = false, pausing = null, kicked = false;
45761
45780
  let ended = null;
45762
45781
  const attached = /* @__PURE__ */ new Map();
45782
+ const timerKeys2 = /* @__PURE__ */ new Map();
45783
+ const timerKey = () => {
45784
+ try {
45785
+ return host.timerConsentKey(scope.collection);
45786
+ } catch {
45787
+ return void 0;
45788
+ }
45789
+ };
45763
45790
  let problem7 = null;
45764
45791
  const listeners = /* @__PURE__ */ new Set();
45765
45792
  const current3 = () => {
@@ -46217,6 +46244,7 @@ ${end.comment}` : end.comment;
46217
46244
  const generation = crypto.randomUUID();
46218
46245
  let attachOpened = null;
46219
46246
  let detachOpened = null;
46247
+ let renewOpened = null;
46220
46248
  if (isPrivate) {
46221
46249
  report("syncing");
46222
46250
  const key3 = await host.settlePrivateKey({ signal: life.signal });
@@ -46297,11 +46325,13 @@ ${end.comment}` : end.comment;
46297
46325
  });
46298
46326
  timers = host.openTimersPort({ scope, generation, signal: life.signal });
46299
46327
  check3();
46328
+ const openedKey = timerKey() ?? null;
46300
46329
  data = new MessageChannel();
46301
46330
  command = new MessageChannel();
46302
46331
  control = controlFor(data.port1, command.port1, setForeground, abort);
46303
46332
  check3();
46304
46333
  const detach = (handoff) => {
46334
+ timerKeys2.delete(handoff.dataPort);
46305
46335
  if (data && command && handoff.dataPort === data.port2) {
46306
46336
  const own2 = { data, command, control, timers };
46307
46337
  data = null;
@@ -46342,13 +46372,14 @@ ${end.comment}` : end.comment;
46342
46372
  }
46343
46373
  }
46344
46374
  };
46345
- const attach = () => {
46375
+ const attach = (mode = setupMode === "reconcile-original" ? setupMode : "inspect") => {
46346
46376
  if (!current3() || ended !== null) return null;
46347
46377
  const d = new MessageChannel(), c = new MessageChannel();
46348
46378
  let t = null, ctl = null;
46349
46379
  try {
46350
46380
  t = host.openTimersPort({ scope, generation, signal: life.signal });
46351
46381
  let value2 = null;
46382
+ const key3 = timerKey() ?? null;
46352
46383
  ctl = controlFor(d.port1, c.port1, () => {
46353
46384
  }, () => {
46354
46385
  if (value2) detach(value2);
@@ -46358,13 +46389,14 @@ ${end.comment}` : end.comment;
46358
46389
  scope,
46359
46390
  generation,
46360
46391
  displayName,
46361
- setupMode: setupMode === "reconcile-original" ? setupMode : "inspect",
46392
+ setupMode: mode,
46362
46393
  dataPort: d.port2,
46363
46394
  controlPort: c.port2,
46364
46395
  ...people,
46365
46396
  ...t ? { timerPort: t.port } : {}
46366
46397
  });
46367
46398
  attached.set(d.port2, { data: d, command: c, control: ctl, timers: t });
46399
+ timerKeys2.set(d.port2, key3);
46368
46400
  return value2;
46369
46401
  } catch {
46370
46402
  try {
@@ -46379,8 +46411,18 @@ ${end.comment}` : end.comment;
46379
46411
  return null;
46380
46412
  }
46381
46413
  };
46414
+ const renew = (handoff) => {
46415
+ if (!current3() || !timerKeys2.has(handoff.dataPort)) return null;
46416
+ const key3 = timerKey();
46417
+ if (key3 === void 0 || key3 === timerKeys2.get(handoff.dataPort)) return null;
46418
+ const value2 = attach(handoff.setupMode);
46419
+ if (value2) detach(handoff);
46420
+ return value2;
46421
+ };
46382
46422
  attachOpened = attach;
46383
46423
  detachOpened = detach;
46424
+ renewOpened = renew;
46425
+ timerKeys2.set(data.port2, openedKey);
46384
46426
  options.handoff(Object.freeze({
46385
46427
  schema: "mdbn-app-collection/1",
46386
46428
  scope,
@@ -46403,7 +46445,8 @@ ${end.comment}` : end.comment;
46403
46445
  attach: () => attachOpened ? attachOpened() : null,
46404
46446
  detach: (handoff) => {
46405
46447
  detachOpened?.(handoff);
46406
- }
46448
+ },
46449
+ renewTimers: (handoff) => renewOpened ? renewOpened(handoff) : null
46407
46450
  });
46408
46451
  const unlock = async (secret) => {
46409
46452
  check3();
@@ -50381,12 +50424,12 @@ ${end.comment}` : end.comment;
50381
50424
  // src/application/asset-pins.json
50382
50425
  var asset_pins_default = {
50383
50426
  runtime: {
50384
- sha256: "f63b67f7d68f2bbd653eca8cf10a365dd302b6ef1c2781e77583cb8e123148d5",
50385
- bytes: 3912697,
50386
- maxBytes: 3912697,
50427
+ sha256: "4920cd466a3d246f38c9b7fb3efe13eb48bde6f1b4c0392c3484b2e34c804c97",
50428
+ bytes: 3921681,
50429
+ maxBytes: 3921681,
50387
50430
  source: {
50388
50431
  repository: "mdbase-dev/mdbase-connect",
50389
- commit: "6383ea5d2627ac3334bebfc5f8a10c2587c687a2"
50432
+ commit: "039c7253e12af2710b9ab8be64f4c037766bf1ef"
50390
50433
  }
50391
50434
  },
50392
50435
  sqlite: {