@unisim/sdk 0.254.0 → 0.255.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.
- package/README.md +27 -0
- package/dist/DevelopmentRibbon.d.ts +12 -2
- package/dist/DevelopmentRibbon.d.ts.map +1 -1
- package/dist/DevelopmentRibbon.js +54 -63
- package/dist/DevelopmentRibbon.js.map +1 -1
- package/dist/SessionReplaced.d.ts +2 -0
- package/dist/SessionReplaced.d.ts.map +1 -0
- package/dist/SessionReplaced.js +153 -0
- package/dist/SessionReplaced.js.map +1 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +48 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/liveSession.d.ts +41 -0
- package/dist/liveSession.d.ts.map +1 -0
- package/dist/liveSession.js +87 -0
- package/dist/liveSession.js.map +1 -0
- package/dist/liveSessionCore.d.ts +78 -0
- package/dist/liveSessionCore.d.ts.map +1 -0
- package/dist/liveSessionCore.js +165 -0
- package/dist/liveSessionCore.js.map +1 -0
- package/dist/provider.d.ts +19 -0
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +2 -1
- package/dist/provider.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Session } from '@supabase/supabase-js';
|
|
2
|
+
import { type UniversalConfig } from './provider.js';
|
|
3
|
+
import { type LiveSessionStatus, type LiveSessionWatch } from './liveSessionCore.js';
|
|
4
|
+
/** Internal: <SessionReplaced /> publishes its watch's state here. */
|
|
5
|
+
export declare function publishLiveSession(sessionId: string | null, status: LiveSessionStatus, watch: LiveSessionWatch | null): void;
|
|
6
|
+
/** Internal: the watch behind the prompt's buttons. */
|
|
7
|
+
export declare function currentLiveSessionWatch(): LiveSessionWatch | null;
|
|
8
|
+
/**
|
|
9
|
+
* The `session_id` the rule is watching for this provider, or null when the
|
|
10
|
+
* rule does not apply: another product, `liveSession: false`, mock auth, an
|
|
11
|
+
* app without accounts, signed out, a guest, or a token with no `session_id`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function liveSessionIdFor(config: UniversalConfig, session: Session | null, noAccounts?: boolean): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Is this signed-in session the live one for the Assess products? (platform
|
|
16
|
+
* 0351: one session per seat in COSHH, Cyber, Fire, Risk and Workstation.)
|
|
17
|
+
*
|
|
18
|
+
* - `'off'`: no rule here (another product, signed out, a guest, a database
|
|
19
|
+
* without the rule). Read as usual.
|
|
20
|
+
* - `'checking'`: the first answer is not in yet.
|
|
21
|
+
* - `'live'`: read as usual.
|
|
22
|
+
* - `'replaced'`: a newer sign-in took the place. The database refuses this
|
|
23
|
+
* session the five products' rows, and a refused SELECT is EMPTY, not an
|
|
24
|
+
* error: do not treat an empty read as "nothing saved", and do not write.
|
|
25
|
+
* <UniversalProvider> is already showing the prompt.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useLiveSession(): LiveSessionStatus;
|
|
28
|
+
/**
|
|
29
|
+
* A number that goes up each time this session gets its place back
|
|
30
|
+
* (`unisim:live-session` on window). Put it in the dependency array of an
|
|
31
|
+
* effect that reads the product's rows, with `liveSessionReload: false`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useLiveSessionTick(): number;
|
|
34
|
+
/**
|
|
35
|
+
* Ask now whether this session is still the live one, e.g. straight after a
|
|
36
|
+
* save was refused ("new row violates row-level security policy") or an
|
|
37
|
+
* update changed no rows. Shows the prompt if it is not. Does nothing where
|
|
38
|
+
* the rule does not apply.
|
|
39
|
+
*/
|
|
40
|
+
export declare function recheckLiveSession(): Promise<void>;
|
|
41
|
+
//# sourceMappingURL=liveSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveSession.d.ts","sourceRoot":"","sources":["../src/liveSession.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAElE,OAAO,EAEL,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAC9C,MAAM,sBAAsB,CAAA;AA4B7B,sEAAsE;AACtE,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI,QAKrH;AAED,uDAAuD;AACvD,wBAAgB,uBAAuB,IAAI,gBAAgB,GAAG,IAAI,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,EAAE,UAAU,UAAQ,GAAG,MAAM,GAAG,IAAI,CAMpH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,IAAI,iBAAiB,CAOlD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAQ3C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAElD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useState, useSyncExternalStore } from 'react';
|
|
3
|
+
import { useUniversal } from './provider.js';
|
|
4
|
+
import { readSessionIdClaim } from './seatSession.js';
|
|
5
|
+
import { isLiveSessionProduct, LIVE_SESSION_EVENT, } from './liveSessionCore.js';
|
|
6
|
+
const OFF = { sessionId: null, status: 'off' };
|
|
7
|
+
let snapshot = OFF;
|
|
8
|
+
let current = null;
|
|
9
|
+
const listeners = new Set();
|
|
10
|
+
function subscribe(fn) {
|
|
11
|
+
listeners.add(fn);
|
|
12
|
+
return () => { listeners.delete(fn); };
|
|
13
|
+
}
|
|
14
|
+
/** Internal: <SessionReplaced /> publishes its watch's state here. */
|
|
15
|
+
export function publishLiveSession(sessionId, status, watch) {
|
|
16
|
+
current = watch;
|
|
17
|
+
if (snapshot.sessionId === sessionId && snapshot.status === status)
|
|
18
|
+
return;
|
|
19
|
+
snapshot = sessionId ? { sessionId, status } : OFF;
|
|
20
|
+
listeners.forEach((fn) => fn());
|
|
21
|
+
}
|
|
22
|
+
/** Internal: the watch behind the prompt's buttons. */
|
|
23
|
+
export function currentLiveSessionWatch() {
|
|
24
|
+
return current;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The `session_id` the rule is watching for this provider, or null when the
|
|
28
|
+
* rule does not apply: another product, `liveSession: false`, mock auth, an
|
|
29
|
+
* app without accounts, signed out, a guest, or a token with no `session_id`.
|
|
30
|
+
*/
|
|
31
|
+
export function liveSessionIdFor(config, session, noAccounts = false) {
|
|
32
|
+
if (!isLiveSessionProduct(config.product) || config.liveSession === false)
|
|
33
|
+
return null;
|
|
34
|
+
if (noAccounts || config.noAccounts || (config.mockAuth && !config.cookieDomain))
|
|
35
|
+
return null;
|
|
36
|
+
if (!session?.access_token)
|
|
37
|
+
return null;
|
|
38
|
+
if (session.user?.is_anonymous === true)
|
|
39
|
+
return null;
|
|
40
|
+
return readSessionIdClaim(session.access_token);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Is this signed-in session the live one for the Assess products? (platform
|
|
44
|
+
* 0351: one session per seat in COSHH, Cyber, Fire, Risk and Workstation.)
|
|
45
|
+
*
|
|
46
|
+
* - `'off'`: no rule here (another product, signed out, a guest, a database
|
|
47
|
+
* without the rule). Read as usual.
|
|
48
|
+
* - `'checking'`: the first answer is not in yet.
|
|
49
|
+
* - `'live'`: read as usual.
|
|
50
|
+
* - `'replaced'`: a newer sign-in took the place. The database refuses this
|
|
51
|
+
* session the five products' rows, and a refused SELECT is EMPTY, not an
|
|
52
|
+
* error: do not treat an empty read as "nothing saved", and do not write.
|
|
53
|
+
* <UniversalProvider> is already showing the prompt.
|
|
54
|
+
*/
|
|
55
|
+
export function useLiveSession() {
|
|
56
|
+
const { config, session, noAccounts } = useUniversal();
|
|
57
|
+
const snap = useSyncExternalStore(subscribe, () => snapshot, () => OFF);
|
|
58
|
+
const sessionId = liveSessionIdFor(config, session, noAccounts);
|
|
59
|
+
if (!sessionId)
|
|
60
|
+
return 'off';
|
|
61
|
+
// The watch starts in an effect, a moment after the session appears.
|
|
62
|
+
return snap.sessionId === sessionId ? snap.status : 'checking';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A number that goes up each time this session gets its place back
|
|
66
|
+
* (`unisim:live-session` on window). Put it in the dependency array of an
|
|
67
|
+
* effect that reads the product's rows, with `liveSessionReload: false`.
|
|
68
|
+
*/
|
|
69
|
+
export function useLiveSessionTick() {
|
|
70
|
+
const [tick, setTick] = useState(0);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const bump = () => setTick((n) => n + 1);
|
|
73
|
+
window.addEventListener(LIVE_SESSION_EVENT, bump);
|
|
74
|
+
return () => window.removeEventListener(LIVE_SESSION_EVENT, bump);
|
|
75
|
+
}, []);
|
|
76
|
+
return tick;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Ask now whether this session is still the live one, e.g. straight after a
|
|
80
|
+
* save was refused ("new row violates row-level security policy") or an
|
|
81
|
+
* update changed no rows. Shows the prompt if it is not. Does nothing where
|
|
82
|
+
* the rule does not apply.
|
|
83
|
+
*/
|
|
84
|
+
export function recheckLiveSession() {
|
|
85
|
+
return current ? current.check(true) : Promise.resolve();
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=liveSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveSession.js","sourceRoot":"","sources":["../src/liveSession.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAwB,MAAM,eAAe,CAAA;AAClE,OAAO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CAAC,EAAE,EAAE,CAAC,CAAA;IACN,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;AAC1D,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ProductCode } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The products under the rule. `workplace_assess` is Workstation Assess and
|
|
4
|
+
* also Workplace Assess on the web (comply-hub), which reads the same tables.
|
|
5
|
+
* Not Ergo (its own API does this), not the Hub, not the Universal Apps.
|
|
6
|
+
*/
|
|
7
|
+
export declare const LIVE_SESSION_PRODUCTS: readonly ProductCode[];
|
|
8
|
+
export declare function isLiveSessionProduct(product: ProductCode): boolean;
|
|
9
|
+
/** What `assess_session_claim()` answers. */
|
|
10
|
+
export type LiveSessionClaim = 'none' | 'live' | 'claimed' | 'replaced';
|
|
11
|
+
/**
|
|
12
|
+
* - `'off'`: the rule does not apply here (another product, signed out, a
|
|
13
|
+
* guest, mock auth, a database without 0351),
|
|
14
|
+
* - `'checking'`: signed in, the first answer is not in yet,
|
|
15
|
+
* - `'live'`: this session is the live one (or the question could not be
|
|
16
|
+
* asked: the database still decides),
|
|
17
|
+
* - `'replaced'`: a newer sign-in took this account's place; the five
|
|
18
|
+
* products' rows are refused until "Sign in here".
|
|
19
|
+
*/
|
|
20
|
+
export type LiveSessionStatus = 'off' | 'checking' | 'live' | 'replaced';
|
|
21
|
+
/**
|
|
22
|
+
* Fired on `window` when this session has just become the live one after a
|
|
23
|
+
* spell of being refused ("Sign in here", here or in another tab): rows read
|
|
24
|
+
* before it may be empty, so read them again.
|
|
25
|
+
*/
|
|
26
|
+
export declare const LIVE_SESSION_EVENT = "unisim:live-session";
|
|
27
|
+
/** How often an open, visible tab asks whether it is still the live one. */
|
|
28
|
+
export declare const LIVE_SESSION_CHECK_MS = 60000;
|
|
29
|
+
type RpcResult = {
|
|
30
|
+
data: unknown;
|
|
31
|
+
error: {
|
|
32
|
+
code?: string;
|
|
33
|
+
message?: string;
|
|
34
|
+
} | null;
|
|
35
|
+
status?: number;
|
|
36
|
+
};
|
|
37
|
+
/** The one method of the Supabase client this needs. */
|
|
38
|
+
export interface LiveSessionClient {
|
|
39
|
+
rpc: (fn: string, args?: Record<string, unknown>) => PromiseLike<RpcResult>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Claim the live place for this session. `takeOver` is the prompt's "Sign in
|
|
43
|
+
* here". Answers what the database said; `'unsupported'` when the database has
|
|
44
|
+
* no such function (nothing to enforce yet); null when it could not be asked.
|
|
45
|
+
* Never throws.
|
|
46
|
+
*/
|
|
47
|
+
export declare function claimLiveSession(supabase: LiveSessionClient, takeOver?: boolean): Promise<LiveSessionClaim | 'unsupported' | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Is this session the live one? The database's own answer
|
|
50
|
+
* (`assess_session_is_live()`, the function the RLS policy runs), read-only
|
|
51
|
+
* and cheap. Null when it could not be asked. Never throws.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isLiveSession(supabase: LiveSessionClient): Promise<boolean | null>;
|
|
54
|
+
export interface LiveSessionWatch {
|
|
55
|
+
/** The first claim, when the session appears. */
|
|
56
|
+
start(): Promise<void>;
|
|
57
|
+
/** Ask again (focus, the minute tick, another tab's news). `force` skips the burst guard. */
|
|
58
|
+
check(force?: boolean): Promise<void>;
|
|
59
|
+
/** "Sign in here". True when this session is now the live one. */
|
|
60
|
+
takeOver(): Promise<boolean>;
|
|
61
|
+
stop(): void;
|
|
62
|
+
readonly status: LiveSessionStatus;
|
|
63
|
+
}
|
|
64
|
+
export interface LiveSessionWatchOptions {
|
|
65
|
+
supabase: LiveSessionClient;
|
|
66
|
+
onStatus: (status: LiveSessionStatus) => void;
|
|
67
|
+
/**
|
|
68
|
+
* This session is live again after being refused, so what it read meanwhile
|
|
69
|
+
* may be empty. `byThisCall` is true when this very call moved the place
|
|
70
|
+
* (worth telling the other tabs), false when it only found out.
|
|
71
|
+
*/
|
|
72
|
+
onMoved: (byThisCall: boolean) => void;
|
|
73
|
+
now?: () => number;
|
|
74
|
+
}
|
|
75
|
+
/** One watch per signed-in session: claims, re-checks, takes over. */
|
|
76
|
+
export declare function createLiveSessionWatch(o: LiveSessionWatchOptions): LiveSessionWatch;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=liveSessionCore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveSessionCore.d.ts","sourceRoot":"","sources":["../src/liveSessionCore.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,WAAW,EAEvD,CAAA;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAElE;AAED,6CAA6C;AAC7C,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAA;AAEvE;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,CAAA;AAExE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,wBAAwB,CAAA;AAEvD,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,QAAS,CAAA;AAK3C,KAAK,SAAS,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AACtG,wDAAwD;AACxD,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,WAAW,CAAC,SAAS,CAAC,CAAA;CAC5E;AAQD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,UAAQ,GACf,OAAO,CAAC,gBAAgB,GAAG,aAAa,GAAG,IAAI,CAAC,CASlD;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAOxF;AAED,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,6FAA6F;IAC7F,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,kEAAkE;IAClE,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAC5B,IAAI,IAAI,IAAI,CAAA;IACZ,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;CACnC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAA;IAC7C;;;;OAIG;IACH,OAAO,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,uBAAuB,GAAG,gBAAgB,CAkEnF"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
// One live session per seat, for the five Assess products that keep their data
|
|
3
|
+
// in Supabase behind RLS: COSHH, Cyber, Fire, Risk and Workstation Assess
|
|
4
|
+
// (platform migration 0351; `Docs_UNI_SIM/assess-ground-rules.md` rule 11,
|
|
5
|
+
// James, 2026-11-26: "one session per seat").
|
|
6
|
+
//
|
|
7
|
+
// The rule is the database's. `assess_session_claim()` makes the newest
|
|
8
|
+
// sign-in the live one, and a restrictive policy refuses the five products'
|
|
9
|
+
// rows to any other session of the same person. Ergo has had the same rule in
|
|
10
|
+
// its own API since 2026-10-12. This file is the part that TELLS the browser
|
|
11
|
+
// which lost its place: a refused SELECT comes back empty, not as an error, so
|
|
12
|
+
// without it the person would only see their lists go blank.
|
|
13
|
+
//
|
|
14
|
+
// Nothing React in this file, so a plain Node test can drive it. The provider
|
|
15
|
+
// mounts <SessionReplaced /> (SessionReplaced.tsx), which runs one watch per
|
|
16
|
+
// signed-in session and shows the prompt; `liveSession.ts` has the hooks.
|
|
17
|
+
//
|
|
18
|
+
// Not the control: a fork that never calls any of this is still refused by RLS
|
|
19
|
+
// once anybody has claimed for that account.
|
|
20
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
21
|
+
/**
|
|
22
|
+
* The products under the rule. `workplace_assess` is Workstation Assess and
|
|
23
|
+
* also Workplace Assess on the web (comply-hub), which reads the same tables.
|
|
24
|
+
* Not Ergo (its own API does this), not the Hub, not the Universal Apps.
|
|
25
|
+
*/
|
|
26
|
+
export const LIVE_SESSION_PRODUCTS = [
|
|
27
|
+
'coshh_assess', 'cyber_assess', 'fire_assess', 'risk_assess', 'workplace_assess',
|
|
28
|
+
];
|
|
29
|
+
export function isLiveSessionProduct(product) {
|
|
30
|
+
return LIVE_SESSION_PRODUCTS.includes(product);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fired on `window` when this session has just become the live one after a
|
|
34
|
+
* spell of being refused ("Sign in here", here or in another tab): rows read
|
|
35
|
+
* before it may be empty, so read them again.
|
|
36
|
+
*/
|
|
37
|
+
export const LIVE_SESSION_EVENT = 'unisim:live-session';
|
|
38
|
+
/** How often an open, visible tab asks whether it is still the live one. */
|
|
39
|
+
export const LIVE_SESSION_CHECK_MS = 60_000;
|
|
40
|
+
/** Focus and visibility events arrive in bursts: one question per this long. */
|
|
41
|
+
const MIN_GAP_MS = 5_000;
|
|
42
|
+
/** PostgREST's "no such function": the database has not got migration 0351. */
|
|
43
|
+
function missingFunction(res) {
|
|
44
|
+
const code = res.error?.code;
|
|
45
|
+
return code === 'PGRST202' || code === '42883' || res.status === 404;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Claim the live place for this session. `takeOver` is the prompt's "Sign in
|
|
49
|
+
* here". Answers what the database said; `'unsupported'` when the database has
|
|
50
|
+
* no such function (nothing to enforce yet); null when it could not be asked.
|
|
51
|
+
* Never throws.
|
|
52
|
+
*/
|
|
53
|
+
export async function claimLiveSession(supabase, takeOver = false) {
|
|
54
|
+
try {
|
|
55
|
+
const res = await supabase.rpc('assess_session_claim', { p_take_over: takeOver });
|
|
56
|
+
if (res.error)
|
|
57
|
+
return missingFunction(res) ? 'unsupported' : null;
|
|
58
|
+
const v = res.data;
|
|
59
|
+
return v === 'none' || v === 'live' || v === 'claimed' || v === 'replaced' ? v : null;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Is this session the live one? The database's own answer
|
|
67
|
+
* (`assess_session_is_live()`, the function the RLS policy runs), read-only
|
|
68
|
+
* and cheap. Null when it could not be asked. Never throws.
|
|
69
|
+
*/
|
|
70
|
+
export async function isLiveSession(supabase) {
|
|
71
|
+
try {
|
|
72
|
+
const res = await supabase.rpc('assess_session_is_live');
|
|
73
|
+
return !res.error && typeof res.data === 'boolean' ? res.data : null;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** One watch per signed-in session: claims, re-checks, takes over. */
|
|
80
|
+
export function createLiveSessionWatch(o) {
|
|
81
|
+
const now = o.now ?? (() => Date.now());
|
|
82
|
+
let status = 'checking';
|
|
83
|
+
let stopped = false;
|
|
84
|
+
/** The database has no rule (pre-0351): ask nothing more this page load. */
|
|
85
|
+
let unsupported = false;
|
|
86
|
+
/** A claim has been answered, so the cheap question is enough from here on. */
|
|
87
|
+
let answered = false;
|
|
88
|
+
let lastAsk = 0;
|
|
89
|
+
// One question at a time: a focus burst must not race the first claim.
|
|
90
|
+
let queue = Promise.resolve();
|
|
91
|
+
const enqueue = (fn) => {
|
|
92
|
+
const next = queue.then(fn, fn);
|
|
93
|
+
queue = next.catch(() => undefined);
|
|
94
|
+
return next;
|
|
95
|
+
};
|
|
96
|
+
const set = (next) => {
|
|
97
|
+
if (stopped || status === next)
|
|
98
|
+
return;
|
|
99
|
+
status = next;
|
|
100
|
+
o.onStatus(next);
|
|
101
|
+
};
|
|
102
|
+
async function claim(takeOver) {
|
|
103
|
+
const was = status;
|
|
104
|
+
const answer = await claimLiveSession(o.supabase, takeOver);
|
|
105
|
+
if (stopped)
|
|
106
|
+
return false;
|
|
107
|
+
if (answer === 'unsupported') {
|
|
108
|
+
unsupported = true;
|
|
109
|
+
set('off');
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
if (answer === null) {
|
|
113
|
+
// Could not ask. Say nothing rather than guess: the database still
|
|
114
|
+
// refuses what it must, and the next check asks again.
|
|
115
|
+
if (status === 'checking')
|
|
116
|
+
set('live');
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
answered = true;
|
|
120
|
+
if (answer === 'none') {
|
|
121
|
+
set('off');
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
if (answer === 'replaced') {
|
|
125
|
+
set('replaced');
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
set('live');
|
|
129
|
+
if (answer === 'claimed' || was === 'replaced')
|
|
130
|
+
o.onMoved(answer === 'claimed');
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
get status() { return status; },
|
|
135
|
+
start: () => enqueue(async () => { lastAsk = now(); await claim(false); }),
|
|
136
|
+
check: (force = false) => enqueue(async () => {
|
|
137
|
+
if (stopped || unsupported || status === 'off')
|
|
138
|
+
return;
|
|
139
|
+
const t = now();
|
|
140
|
+
if (!force && t - lastAsk < MIN_GAP_MS)
|
|
141
|
+
return;
|
|
142
|
+
lastAsk = t;
|
|
143
|
+
if (!answered) {
|
|
144
|
+
await claim(false);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const live = await isLiveSession(o.supabase);
|
|
148
|
+
if (stopped || live === null)
|
|
149
|
+
return;
|
|
150
|
+
if (live) {
|
|
151
|
+
// Refused a moment ago and let through now: "Sign in here" in another
|
|
152
|
+
// tab of this browser, or the row was cleared. The claim settles which.
|
|
153
|
+
if (status === 'replaced')
|
|
154
|
+
await claim(false);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
// Live until now, and no longer: a newer sign-in, or the other browser's
|
|
158
|
+
// "Sign in here". A claim could not win it back by itself.
|
|
159
|
+
set('replaced');
|
|
160
|
+
}),
|
|
161
|
+
takeOver: () => enqueue(() => claim(true)),
|
|
162
|
+
stop: () => { stopped = true; },
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=liveSessionCore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveSessionCore.js","sourceRoot":"","sources":["../src/liveSessionCore.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,+EAA+E;AAC/E,0EAA0E;AAC1E,2EAA2E;AAC3E,8CAA8C;AAC9C,EAAE;AACF,wEAAwE;AACxE,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,6DAA6D;AAC7D,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,+EAA+E;AAC/E,6CAA6C;AAC7C,iFAAiF;AAIjF;;;;GAIG;AACH,M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C,CAAC,CAAC;QACzE,KAAK,EAAE,CAAC,KAAK,GAAG,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;YAC3C,IAAI,OAAO,IAAI,WAAW,IAAI,MAAM,KAAK,KAAK;gBAAE,OAAM;YACtD,MAAM,CAAC,GAAG,GAAG,EAAE,CAAA;YACf,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,OAAO,GAAG,UAAU;gBAAE,OAAM;YAC9C,OAAO,GAAG,CAAC,CAAA;YACX,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAAC,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC;gBAAC,OAAM;YAAC,CAAC;YAC7C,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;YAC5C,IAAI,OAAO,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAM;YACpC,IAAI,IAAI,EAAE,CAAC;gBACT,sEAAsE;gBACtE,wEAAwE;gBACxE,IAAI,MAAM,KAAK,UAAU;oBAAE,MAAM,KAAK,CAAC,KAAK,CAAC,CAAA;gBAC7C,OAAM;YACR,CAAC;YACD,yEAAyE;YACzE,2DAA2D;YAC3D,GAAG,CAAC,UAAU,CAAC,CAAA;QACjB,CAAC,CAAC;QACF,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,GAAG,IAAI,CAAA,CAAC,CAAC;KAC/B,CAAA;AACH,CAAC"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -144,6 +144,25 @@ export interface UniversalConfig {
|
|
|
144
144
|
* without the switch costs one small read per page load and writes nothing.
|
|
145
145
|
*/
|
|
146
146
|
ssoSessionCheck?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* One live session per seat (<SessionReplaced />, platform migration 0351).
|
|
149
|
+
* ON unless false, and only in COSHH, Cyber, Fire, Risk and Workstation /
|
|
150
|
+
* Workplace Assess (`LIVE_SESSION_PRODUCTS`): every other product ignores
|
|
151
|
+
* it. A signed-in session claims the live place when the app opens (the
|
|
152
|
+
* newest sign-in wins); the browser it replaced is refused those products'
|
|
153
|
+
* rows by the database and shown "This account was opened on another
|
|
154
|
+
* device", with Sign in here / Sign out. Costs one call when the session
|
|
155
|
+
* appears and one small read on focus and each minute. Does nothing against
|
|
156
|
+
* a database without 0351.
|
|
157
|
+
*/
|
|
158
|
+
liveSession?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Reload the page when this session gets its place back ("Sign in here").
|
|
161
|
+
* ON unless false: what it read while it was refused came back empty. Set
|
|
162
|
+
* false in an app that re-reads on `LIVE_SESSION_EVENT` /
|
|
163
|
+
* `useLiveSessionTick()` instead.
|
|
164
|
+
*/
|
|
165
|
+
liveSessionReload?: boolean;
|
|
147
166
|
}
|
|
148
167
|
interface UniversalContextValue {
|
|
149
168
|
config: UniversalConfig;
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAIvF,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,EAA6D,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpG,OAAO,EAAyB,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AACvF,OAAO,EAAyC,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAK3F,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx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,EAAE,QAAQ,CAAA;IACxB,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAA;IAC5B,iBAAiB,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC3C,cAAc,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,KAAK,IAAI,CAAA;CAChD,CAGA;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI;IACtC,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAA;IACrC,WAAW,EAAE,SAAS,CAAA;IACtB,cAAc,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACzC,mFAAmF;IACnF,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC;;;;;OAKG;IACH,KAAK,EAAE,OAAO,CAAA;CACf,CAWA"}
|
package/dist/provider.js
CHANGED
|
@@ -16,6 +16,7 @@ import { GLOBAL_COLOR_SCHEME_EVENT, GLOBAL_COLOR_SCHEME_KEY, getDefaultColorSche
|
|
|
16
16
|
import { keepGuestColorScheme } from './themeStore.js';
|
|
17
17
|
import { TwoStepPrompt } from './TwoStepPrompt.js';
|
|
18
18
|
import { SsoSessionCheck } from './ssoSession.js';
|
|
19
|
+
import { SessionReplaced } from './SessionReplaced.js';
|
|
19
20
|
import { noteTuneChange } from './tuneSyncCore.js';
|
|
20
21
|
import { TuneSync } from './TuneSync.js';
|
|
21
22
|
import { SyncedSettingsSync } from './SyncedSettingsSync.js';
|
|
@@ -1253,7 +1254,7 @@ export function UniversalProvider({ config, children }) {
|
|
|
1253
1254
|
globalColorScheme, setGlobalColorScheme, globalCallMe, setGlobalCallMe,
|
|
1254
1255
|
splitPreferences, noAccounts,
|
|
1255
1256
|
]);
|
|
1256
|
-
return (_jsxs(UniversalContext.Provider, { value: value, children: [!mockActive && _jsx(TuneSync, {}), !mockActive && _jsx(SyncedSettingsSync, {}), children, config.twoStepPrompt !== false && !mockActive && !noAccounts && _jsx(TwoStepPrompt, {}), config.ssoSessionCheck !== false && !mockActive && !noAccounts && _jsx(SsoSessionCheck, {})] }));
|
|
1257
|
+
return (_jsxs(UniversalContext.Provider, { value: value, children: [!mockActive && _jsx(TuneSync, {}), !mockActive && _jsx(SyncedSettingsSync, {}), children, config.twoStepPrompt !== false && !mockActive && !noAccounts && _jsx(TwoStepPrompt, {}), config.ssoSessionCheck !== false && !mockActive && !noAccounts && _jsx(SsoSessionCheck, {}), config.liveSession !== false && !mockActive && !noAccounts && _jsx(SessionReplaced, {})] }));
|
|
1257
1258
|
}
|
|
1258
1259
|
export function useUniversal() {
|
|
1259
1260
|
const ctx = useContext(UniversalContext);
|