@simplelayer/graniteer-core 0.3.6 → 0.3.8
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.
|
@@ -22,6 +22,43 @@ const corsHeaders = {
|
|
|
22
22
|
'Access-Control-Allow-Origin': '*',
|
|
23
23
|
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type, x-lovable-signature, x-lovable-timestamp, x-supabase-client-platform, x-supabase-client-platform-version, x-supabase-client-runtime, x-supabase-client-runtime-version',
|
|
24
24
|
};
|
|
25
|
+
// `data.url` for magiclink (and recovery) arrives as Supabase's own
|
|
26
|
+
// `{SUPABASE_URL}/auth/v1/verify?token=<hash>&type=<type>&redirect_to=<dest>`
|
|
27
|
+
// action link. That link performs the OTP verification on a plain GET, so an
|
|
28
|
+
// email-scanner prefetch (M365 Safe Links, etc.) silently burns the token
|
|
29
|
+
// before the real recipient ever clicks -- confirmed live 2026-09-23 against
|
|
30
|
+
// kyle+qatest@simplelayer.io (M365-hosted inbox): the link arrived, was
|
|
31
|
+
// pre-fetched, and the user's own click then hit an already-consumed token
|
|
32
|
+
// (otp_expired).
|
|
33
|
+
//
|
|
34
|
+
// Fix (magiclink only, for now): rewrite the emailed link to point at our own
|
|
35
|
+
// /portal/confirm page instead, carrying the same token/type/redirect_to as
|
|
36
|
+
// query params. That page does nothing on load -- it renders a "Continue to
|
|
37
|
+
// sign in" button and only calls supabase.auth.verifyOtp({token_hash, type})
|
|
38
|
+
// on an actual click, so a scanner's GET can no longer consume the token.
|
|
39
|
+
//
|
|
40
|
+
// Fails open: if the URL doesn't parse or is missing an expected param
|
|
41
|
+
// (Supabase changes the link shape, a non-magiclink call site reuses this),
|
|
42
|
+
// return the original link unchanged rather than break the login/reset flow.
|
|
43
|
+
function toClickToContinueUrl(rawUrl) {
|
|
44
|
+
try {
|
|
45
|
+
const u = new URL(rawUrl);
|
|
46
|
+
const token = u.searchParams.get('token');
|
|
47
|
+
const type = u.searchParams.get('type');
|
|
48
|
+
const redirectTo = u.searchParams.get('redirect_to');
|
|
49
|
+
if (!token || !type || !redirectTo)
|
|
50
|
+
return rawUrl;
|
|
51
|
+
const dest = new URL(redirectTo);
|
|
52
|
+
const confirm = new URL('/portal/confirm', dest.origin);
|
|
53
|
+
confirm.searchParams.set('token_hash', token);
|
|
54
|
+
confirm.searchParams.set('type', type);
|
|
55
|
+
confirm.searchParams.set('redirect_to', redirectTo);
|
|
56
|
+
return confirm.toString();
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return rawUrl;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
25
62
|
// Template mapping for preview mode
|
|
26
63
|
const EMAIL_TEMPLATES = {
|
|
27
64
|
signup: SignupEmail,
|
|
@@ -164,7 +201,10 @@ export function createAuthEmailHook(config) {
|
|
|
164
201
|
subject: 'Your login link',
|
|
165
202
|
render: (data) => React.createElement(MagicLinkEmail, {
|
|
166
203
|
siteName: SITE_NAME,
|
|
167
|
-
|
|
204
|
+
// Click-to-continue (2026-09-23): route through our own confirm
|
|
205
|
+
// page instead of Supabase's direct, scanner-vulnerable /verify
|
|
206
|
+
// GET link. See toClickToContinueUrl() above.
|
|
207
|
+
confirmationUrl: toClickToContinueUrl(data.url),
|
|
168
208
|
colors: BRAND_COLORS,
|
|
169
209
|
footerLine: FOOTER_LINE,
|
|
170
210
|
}),
|
|
@@ -17,6 +17,24 @@ const corsHeaders = {
|
|
|
17
17
|
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
|
|
18
18
|
};
|
|
19
19
|
const TIMEOUT_MS = 20_000;
|
|
20
|
+
// D32 item #3 (2026-09-23): a two-pin grant's UniFi collision-retry logic
|
|
21
|
+
// can, in the corrected worst case, take up to ~65-70s inside ftw-middleware
|
|
22
|
+
// alone (one wall-clock-budget-gated retry attempt can itself make up to 3
|
|
23
|
+
// UniFi calls before the budget check ever gets a chance to abort it -- see
|
|
24
|
+
// event_access.py's _TWO_PIN_PROVISION_BUDGET_SEC comment for the full
|
|
25
|
+
// derivation). The original 20s TIMEOUT_MS fired long before the middleware
|
|
26
|
+
// could ever return a real (success or definitive-failure) response for a
|
|
27
|
+
// grant, forcing staff to see a spurious 502 middleware_unreachable while
|
|
28
|
+
// the middleware kept working in the background -- wasting a minted PIN and
|
|
29
|
+
// requiring a manual Revoke+Grant. GRANT_TIMEOUT_MS gives grant-only
|
|
30
|
+
// headroom (95s) that sits comfortably above ftw-middleware's own
|
|
31
|
+
// _GRANT_HANDLER_TIMEOUT_SEC (85s, itself raised in the same pass to clear
|
|
32
|
+
// the corrected worst case) while staying under the Cloudflare Tunnel
|
|
33
|
+
// edge's own ~100s proxied-HTTP limit for ftw.granitecity.io -- past that,
|
|
34
|
+
// Cloudflare cuts the connection with a 524 regardless of what this signal
|
|
35
|
+
// says, so there is no point setting this any higher. door/revoke keep the
|
|
36
|
+
// original 20s: neither has a retry loop and both should fail fast.
|
|
37
|
+
const GRANT_TIMEOUT_MS = 95_000;
|
|
20
38
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
21
39
|
const JWKS_URL_SUFFIX = '/auth/v1/.well-known/jwks.json';
|
|
22
40
|
let jwksCache = null;
|
|
@@ -226,7 +244,7 @@ export function createEventAccessAdminHandler(config) {
|
|
|
226
244
|
'X-Event-Access-Timestamp': ts,
|
|
227
245
|
},
|
|
228
246
|
body: rawBody,
|
|
229
|
-
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
247
|
+
signal: AbortSignal.timeout(action === 'grant' ? GRANT_TIMEOUT_MS : TIMEOUT_MS),
|
|
230
248
|
});
|
|
231
249
|
}
|
|
232
250
|
catch (e) {
|