@mistriwork/kit 1.0.0-rc.33 → 1.0.0-rc.35

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.
@@ -21,6 +21,11 @@ export declare function captureTenantLease(owner?: SessionIdentitySnapshot): Ten
21
21
  export declare function tenantLeaseActive(owner?: SessionIdentitySnapshot): boolean;
22
22
  export declare function suspendTenantLease(owner?: SessionIdentitySnapshot): void;
23
23
  export declare function acceptTenantRenewal(owner: SessionIdentitySnapshot, expectedRevision: number, reply: TenantContextReply): void;
24
+ /** A fresh context for the same tenant, after the server forgot `lost`: a restarted host holds no context this page
25
+ * entered, so it opens a new one (revision 1, a new tab and context) and the page goes on under it. The selection —
26
+ * the snapshot, its storage namespace, every operation it owns — stands, because the same account chose the same
27
+ * tenant; only the lease the requests carry is replaced. Anything else is refused, never adopted. */
28
+ export declare function adoptTenantReentry(owner: SessionIdentitySnapshot, lost: TenantContextReply, reply: TenantContextReply): void;
24
29
  /** Lock once, including callbacks that captured an otherwise identical account. */
25
30
  export declare function lockSessionIdentity(): SessionIdentitySnapshot;
26
31
  /** Retire every captured operation/storage owner before requesting a selection.
@@ -113,6 +113,32 @@ export function acceptTenantRenewal(owner, expectedRevision, reply) {
113
113
  leases.set(owner, { reply: Object.freeze({ ...reply }), suspended: reply.expiresAt <= now, observedAt: now });
114
114
  leaseChanged();
115
115
  }
116
+ /** A fresh context for the same tenant, after the server forgot `lost`: a restarted host holds no context this page
117
+ * entered, so it opens a new one (revision 1, a new tab and context) and the page goes on under it. The selection —
118
+ * the snapshot, its storage namespace, every operation it owns — stands, because the same account chose the same
119
+ * tenant; only the lease the requests carry is replaced. Anything else is refused, never adopted. */
120
+ export function adoptTenantReentry(owner, lost, reply) {
121
+ const state = owner === identity ? leases.get(owner) : undefined;
122
+ const now = Date.now();
123
+ if (!state ||
124
+ owner !== identity ||
125
+ !owner.tenant ||
126
+ state.reply.revision !== lost.revision ||
127
+ !ownerFields.every((key) => lost[key] === state.reply[key]) ||
128
+ !validLease(reply) ||
129
+ reply.revision !== 1 ||
130
+ reply.appId !== owner.tenant.appId ||
131
+ reply.accountId !== owner.tenant.accountId ||
132
+ reply.tenantId !== owner.tenant.tenantId ||
133
+ reply.realm !== owner.tenant.realm ||
134
+ (reply.tabId === lost.tabId && reply.context === lost.context) ||
135
+ !Number.isFinite(now) ||
136
+ now < state.observedAt ||
137
+ reply.expiresAt <= now)
138
+ throw new SessionIdentityError(say('theTenantSelectionCould'), 'invalid-identity');
139
+ leases.set(owner, { reply: Object.freeze({ ...reply }), suspended: false, observedAt: now });
140
+ leaseChanged();
141
+ }
116
142
  function transition(mode, accountId, appId) {
117
143
  if (identity.mode !== mode || identity.accountId !== accountId || identity.appId !== appId) {
118
144
  identity = Object.freeze({ mode, accountId, appId, epoch: identity.epoch + 1 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/kit",
3
- "version": "1.0.0-rc.33",
3
+ "version": "1.0.0-rc.35",
4
4
  "description": "The shared React client both shells are drawn with: the walk and the address, Grid, Value, the record page, lists, filters and charts.",
5
5
  "homepage": "https://mistriwork.dev",
6
6
  "bugs": {
@@ -83,8 +83,8 @@
83
83
  "./package.json": "./package.json"
84
84
  },
85
85
  "dependencies": {
86
- "@mistriwork/engine": "1.0.0-rc.33",
87
- "@mistriwork/ui": "1.0.0-rc.33",
86
+ "@mistriwork/engine": "1.0.0-rc.35",
87
+ "@mistriwork/ui": "1.0.0-rc.35",
88
88
  "intl-messageformat": "12.1.2",
89
89
  "qrcode-generator": "^2.0.4"
90
90
  },