@glyphteck/veyl 0.67.0 → 0.69.0

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.
@@ -44,6 +44,14 @@ var USERNAME_MAX_CHARS = 12;
44
44
  var PASSWORD_MIN_CHARS = 15;
45
45
  var PASSWORD_MAX_CHARS = 64;
46
46
  var PASSWORD_MAX_BYTES = 4 * 1024;
47
+ var ACCOUNT_CONNECTION_SLOW_MS = 4 * MS_PER_SECOND;
48
+ var ACCOUNT_CONNECTION_UNAVAILABLE_MS = 15 * MS_PER_SECOND;
49
+ var ACCOUNT_CONNECTION_RETRY_MIN_MS = MS_PER_SECOND;
50
+ var ACCOUNT_CONNECTION_RETRY_MAX_MS = 30 * MS_PER_SECOND;
51
+ var AUTOLOCK_MIN_MINUTES = 1;
52
+ var AUTOLOCK_MAX_MINUTES = 60;
53
+ var CHAT_MESSAGE_EDIT_WINDOW_MS = 10 * MINUTE_MS;
54
+ var CHAT_SEND_CONNECTION_WAIT_MS = 30 * MS_PER_SECOND;
47
55
  var LOCAL_MEDIA_CACHE_MAX_BYTES = 512 * MIB_BYTES;
48
56
  var LOCAL_PROFILE_CACHE_MAX_ITEMS = 500;
49
57
  var LOCAL_PROFILE_CACHE_MAX_AGE_MS = 30 * DAY_MS;
@@ -115,6 +123,7 @@ var CHAT_MANIFEST_MAX_BYTES = 256 * KIB_BYTES;
115
123
  var CHAT_RECEIPT_MAX_MEMBERS = 32;
116
124
  var CHAT_ORDINARY_DELIVERY_MAX_MEMBERS = 128;
117
125
  var CHAT_MAX_MEMBERS = 256;
126
+ var CHAT_LARGE_GROUP_MENTION_MAX_TARGETS = 16;
118
127
  var CHAT_MAX_TEXT_CHARS = 2048;
119
128
  var CHAT_TITLE_INPUT_MAX_CHARS = 16;
120
129
  var CHAT_MAX_REACTIONS = CHAT_MAX_MEMBERS;
@@ -283,7 +292,7 @@ function normalizePasskeyLoginError(error, options = {}) {
283
292
  return passkeyError(PASSKEY_UNLINKED, "This passkey is no longer linked to an account.", error);
284
293
  }
285
294
  if (error?.code === "functions/failed-precondition") {
286
- return passkeyError(PASSKEY_RP_MISMATCH, "This passkey belongs to a different Glyphteck passkey setup.", error);
295
+ return passkeyError(PASSKEY_RP_MISMATCH, "This passkey belongs to a different Veyl passkey setup.", error);
287
296
  }
288
297
  return error;
289
298
  }
@@ -292,7 +301,7 @@ function normalizePasskeyRegisterError(error, options = {}) {
292
301
  return passkeyError(PASSKEY_PROVIDER_ALREADY_LINKED, "you already have a passkey for this account", error);
293
302
  }
294
303
  if (error?.code === "functions/failed-precondition") {
295
- return passkeyError(PASSKEY_RP_MISMATCH, "This passkey belongs to a different Glyphteck passkey setup.", error);
304
+ return passkeyError(PASSKEY_RP_MISMATCH, "This passkey belongs to a different Veyl passkey setup.", error);
296
305
  }
297
306
  if (options.invalidArgument === true && error?.code === "functions/invalid-argument" && error?.message) {
298
307
  return passkeyError(PASSKEY_REGISTER_INVALID, error.message, error);
@@ -563,6 +572,71 @@ function deselectAccountProfile(value, profileId) {
563
572
  return freezeRegistry({ ...registry, selectedProfileId: null });
564
573
  }
565
574
 
575
+ // ../../core/account/scope.js
576
+ var ACCOUNT_SCOPE_STALE_CODE = "account-scope/stale";
577
+ var PROFILE_ID_RE2 = /^[0-9a-f]{32}$/;
578
+ var ACCOUNT_SCOPE_CAPABILITIES = new WeakSet;
579
+ function requireGeneration(value) {
580
+ const generation = Number(value);
581
+ if (!Number.isSafeInteger(generation) || generation < 0) {
582
+ throw new Error("account scope generation required");
583
+ }
584
+ return generation;
585
+ }
586
+ function requireProfileId(value) {
587
+ const profileId = lowerText(value);
588
+ if (!PROFILE_ID_RE2.test(profileId))
589
+ throw new Error("account scope profile id required");
590
+ return profileId;
591
+ }
592
+ function requireText(value, label) {
593
+ const text = cleanText(value);
594
+ if (!text)
595
+ throw new Error(`${label} required`);
596
+ return text;
597
+ }
598
+ function staleAccountScopeError(scope = null) {
599
+ const error = new Error("account scope is no longer active");
600
+ error.code = ACCOUNT_SCOPE_STALE_CODE;
601
+ error.profileId = scope?.profileId || null;
602
+ error.generation = Number.isSafeInteger(scope?.generation) ? scope.generation : null;
603
+ return error;
604
+ }
605
+ function createAccountScope({
606
+ environment,
607
+ generation,
608
+ isCurrent,
609
+ profileId,
610
+ uid
611
+ } = {}) {
612
+ if (typeof isCurrent !== "function")
613
+ throw new Error("account scope current-state port required");
614
+ const normalizedEnvironment = lowerText(requireText(environment, "account scope environment"));
615
+ const normalizedGeneration = requireGeneration(generation);
616
+ const normalizedProfileId = requireProfileId(profileId);
617
+ const normalizedUid = requireText(uid, "account scope uid");
618
+ const accountOwnerKey = `${normalizedEnvironment}:${normalizedProfileId}:${normalizedUid}`;
619
+ const scope = {
620
+ accountOwnerKey,
621
+ environment: normalizedEnvironment,
622
+ generation: normalizedGeneration,
623
+ key: `${accountOwnerKey}:${normalizedGeneration}`,
624
+ profileId: normalizedProfileId,
625
+ uid: normalizedUid,
626
+ isCurrent: () => isCurrent() === true,
627
+ assertCurrent() {
628
+ if (!scope.isCurrent())
629
+ throw staleAccountScopeError(scope);
630
+ return scope;
631
+ }
632
+ };
633
+ ACCOUNT_SCOPE_CAPABILITIES.add(scope);
634
+ return Object.freeze(scope);
635
+ }
636
+ function isAccountScope(value) {
637
+ return !!value && typeof value === "object" && ACCOUNT_SCOPE_CAPABILITIES.has(value);
638
+ }
639
+
566
640
  // src/accountprofiles.js
567
641
  var ACCOUNT_PROFILE_STALE_CODE = "account-profiles/stale";
568
642
  var ACCOUNT_PROFILE_AUTH_REQUIRED_CODE = "account-profiles/auth-required";
@@ -678,12 +752,16 @@ async function resolveAuthenticatedProfile(owner, generation, reason, details =
678
752
  return profile;
679
753
  }
680
754
  function publicSnapshot(owner) {
755
+ const activeBinding = owner.active?.lease.valid === true && owner.active.scope?.isCurrent() === true ? owner.active.binding : null;
681
756
  return Object.freeze({
682
757
  ready: owner.ready,
683
758
  environment: owner.registry.environment,
684
759
  profiles: accountProfilesByRecency(owner.registry),
685
760
  selectedProfileId: owner.registry.selectedProfileId,
686
- activeProfileId: owner.active?.profile.profileId || null,
761
+ activeBinding,
762
+ activeProfileId: activeBinding ? owner.active.profile.profileId : null,
763
+ activeScope: activeBinding?.scope || null,
764
+ activeScopeKey: activeBinding?.scope.key || null,
687
765
  status: owner.status,
688
766
  generation: owner.generation,
689
767
  error: owner.error
@@ -745,12 +823,23 @@ function ensureRequested(owner, generation, profileId) {
745
823
  throw staleTransitionError();
746
824
  }
747
825
  function transitionContext(owner, lease, reason, details = {}) {
826
+ const profile = lease.profileId ? owner.registry.profiles.find((item) => item.profileId === lease.profileId) || null : null;
827
+ const isCurrent = () => !owner.closing && !owner.closed && lease.valid;
748
828
  return Object.freeze({
829
+ environment: owner.registry.environment,
749
830
  generation: lease.generation,
750
831
  profileId: lease.profileId,
832
+ uid: profile?.uid || null,
751
833
  reason,
752
834
  ...details,
753
- isCurrent: () => !owner.closing && !owner.closed && lease.valid
835
+ scope: profile ? createAccountScope({
836
+ environment: owner.registry.environment,
837
+ generation: lease.generation,
838
+ profileId: lease.profileId,
839
+ uid: profile.uid,
840
+ isCurrent
841
+ }) : null,
842
+ isCurrent
754
843
  });
755
844
  }
756
845
  function report(owner, operation, error, profile = null) {
@@ -773,7 +862,13 @@ async function cleanupBinding(owner, binding, context) {
773
862
  binding.lease.valid = false;
774
863
  await attempt("lock", () => binding.runtime.lock());
775
864
  }
776
- await attempt("clearNotification", () => owner.ports.clearNotification(profile, context));
865
+ if (binding?.scope?.key && binding.scope.accountOwnerKey) {
866
+ await attempt("clearNotification", () => owner.ports.clearNotification(Object.freeze({
867
+ owner: binding.scope,
868
+ profile,
869
+ context
870
+ })));
871
+ }
777
872
  if (binding) {
778
873
  try {
779
874
  await owner.ports.dropPush(profile, binding.runtime, context);
@@ -873,7 +968,13 @@ async function openTarget(owner, profile, generation, reason, options = {}) {
873
968
  return discardCandidate(owner, profile, runtime, lease, "stale", null);
874
969
  }
875
970
  owner.openingLease = null;
876
- owner.active = { profile, runtime, lease };
971
+ owner.active = {
972
+ profile,
973
+ runtime,
974
+ lease,
975
+ scope: context.scope,
976
+ binding: Object.freeze({ runtime, scope: context.scope })
977
+ };
877
978
  publish(owner, "idle", null);
878
979
  return runtime;
879
980
  }
@@ -1185,6 +1286,7 @@ function beginAddProfile(owner) {
1185
1286
  return reservation;
1186
1287
  }
1187
1288
  async function switchExisting(owner, profileId, generation) {
1289
+ const sourceProfileId = owner.active?.profile.profileId || null;
1188
1290
  try {
1189
1291
  ensureRequested(owner, generation, profileId);
1190
1292
  const profile = accountProfileById(owner.registry, profileId);
@@ -1203,7 +1305,21 @@ async function switchExisting(owner, profileId, generation) {
1203
1305
  await transitionTo(owner, profile, generation, "switching");
1204
1306
  return accountProfileById(owner.registry, profileId);
1205
1307
  } catch (error) {
1206
- throw transitionFailure(owner, error, generation, profileId);
1308
+ let failure = error;
1309
+ if (sourceProfileId && sourceProfileId !== profileId && isRequested(owner, generation, profileId)) {
1310
+ const sourceProfile = accountProfileById(owner.registry, sourceProfileId);
1311
+ if (sourceProfile) {
1312
+ try {
1313
+ bindSelection(owner, generation, sourceProfileId);
1314
+ await transitionTo(owner, sourceProfile, generation, "restoring", { force: true });
1315
+ } catch (recoveryError) {
1316
+ recoveryError.cause ||= error;
1317
+ failure = recoveryError;
1318
+ publish(owner, "error", recoveryError);
1319
+ }
1320
+ }
1321
+ }
1322
+ throw transitionFailure(owner, failure, generation, profileId);
1207
1323
  }
1208
1324
  }
1209
1325
  async function updateStoredProfile(owner, profileId, fields) {
@@ -1414,7 +1530,7 @@ function createAccountProfiles(options = {}) {
1414
1530
  refresh: () => requestProfileRefresh(owner),
1415
1531
  signOut: (profileId) => requestProfileSignOut(owner, profileId),
1416
1532
  remove: (profileId) => requestProfileRemoval(owner, profileId),
1417
- getActiveRuntime: () => owner.active?.runtime || null,
1533
+ getActiveBinding: () => owner.snapshot.activeBinding,
1418
1534
  close: () => closeProfiles(owner)
1419
1535
  });
1420
1536
  }
package/dist/auth.js CHANGED
@@ -77,7 +77,7 @@ function normalizePasskeyLoginError(error, options = {}) {
77
77
  return passkeyError(PASSKEY_UNLINKED, "This passkey is no longer linked to an account.", error);
78
78
  }
79
79
  if (error?.code === "functions/failed-precondition") {
80
- return passkeyError(PASSKEY_RP_MISMATCH, "This passkey belongs to a different Glyphteck passkey setup.", error);
80
+ return passkeyError(PASSKEY_RP_MISMATCH, "This passkey belongs to a different Veyl passkey setup.", error);
81
81
  }
82
82
  return error;
83
83
  }
@@ -86,7 +86,7 @@ function normalizePasskeyRegisterError(error, options = {}) {
86
86
  return passkeyError(PASSKEY_PROVIDER_ALREADY_LINKED, "you already have a passkey for this account", error);
87
87
  }
88
88
  if (error?.code === "functions/failed-precondition") {
89
- return passkeyError(PASSKEY_RP_MISMATCH, "This passkey belongs to a different Glyphteck passkey setup.", error);
89
+ return passkeyError(PASSKEY_RP_MISMATCH, "This passkey belongs to a different Veyl passkey setup.", error);
90
90
  }
91
91
  if (options.invalidArgument === true && error?.code === "functions/invalid-argument" && error?.message) {
92
92
  return passkeyError(PASSKEY_REGISTER_INVALID, error.message, error);
@@ -95,7 +95,7 @@ function normalizePasskeyRegisterError(error, options = {}) {
95
95
  }
96
96
 
97
97
  // ../../core/agreement.js
98
- var TERMS_VERSION = "2026-08-22.4";
98
+ var TERMS_VERSION = "2026-09-01.1";
99
99
  var CURRENT_AGREEMENT = Object.freeze({
100
100
  termsVersion: TERMS_VERSION
101
101
  });