@simplelayer/graniteer-core 0.3.12 → 0.3.14
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/dist/bookingEffects.d.ts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/entitlements.js +6 -1
- package/dist/functions/admin-charge-guest-print.d.ts +3 -1
- package/dist/functions/admin-charge-guest-print.js +8 -1
- package/dist/functions/admin-create-booking.d.ts +5 -3
- package/dist/functions/admin-create-commons-event.d.ts +3 -1
- package/dist/functions/admin-create-commons-event.js +8 -1
- package/dist/functions/admin-door-write.d.ts +3 -1
- package/dist/functions/admin-door-write.js +8 -1
- package/dist/functions/admin-issue-day-pass.d.ts +1 -0
- package/dist/functions/admin-issue-day-pass.js +8 -1
- package/dist/functions/admin-request-trial.js +21 -0
- package/dist/functions/auth-email-hook.js +1 -1
- package/dist/functions/create-booking.d.ts +5 -3
- package/dist/functions/create-day-pass-checkout.d.ts +1 -0
- package/dist/functions/create-day-pass-checkout.js +6 -0
- package/dist/functions/event-access-admin.d.ts +1 -0
- package/dist/functions/event-access-admin.js +5 -1
- package/dist/functions/guest-print-setup-confirm.d.ts +3 -1
- package/dist/functions/guest-print-setup-confirm.js +8 -1
- package/dist/functions/guest-print-submit.d.ts +3 -1
- package/dist/functions/guest-print-submit.js +8 -1
- package/dist/functions/manage-booking.d.ts +3 -1
- package/dist/functions/mcp.d.ts +2 -2
- package/dist/functions/mcp.js +2 -2
- package/dist/functions/member-door-action.d.ts +3 -1
- package/dist/functions/member-door-action.js +9 -2
- package/dist/functions/office-assignment-end.d.ts +3 -1
- package/dist/functions/office-assignment-end.js +8 -1
- package/dist/functions/portal-submit-event.d.ts +1 -0
- package/dist/functions/portal-submit-event.js +4 -0
- package/dist/functions/reschedule-booking.d.ts +6 -4
- package/dist/functions/review-ratings.js +1 -1
- package/dist/functions/stripe-db-reconcile.js +1 -1
- package/dist/functions/timetable-event-register.d.ts +3 -1
- package/dist/functions/timetable-event-register.js +8 -1
- package/dist/functions/touch-pass-signup.d.ts +3 -1
- package/dist/functions/touch-pass-signup.js +9 -2
- package/dist/functions/voice-booking.d.ts +1 -1
- package/dist/functions/voice-day-pass.d.ts +2 -1
- package/dist/functions/voice-day-pass.js +4 -0
- package/dist/functions/voice-inquiry.d.ts +3 -1
- package/dist/functions/voice-inquiry.js +9 -2
- package/dist/functions/voice-membership-signup.d.ts +2 -2
- package/dist/functions/voice-tour-booking.d.ts +1 -1
- package/dist/membershipWelcome.d.ts +1 -1
- package/package.json +1 -1
package/dist/bookingEffects.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export type BookingCustomFieldNames = {
|
|
|
69
69
|
};
|
|
70
70
|
export type NotifyGhlConfig = {
|
|
71
71
|
operator: {
|
|
72
|
-
/** Full brand name, e.g. "
|
|
72
|
+
/** Full brand name, e.g. "Acme Coworking". */
|
|
73
73
|
name: string;
|
|
74
74
|
/** Short brand name used in the GHL contact `source`. */
|
|
75
75
|
shortName: string;
|
package/dist/entitlements.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type FeatureKey = 'membership' | 'day_pass' | 'access_control' | 'events' | 'office_assignment' | 'guest_print' | 'voice_ai';
|
|
2
2
|
/**
|
|
3
3
|
* Every existing deployment of this platform (there is exactly one in
|
|
4
|
-
* production today
|
|
4
|
+
* production today) predates this entitlements
|
|
5
5
|
* concept and must keep 100% of its current behavior with zero configuration
|
|
6
6
|
* changes. 'legacy-full' carries every feature key, and resolvePlanId()
|
|
7
7
|
* falls back to it whenever an operator's planId is absent, empty, or not a
|
package/dist/entitlements.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// is an optional feature family a tenant's plan may or may not include.
|
|
6
6
|
/**
|
|
7
7
|
* Every existing deployment of this platform (there is exactly one in
|
|
8
|
-
* production today
|
|
8
|
+
* production today) predates this entitlements
|
|
9
9
|
* concept and must keep 100% of its current behavior with zero configuration
|
|
10
10
|
* changes. 'legacy-full' carries every feature key, and resolvePlanId()
|
|
11
11
|
* falls back to it whenever an operator's planId is absent, empty, or not a
|
|
@@ -22,6 +22,11 @@ export const PLANS = {
|
|
|
22
22
|
// (e.g. a podcast studio) that wants booking + memberships and nothing
|
|
23
23
|
// else the platform offers.
|
|
24
24
|
'studio-core': ['membership'],
|
|
25
|
+
// Coworking bundle: day passes, events and office/desk assignment alongside
|
|
26
|
+
// door access. NOTE: access_control is listed here but is NOT YET gated at
|
|
27
|
+
// any call site (that's its own dedicated, adversarially-reviewed pass) --
|
|
28
|
+
// so this plan is not fully enforceable end-to-end until that lands.
|
|
29
|
+
'coworking-standard': ['day_pass', 'access_control', 'events', 'office_assignment'],
|
|
25
30
|
};
|
|
26
31
|
export function resolvePlanId(operator) {
|
|
27
32
|
const id = operator.planId;
|
|
@@ -15,6 +15,7 @@ import { z } from 'zod';
|
|
|
15
15
|
import { jwtVerify, createRemoteJWKSet } from 'jose';
|
|
16
16
|
import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
17
17
|
import { logOps } from '../ops.js';
|
|
18
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
18
19
|
import { chargeGuestPrintJob, CLAIMABLE_CHARGE_STATUSES, } from '../guestPrintCapture.js';
|
|
19
20
|
const corsHeaders = {
|
|
20
21
|
'Access-Control-Allow-Origin': '*',
|
|
@@ -52,7 +53,10 @@ const Body = z.object({
|
|
|
52
53
|
submission_id: z.string().uuid(),
|
|
53
54
|
amount_cents: z.number().int().positive().max(500_00), // sanity ceiling: $500
|
|
54
55
|
});
|
|
55
|
-
export async function handle(req
|
|
56
|
+
export async function handle(req,
|
|
57
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
58
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
59
|
+
operator = {}) {
|
|
56
60
|
if (req.method === 'OPTIONS')
|
|
57
61
|
return new Response('ok', { headers: corsHeaders });
|
|
58
62
|
if (req.method !== 'POST')
|
|
@@ -83,6 +87,9 @@ export async function handle(req) {
|
|
|
83
87
|
return json(500, { ok: false, error: 'allowlist_lookup_failed' });
|
|
84
88
|
if (!allow)
|
|
85
89
|
return json(403, { ok: false, error: 'not_authorized' });
|
|
90
|
+
if (!hasEntitlement(operator, 'guest_print')) {
|
|
91
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'guest_print' });
|
|
92
|
+
}
|
|
86
93
|
let raw;
|
|
87
94
|
try {
|
|
88
95
|
raw = await req.json();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
1
2
|
interface EffectsBookingRow {
|
|
2
3
|
id: string;
|
|
3
4
|
contact_name: string | null;
|
|
@@ -17,9 +18,10 @@ interface EffectsBookingRow {
|
|
|
17
18
|
usage_instructions?: string | null;
|
|
18
19
|
} | null;
|
|
19
20
|
}
|
|
21
|
+
type SupabaseLike = SupabaseClient<any, any, any>;
|
|
20
22
|
export interface AdminCreateBookingDeps {
|
|
21
|
-
notifyGhl: (admin:
|
|
22
|
-
createCalendarEvent: (admin:
|
|
23
|
+
notifyGhl: (admin: SupabaseLike, row: EffectsBookingRow, doorAccess: unknown) => Promise<void>;
|
|
24
|
+
createCalendarEvent: (admin: SupabaseLike, row: EffectsBookingRow) => Promise<void>;
|
|
23
25
|
parseTstzRange: (range: string) => {
|
|
24
26
|
startISO: string;
|
|
25
27
|
endISO: string;
|
|
@@ -34,7 +36,7 @@ export interface AdminCreateBookingDeps {
|
|
|
34
36
|
email: string;
|
|
35
37
|
phone?: string;
|
|
36
38
|
};
|
|
37
|
-
}, admin:
|
|
39
|
+
}, admin: SupabaseLike) => Promise<Record<string, unknown> | null>;
|
|
38
40
|
extractDoorAccess: (busResp: Record<string, unknown> | null) => unknown;
|
|
39
41
|
}
|
|
40
42
|
export declare function handle(req: Request, operator: {
|
|
@@ -17,6 +17,7 @@ import { z } from 'zod';
|
|
|
17
17
|
import { jwtVerify, createRemoteJWKSet } from 'jose';
|
|
18
18
|
import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
19
19
|
import { logOps } from '../ops.js';
|
|
20
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
20
21
|
const corsHeaders = {
|
|
21
22
|
'Access-Control-Allow-Origin': '*',
|
|
22
23
|
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
|
@@ -76,7 +77,10 @@ const MAX_WINDOW_MS = 14 * 24 * 60 * 60 * 1000;
|
|
|
76
77
|
// credit_consume) only ever applies to hourly/day-rate room bookings in
|
|
77
78
|
// create-booking. Never wire this up without a deliberate product call.
|
|
78
79
|
const EVENT_PACKAGE_CREDIT_APPLIED_CENTS = 0;
|
|
79
|
-
export async function handle(req
|
|
80
|
+
export async function handle(req,
|
|
81
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
82
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
83
|
+
operator = {}) {
|
|
80
84
|
if (req.method === 'OPTIONS')
|
|
81
85
|
return new Response('ok', { headers: corsHeaders });
|
|
82
86
|
if (req.method !== 'POST')
|
|
@@ -108,6 +112,9 @@ export async function handle(req) {
|
|
|
108
112
|
return fail(500, 'allowlist_lookup_failed', allowErr.message);
|
|
109
113
|
if (!allow)
|
|
110
114
|
return fail(403, 'not_authorized', 'Not authorized.');
|
|
115
|
+
if (!hasEntitlement(operator, 'events')) {
|
|
116
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'events' });
|
|
117
|
+
}
|
|
111
118
|
// === Body ===
|
|
112
119
|
let raw;
|
|
113
120
|
try {
|
|
@@ -9,6 +9,7 @@ import { createClient } from '@supabase/supabase-js';
|
|
|
9
9
|
import { jwtVerify, createRemoteJWKSet } from 'jose';
|
|
10
10
|
import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
11
11
|
import { logOps } from '../ops.js';
|
|
12
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
12
13
|
const corsHeaders = {
|
|
13
14
|
'Access-Control-Allow-Origin': '*',
|
|
14
15
|
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
|
@@ -68,7 +69,10 @@ function diff(before, after) {
|
|
|
68
69
|
}
|
|
69
70
|
return out;
|
|
70
71
|
}
|
|
71
|
-
export async function handle(req
|
|
72
|
+
export async function handle(req,
|
|
73
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
74
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
75
|
+
operator = {}) {
|
|
72
76
|
if (req.method === 'OPTIONS')
|
|
73
77
|
return new Response('ok', { headers: corsHeaders });
|
|
74
78
|
if (req.method !== 'POST')
|
|
@@ -98,6 +102,9 @@ export async function handle(req) {
|
|
|
98
102
|
return json(500, { ok: false, error: 'allowlist_lookup_failed' });
|
|
99
103
|
if (!allow)
|
|
100
104
|
return json(403, { ok: false, error: 'not_authorized' });
|
|
105
|
+
if (!hasEntitlement(operator, 'access_control')) {
|
|
106
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'access_control' });
|
|
107
|
+
}
|
|
101
108
|
let body;
|
|
102
109
|
try {
|
|
103
110
|
body = await req.json();
|
|
@@ -5,6 +5,7 @@ import { z } from 'zod';
|
|
|
5
5
|
import { jwtVerify, createRemoteJWKSet } from 'jose';
|
|
6
6
|
import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
7
7
|
import { logOps } from '../ops.js';
|
|
8
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
8
9
|
const corsHeaders = {
|
|
9
10
|
'Access-Control-Allow-Origin': '*',
|
|
10
11
|
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
|
@@ -50,7 +51,10 @@ const Body = z.object({
|
|
|
50
51
|
visit_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
51
52
|
issue_mode: z.enum(['payment_link', 'paid_offline', 'comp']),
|
|
52
53
|
});
|
|
53
|
-
export async function handle(req,
|
|
54
|
+
export async function handle(req,
|
|
55
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
56
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
57
|
+
operator, deps) {
|
|
54
58
|
if (req.method === 'OPTIONS')
|
|
55
59
|
return new Response('ok', { headers: corsHeaders });
|
|
56
60
|
if (req.method !== 'POST')
|
|
@@ -81,6 +85,9 @@ export async function handle(req, operator, deps) {
|
|
|
81
85
|
return json(500, { ok: false, error: 'allowlist_lookup_failed' });
|
|
82
86
|
if (!allow)
|
|
83
87
|
return json(403, { ok: false, error: 'not_authorized' });
|
|
88
|
+
if (!hasEntitlement(operator, 'day_pass')) {
|
|
89
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'day_pass' });
|
|
90
|
+
}
|
|
84
91
|
let raw;
|
|
85
92
|
try {
|
|
86
93
|
raw = await req.json();
|
|
@@ -207,6 +207,10 @@ export async function handle(req, config) {
|
|
|
207
207
|
let provisionOk = false;
|
|
208
208
|
let provisionUnifiUserId;
|
|
209
209
|
let provisionPin;
|
|
210
|
+
// WiFi voucher minted by ftw-middleware (best-effort; absent when guest WiFi
|
|
211
|
+
// is disabled or the mint failed). Before 0.3.14 this was dropped here, so
|
|
212
|
+
// the voucher existed in UniFi but was never recorded or surfaced.
|
|
213
|
+
let wifiVoucher;
|
|
210
214
|
let provisionErrorCode;
|
|
211
215
|
const trialHmacSecret = Deno.env.get('TRIAL_HMAC_SECRET');
|
|
212
216
|
if (!trialHmacSecret) {
|
|
@@ -270,6 +274,14 @@ export async function handle(req, config) {
|
|
|
270
274
|
? provisionParsed.unifi_user_id : undefined;
|
|
271
275
|
const cred = provisionParsed?.credential;
|
|
272
276
|
provisionPin = cred && typeof cred.pin === 'string' ? cred.pin : undefined;
|
|
277
|
+
const wv = provisionParsed?.wifi_voucher;
|
|
278
|
+
if (wv && typeof wv.code_display === 'string' && wv.code_display) {
|
|
279
|
+
wifiVoucher = {
|
|
280
|
+
id: typeof wv.id === 'string' ? wv.id : '',
|
|
281
|
+
code_display: wv.code_display,
|
|
282
|
+
expires_minutes: typeof wv.expires_minutes === 'number' ? wv.expires_minutes : 0,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
273
285
|
}
|
|
274
286
|
}
|
|
275
287
|
}
|
|
@@ -286,6 +298,12 @@ export async function handle(req, config) {
|
|
|
286
298
|
else {
|
|
287
299
|
updatePayload.notes = 'Provisioned without a PIN — mint/set failed on ftw-middleware.';
|
|
288
300
|
}
|
|
301
|
+
if (wifiVoucher) {
|
|
302
|
+
if (wifiVoucher.id)
|
|
303
|
+
updatePayload.wifi_voucher_id = wifiVoucher.id;
|
|
304
|
+
// The voucher is scoped to the trial window; record the window end.
|
|
305
|
+
updatePayload.wifi_expires_at = grant.trial_end_at;
|
|
306
|
+
}
|
|
289
307
|
const { error: statusUpdateErr } = await admin.from('trial_grants').update(updatePayload).eq('id', grant.id);
|
|
290
308
|
if (statusUpdateErr) {
|
|
291
309
|
await logOps(admin, 'admin_request_trial_status_update_failed', { grant_id: grant.id, message: statusUpdateErr.message }, { severity: 'error' });
|
|
@@ -335,6 +353,9 @@ export async function handle(req, config) {
|
|
|
335
353
|
trial_end_at: grant.trial_end_at,
|
|
336
354
|
status: finalStatus,
|
|
337
355
|
...(credential ? { credential } : {}),
|
|
356
|
+
...(wifiVoucher && provisionOk
|
|
357
|
+
? { wifi_voucher: { code_display: wifiVoucher.code_display, expires_minutes: wifiVoucher.expires_minutes } }
|
|
358
|
+
: {}),
|
|
338
359
|
...(provisioningErrorForResponse ? { provisioning_error: provisioningErrorForResponse } : {}),
|
|
339
360
|
});
|
|
340
361
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// DELIVERABILITY-CRITICAL. `senderDomain` and `fromDomain` are the values the
|
|
7
7
|
// sending backend signs and stamps on real password-reset / magic-link mail.
|
|
8
8
|
// They are supplied per tenant by the caller and are NOT interchangeable:
|
|
9
|
-
// today
|
|
9
|
+
// today the current production tenant's sender/from domain (mail.notify.*) differs from its
|
|
10
10
|
// rootDomain (notify.*). Never collapse them into one field, and never
|
|
11
11
|
// default them.
|
|
12
12
|
import * as React from 'react';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
1
2
|
interface EffectsBookingRow {
|
|
2
3
|
id: string;
|
|
3
4
|
contact_name: string | null;
|
|
@@ -17,9 +18,10 @@ interface EffectsBookingRow {
|
|
|
17
18
|
usage_instructions?: string | null;
|
|
18
19
|
} | null;
|
|
19
20
|
}
|
|
21
|
+
type SupabaseLike = SupabaseClient<any, any, any>;
|
|
20
22
|
export interface CreateBookingDeps {
|
|
21
|
-
notifyGhl: (admin:
|
|
22
|
-
createCalendarEvent: (admin:
|
|
23
|
+
notifyGhl: (admin: SupabaseLike, row: EffectsBookingRow, doorAccess: unknown) => Promise<void>;
|
|
24
|
+
createCalendarEvent: (admin: SupabaseLike, row: EffectsBookingRow) => Promise<void>;
|
|
23
25
|
parseTstzRange: (range: string) => {
|
|
24
26
|
startISO: string;
|
|
25
27
|
endISO: string;
|
|
@@ -34,7 +36,7 @@ export interface CreateBookingDeps {
|
|
|
34
36
|
email: string;
|
|
35
37
|
phone?: string;
|
|
36
38
|
};
|
|
37
|
-
}, supabase:
|
|
39
|
+
}, supabase: SupabaseLike) => Promise<Record<string, unknown> | null>;
|
|
38
40
|
extractDoorAccess: (busResp: Record<string, unknown> | null) => unknown;
|
|
39
41
|
}
|
|
40
42
|
export declare function handle(req: Request, operator: {
|
|
@@ -6,6 +6,7 @@ import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
|
6
6
|
import { logOps } from '../ops.js';
|
|
7
7
|
import { applyCheckoutCoupon, couponFailureBody, reverseCheckoutCoupon } from '../checkoutCoupon.js';
|
|
8
8
|
import { buildDayPassSessionParams, computeApplicationFeeCents } from '../checkoutSessionParams.js';
|
|
9
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
9
10
|
const Body = z.object({
|
|
10
11
|
plan_slug: z.string().min(1).max(80).regex(/^[a-z0-9-]+$/),
|
|
11
12
|
email: z.string().email().max(255),
|
|
@@ -24,6 +25,11 @@ function todayLA() {
|
|
|
24
25
|
export async function handle(req, operator) {
|
|
25
26
|
if (req.method === 'OPTIONS')
|
|
26
27
|
return new Response('ok', { headers: corsHeaders });
|
|
28
|
+
if (!hasEntitlement(operator, 'day_pass')) {
|
|
29
|
+
return new Response(JSON.stringify({ ok: false, error: 'feature_not_enabled', feature: 'day_pass' }), {
|
|
30
|
+
status: 403, headers: { ...corsHeaders, 'Content-Type': 'application/json' },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
27
33
|
// Set once a coupon reservation exists. Held at handler scope so the outer
|
|
28
34
|
// catch can release it if anything after the reservation throws.
|
|
29
35
|
let couponRedemptionId = null;
|
|
@@ -13,5 +13,6 @@ export interface EventAccessAdminConfig {
|
|
|
13
13
|
* bytecode (wrapper plus the core version it pulled in) is current, without
|
|
14
14
|
* needing a real door/grant to test against. */
|
|
15
15
|
buildMarker: string;
|
|
16
|
+
planId?: string | null;
|
|
16
17
|
}
|
|
17
18
|
export declare function createEventAccessAdminHandler(config: EventAccessAdminConfig): (req: Request) => Promise<Response>;
|
|
@@ -11,6 +11,7 @@ import { jwtVerify, createRemoteJWKSet } from 'jose';
|
|
|
11
11
|
import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
12
12
|
import { logOps } from '../ops.js';
|
|
13
13
|
import { sha256Hex, signBusMessage } from '../busSignature.js';
|
|
14
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
14
15
|
const corsHeaders = {
|
|
15
16
|
'Access-Control-Allow-Origin': '*',
|
|
16
17
|
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
|
@@ -30,7 +31,7 @@ const TIMEOUT_MS = 20_000;
|
|
|
30
31
|
// headroom (95s) that sits comfortably above ftw-middleware's own
|
|
31
32
|
// _GRANT_HANDLER_TIMEOUT_SEC (85s, itself raised in the same pass to clear
|
|
32
33
|
// the corrected worst case) while staying under the Cloudflare Tunnel
|
|
33
|
-
// edge's own ~100s proxied-HTTP limit for
|
|
34
|
+
// edge's own ~100s proxied-HTTP limit for the FTW middleware's origin -- past that,
|
|
34
35
|
// Cloudflare cuts the connection with a 524 regardless of what this signal
|
|
35
36
|
// says, so there is no point setting this any higher. door/revoke keep the
|
|
36
37
|
// original 20s: neither has a retry loop and both should fail fast.
|
|
@@ -119,6 +120,9 @@ export function createEventAccessAdminHandler(config) {
|
|
|
119
120
|
return json(500, { ok: false, error: 'authz_lookup_failed' });
|
|
120
121
|
if (!allowRes.data && !doorOpsRes.data)
|
|
121
122
|
return json(403, { ok: false, error: 'not_authorized' });
|
|
123
|
+
if (!hasEntitlement(config, 'access_control')) {
|
|
124
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'access_control' });
|
|
125
|
+
}
|
|
122
126
|
let body;
|
|
123
127
|
try {
|
|
124
128
|
body = await req.json();
|
|
@@ -8,6 +8,7 @@ import Stripe from 'stripe';
|
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
10
10
|
import { logOps } from '../ops.js';
|
|
11
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
11
12
|
import { confirmGuestPrintSetup, } from '../guestPrintCapture.js';
|
|
12
13
|
const Body = z.object({
|
|
13
14
|
submission_id: z.string().uuid(),
|
|
@@ -18,7 +19,10 @@ function json(status, body) {
|
|
|
18
19
|
status, headers: { ...corsHeaders, 'Content-Type': 'application/json' },
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
|
-
export async function handle(req
|
|
22
|
+
export async function handle(req,
|
|
23
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
24
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
25
|
+
operator = {}) {
|
|
22
26
|
if (req.method === 'OPTIONS')
|
|
23
27
|
return new Response('ok', { headers: corsHeaders });
|
|
24
28
|
if (req.method !== 'POST')
|
|
@@ -43,6 +47,9 @@ export async function handle(req) {
|
|
|
43
47
|
const ipOk = await checkRateLimit(supabase, 'guest-print-setup-confirm-ip', ip, 30, 600);
|
|
44
48
|
if (!ipOk)
|
|
45
49
|
return json(429, { ok: false, error: 'rate_limited' });
|
|
50
|
+
if (!hasEntitlement(operator, 'guest_print')) {
|
|
51
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'guest_print' });
|
|
52
|
+
}
|
|
46
53
|
// Ownership check BEFORE touching Stripe: the submission_id + setup_intent_id
|
|
47
54
|
// pair must belong to the same row, or a guessed submission_id + an
|
|
48
55
|
// attacker's own real setup_intent_id could mark someone else's row
|
|
@@ -12,6 +12,7 @@ import Stripe from 'stripe';
|
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
14
14
|
import { logOps } from '../ops.js';
|
|
15
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
15
16
|
import { generateGuestBillingCode, submitGuestPrintJob, } from '../guestPrintCapture.js';
|
|
16
17
|
const Body = z.object({
|
|
17
18
|
email: z.string().trim().email().max(255),
|
|
@@ -22,7 +23,10 @@ function json(status, body) {
|
|
|
22
23
|
status, headers: { ...corsHeaders, 'Content-Type': 'application/json' },
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
export async function handle(req
|
|
26
|
+
export async function handle(req,
|
|
27
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
28
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
29
|
+
operator = {}) {
|
|
26
30
|
if (req.method === 'OPTIONS')
|
|
27
31
|
return new Response('ok', { headers: corsHeaders });
|
|
28
32
|
if (req.method !== 'POST')
|
|
@@ -51,6 +55,9 @@ export async function handle(req) {
|
|
|
51
55
|
]);
|
|
52
56
|
if (!ipOk || !emailOk)
|
|
53
57
|
return json(429, { ok: false, error: 'rate_limited' });
|
|
58
|
+
if (!hasEntitlement(operator, 'guest_print')) {
|
|
59
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'guest_print' });
|
|
60
|
+
}
|
|
54
61
|
const stripeKey = Deno.env.get('STRIPE_SECRET_KEY');
|
|
55
62
|
if (!stripeKey)
|
|
56
63
|
return json(500, { ok: false, error: 'stripe_not_configured' });
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
type SupabaseLike = SupabaseClient<any, any, any>;
|
|
1
3
|
interface BookingRow {
|
|
2
4
|
id: string;
|
|
3
5
|
status: string;
|
|
@@ -30,7 +32,7 @@ export interface ManageBookingDeps {
|
|
|
30
32
|
roomKey: string;
|
|
31
33
|
startUtc: string;
|
|
32
34
|
endUtc: string;
|
|
33
|
-
}, admin:
|
|
35
|
+
}, admin: SupabaseLike) => Promise<unknown>;
|
|
34
36
|
signBus: (verb: string, bookingId: string, roomKey: string, startUtc: string, endUtc: string, secret: string, ts: number) => Promise<string>;
|
|
35
37
|
toBusUtc: (iso: string) => string;
|
|
36
38
|
}
|
package/dist/functions/mcp.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface McpBrandConfig {
|
|
2
|
-
/** Public-facing operator name, e.g. "
|
|
2
|
+
/** Public-facing operator name, e.g. "Acme Coworking". */
|
|
3
3
|
brandName: string;
|
|
4
|
-
/** Site origin, no trailing slash, e.g. "https://
|
|
4
|
+
/** Site origin, no trailing slash, e.g. "https://acme-coworking.example". */
|
|
5
5
|
siteBase: string;
|
|
6
6
|
}
|
|
7
7
|
export declare function meetingRoomUrl(config: McpBrandConfig, slug: string): string;
|
package/dist/functions/mcp.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// stay in the tenant repo -- this module only supplies the generic
|
|
5
5
|
// text-construction logic behind the brand name / site URL literals that
|
|
6
6
|
// appear in tool descriptions and generated links, so those strings are
|
|
7
|
-
// parameterized instead of hardcoding
|
|
8
|
-
//
|
|
7
|
+
// parameterized instead of hardcoding a single tenant's brand name / site
|
|
8
|
+
// domain in nine separate places.
|
|
9
9
|
function bareDomain(siteBase) {
|
|
10
10
|
return siteBase.replace(/^https?:\/\//, '');
|
|
11
11
|
}
|
|
@@ -57,4 +57,6 @@ export declare function parseEnabled(raw: string | undefined): {
|
|
|
57
57
|
* An EMPTY allowlist denies everyone — not "no filter applied".
|
|
58
58
|
*/
|
|
59
59
|
export declare function parseAllowlist(raw: string | undefined): Set<string>;
|
|
60
|
-
export declare function handleMemberDoorAction(req: Request
|
|
60
|
+
export declare function handleMemberDoorAction(req: Request, operator?: {
|
|
61
|
+
planId?: string | null;
|
|
62
|
+
}): Promise<Response>;
|
|
@@ -82,6 +82,7 @@ import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
|
82
82
|
import { resolvePortalSession } from '../portalSession.js';
|
|
83
83
|
import { computeEntitlement } from '../membership.js';
|
|
84
84
|
import { logOps } from '../ops.js';
|
|
85
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
85
86
|
const corsHeaders = {
|
|
86
87
|
'Access-Control-Allow-Origin': '*',
|
|
87
88
|
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
|
@@ -107,7 +108,7 @@ const corsHeaders = {
|
|
|
107
108
|
// keyIsolationViolations() enforces it)
|
|
108
109
|
//
|
|
109
110
|
// No hardcoded live host. Every other tenant-app -> middleware caller in this repo
|
|
110
|
-
// hardcodes
|
|
111
|
+
// hardcodes the FTW middleware's live origin; this one does not, so the function is
|
|
111
112
|
// inert (503 not_configured) until an operator sets the base URL as a secret.
|
|
112
113
|
// That also keeps a mis-deployed member-facing door route from ever reaching the
|
|
113
114
|
// real middleware by default.
|
|
@@ -379,7 +380,10 @@ function doorGateOk(notBefore, now) {
|
|
|
379
380
|
return false;
|
|
380
381
|
return t <= now;
|
|
381
382
|
}
|
|
382
|
-
export async function handleMemberDoorAction(req
|
|
383
|
+
export async function handleMemberDoorAction(req,
|
|
384
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
385
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
386
|
+
operator = {}) {
|
|
383
387
|
if (req.method === 'OPTIONS')
|
|
384
388
|
return new Response('ok', { headers: corsHeaders });
|
|
385
389
|
if (req.method !== 'POST')
|
|
@@ -446,6 +450,9 @@ export async function handleMemberDoorAction(req) {
|
|
|
446
450
|
}, { severity: 'warning' });
|
|
447
451
|
return denied();
|
|
448
452
|
}
|
|
453
|
+
if (!hasEntitlement(operator, 'access_control')) {
|
|
454
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'access_control' });
|
|
455
|
+
}
|
|
449
456
|
// ---- Step 5: the tenant app's half of the dual authorization check ---------------
|
|
450
457
|
// Requires a real auth_user_id linkage. Deliberately NO email fallback for
|
|
451
458
|
// still-unlinked rows (portal-resend-invite has one): an email-matched,
|
|
@@ -9,4 +9,6 @@
|
|
|
9
9
|
* Auth scaffold mirrors create-agreement: JWKS verify -> aal2 -> rate limit ->
|
|
10
10
|
* admin_users allowlist.
|
|
11
11
|
*/
|
|
12
|
-
export declare function handle(req: Request
|
|
12
|
+
export declare function handle(req: Request, operator?: {
|
|
13
|
+
planId?: string | null;
|
|
14
|
+
}): Promise<Response>;
|
|
@@ -2,6 +2,7 @@ import { createClient } from '@supabase/supabase-js';
|
|
|
2
2
|
import { jwtVerify, createRemoteJWKSet } from 'jose';
|
|
3
3
|
import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
4
4
|
import { logOps } from '../ops.js';
|
|
5
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
5
6
|
const corsHeaders = {
|
|
6
7
|
'Access-Control-Allow-Origin': '*',
|
|
7
8
|
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
|
@@ -46,7 +47,10 @@ function json(status, body) {
|
|
|
46
47
|
* Auth scaffold mirrors create-agreement: JWKS verify -> aal2 -> rate limit ->
|
|
47
48
|
* admin_users allowlist.
|
|
48
49
|
*/
|
|
49
|
-
export async function handle(req
|
|
50
|
+
export async function handle(req,
|
|
51
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
52
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
53
|
+
operator = {}) {
|
|
50
54
|
if (req.method === 'OPTIONS')
|
|
51
55
|
return new Response('ok', { headers: corsHeaders });
|
|
52
56
|
if (req.method !== 'POST')
|
|
@@ -77,6 +81,9 @@ export async function handle(req) {
|
|
|
77
81
|
return json(500, { ok: false, error: 'allowlist_lookup_failed' });
|
|
78
82
|
if (!allow)
|
|
79
83
|
return json(403, { ok: false, error: 'not_authorized' });
|
|
84
|
+
if (!hasEntitlement(operator, 'office_assignment')) {
|
|
85
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'office_assignment' });
|
|
86
|
+
}
|
|
80
87
|
let body;
|
|
81
88
|
try {
|
|
82
89
|
body = await req.json();
|
|
@@ -18,6 +18,7 @@ import { createClient } from '@supabase/supabase-js';
|
|
|
18
18
|
import { resolvePortalSession } from '../portalSession.js';
|
|
19
19
|
import { checkRateLimit } from '../rateLimit.js';
|
|
20
20
|
import { logOps } from '../ops.js';
|
|
21
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
21
22
|
const corsHeaders = {
|
|
22
23
|
'Access-Control-Allow-Origin': '*',
|
|
23
24
|
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
|
@@ -54,6 +55,9 @@ export async function handle(req, config) {
|
|
|
54
55
|
const ok = await checkRateLimit(admin, 'portal-submit-event', email, 10, 3600);
|
|
55
56
|
if (!ok)
|
|
56
57
|
return json(429, { error: 'rate_limited' });
|
|
58
|
+
if (!hasEntitlement(config, 'events')) {
|
|
59
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'events' });
|
|
60
|
+
}
|
|
57
61
|
let body;
|
|
58
62
|
try {
|
|
59
63
|
body = await req.json();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
1
2
|
interface EffectsBookingRow {
|
|
2
3
|
id: string;
|
|
3
4
|
contact_name: string | null;
|
|
@@ -17,9 +18,10 @@ interface EffectsBookingRow {
|
|
|
17
18
|
usage_instructions?: string | null;
|
|
18
19
|
} | null;
|
|
19
20
|
}
|
|
21
|
+
type SupabaseLike = SupabaseClient<any, any, any>;
|
|
20
22
|
export interface RescheduleBookingDeps {
|
|
21
|
-
notifyGhl: (admin:
|
|
22
|
-
createCalendarEvent: (admin:
|
|
23
|
+
notifyGhl: (admin: SupabaseLike, row: EffectsBookingRow, doorAccess: unknown) => Promise<void>;
|
|
24
|
+
createCalendarEvent: (admin: SupabaseLike, row: EffectsBookingRow) => Promise<void>;
|
|
23
25
|
parseTstzRange: (range: string) => {
|
|
24
26
|
startISO: string;
|
|
25
27
|
endISO: string;
|
|
@@ -34,13 +36,13 @@ export interface RescheduleBookingDeps {
|
|
|
34
36
|
email: string;
|
|
35
37
|
phone?: string;
|
|
36
38
|
};
|
|
37
|
-
}, admin:
|
|
39
|
+
}, admin: SupabaseLike) => Promise<Record<string, unknown> | null>;
|
|
38
40
|
busCancel: (input: {
|
|
39
41
|
bookingId: string;
|
|
40
42
|
roomKey: string;
|
|
41
43
|
startUtc: string;
|
|
42
44
|
endUtc: string;
|
|
43
|
-
}, admin:
|
|
45
|
+
}, admin: SupabaseLike) => Promise<unknown>;
|
|
44
46
|
extractDoorAccess: (busResp: Record<string, unknown> | null) => unknown;
|
|
45
47
|
}
|
|
46
48
|
export declare function handle(req: Request, operator: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Public, read-only review-ratings endpoint.
|
|
2
2
|
//
|
|
3
3
|
// Fetches the Google Places and Yelp Fusion ratings for the business and
|
|
4
|
-
// returns a small JSON payload. Exists so
|
|
4
|
+
// returns a small JSON payload. Exists so the operator's site — a prerendered
|
|
5
5
|
// SPA where everything in the client bundle is public — never has to embed
|
|
6
6
|
// a vendor API key or a hand-typed review number in src/. Vendor keys live
|
|
7
7
|
// only in this function's environment (see env var names below).
|
|
@@ -197,7 +197,7 @@ export async function handle(req, operator) {
|
|
|
197
197
|
for (const s of paidSessions) {
|
|
198
198
|
const checkoutType = s.metadata?.checkout_type ?? null;
|
|
199
199
|
// frAIdays lunch pre-orders use a standalone Stripe Payment Link and are
|
|
200
|
-
// tracked outside
|
|
200
|
+
// tracked outside this platform entirely (Luma/luma-receiver), not in `bookings`.
|
|
201
201
|
// Skip them here rather than false-alarming on every lunch order.
|
|
202
202
|
const FRAIDAYS_LUNCH_PAYMENT_LINK = 'plink_1U3fBDIRhYejQaS5rlYIQF5P';
|
|
203
203
|
if (s.payment_link === FRAIDAYS_LUNCH_PAYMENT_LINK)
|
|
@@ -24,6 +24,7 @@ import { createClient } from '@supabase/supabase-js';
|
|
|
24
24
|
import { resolvePortalSession } from '../portalSession.js';
|
|
25
25
|
import { checkRateLimit } from '../rateLimit.js';
|
|
26
26
|
import { logOps } from '../ops.js';
|
|
27
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
27
28
|
const corsHeaders = {
|
|
28
29
|
'Access-Control-Allow-Origin': '*',
|
|
29
30
|
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
|
@@ -75,7 +76,10 @@ async function findOwnGuest(eventId, email, apiKey) {
|
|
|
75
76
|
}
|
|
76
77
|
return { guest: null };
|
|
77
78
|
}
|
|
78
|
-
export async function handle(req
|
|
79
|
+
export async function handle(req,
|
|
80
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
81
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
82
|
+
operator = {}) {
|
|
79
83
|
if (req.method === 'OPTIONS')
|
|
80
84
|
return new Response('ok', { headers: corsHeaders });
|
|
81
85
|
if (req.method !== 'POST')
|
|
@@ -92,6 +96,9 @@ export async function handle(req) {
|
|
|
92
96
|
const ok = await checkRateLimit(admin, 'timetable-event-register', session.email, 15, 600);
|
|
93
97
|
if (!ok)
|
|
94
98
|
return json(429, { error: 'rate_limited' });
|
|
99
|
+
if (!hasEntitlement(operator, 'events')) {
|
|
100
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'events' });
|
|
101
|
+
}
|
|
95
102
|
const payload = await req.json().catch(() => ({}));
|
|
96
103
|
const eventId = typeof payload?.event_id === 'string' ? payload.event_id.trim() : '';
|
|
97
104
|
const action = payload?.action === 'cancel' ? 'cancel' : 'register';
|
|
@@ -44,6 +44,7 @@ import { z } from 'zod';
|
|
|
44
44
|
import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
45
45
|
import { resolvePortalSession } from '../portalSession.js';
|
|
46
46
|
import { logOps } from '../ops.js';
|
|
47
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
47
48
|
const corsHeaders = {
|
|
48
49
|
'Access-Control-Allow-Origin': '*',
|
|
49
50
|
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
|
@@ -65,7 +66,10 @@ const TOUCH_PASS_AMOUNT_CENTS = 500; // $5.00 flat -- see plan v7 §2 step 4
|
|
|
65
66
|
const Body = z.object({
|
|
66
67
|
membership_id: z.string().uuid(),
|
|
67
68
|
});
|
|
68
|
-
export async function handle(req
|
|
69
|
+
export async function handle(req,
|
|
70
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
71
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
72
|
+
operator = {}) {
|
|
69
73
|
if (req.method === 'OPTIONS')
|
|
70
74
|
return new Response('ok', { headers: corsHeaders });
|
|
71
75
|
if (req.method !== 'POST')
|
|
@@ -107,6 +111,9 @@ export async function handle(req) {
|
|
|
107
111
|
if (!allowlist.has(session.id)) {
|
|
108
112
|
return json(503, { ok: false, error: 'not_configured' });
|
|
109
113
|
}
|
|
114
|
+
if (!hasEntitlement(operator, 'access_control')) {
|
|
115
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'access_control' });
|
|
116
|
+
}
|
|
110
117
|
// ---- Body ----------------------------------------------------------------
|
|
111
118
|
const raw = await req.json().catch(() => ({}));
|
|
112
119
|
const parsed = Body.safeParse(raw);
|
|
@@ -121,7 +128,7 @@ export async function handle(req) {
|
|
|
121
128
|
if (buckets.some((ok) => !ok))
|
|
122
129
|
return json(429, { ok: false, error: 'rate_limited' });
|
|
123
130
|
// ===========================================================================
|
|
124
|
-
// §2 step 1 -- claim-lock the row, keyed on
|
|
131
|
+
// §2 step 1 -- claim-lock the row, keyed on this platform's own RLS resolution order.
|
|
125
132
|
// ===========================================================================
|
|
126
133
|
// Uses the touch_pass_claim_pending() SQL function (SECURITY DEFINER,
|
|
127
134
|
// EXECUTE revoked from anon/authenticated, granted only to service_role --
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Tenant-owned inputs to this function. */
|
|
2
2
|
export type VoiceBookingConfig = {
|
|
3
|
-
/** Spoken/texted business name, e.g. "
|
|
3
|
+
/** Spoken/texted business name, e.g. "Acme Coworking". */
|
|
4
4
|
businessName: string;
|
|
5
5
|
/** Spoken/texted support phone number, e.g. "(916) 836-0808". */
|
|
6
6
|
supportPhoneDisplay: string;
|
|
@@ -7,9 +7,10 @@ export type VoiceDayPassConfig = {
|
|
|
7
7
|
* caller-supplied.
|
|
8
8
|
*/
|
|
9
9
|
dayPassPlanSlug: string;
|
|
10
|
-
/** Spoken/texted business name, e.g. "
|
|
10
|
+
/** Spoken/texted business name, e.g. "Acme Coworking". */
|
|
11
11
|
businessName: string;
|
|
12
12
|
/** Spoken/texted support phone number, e.g. "(916) 836-0808". */
|
|
13
13
|
supportPhoneDisplay: string;
|
|
14
|
+
planId?: string | null;
|
|
14
15
|
};
|
|
15
16
|
export declare function handle(req: Request, config: VoiceDayPassConfig): Promise<Response>;
|
|
@@ -11,6 +11,7 @@ import { createClient } from '@supabase/supabase-js';
|
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { logOps } from '../ops.js';
|
|
13
13
|
import { verifyRetellSignature } from '../retellSignature.js';
|
|
14
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
14
15
|
const Body = z.object({
|
|
15
16
|
contact_name: z.string().min(1).max(200),
|
|
16
17
|
contact_email: z.string().email(),
|
|
@@ -183,6 +184,9 @@ export async function handle(req, config) {
|
|
|
183
184
|
if (!parsed.success)
|
|
184
185
|
return json(400, { ok: false, error: 'invalid_request' });
|
|
185
186
|
const { contact_name, contact_email, contact_phone, visit_date, arrival_time, idempotency_key, } = parsed.data;
|
|
187
|
+
if (!hasEntitlement(config, 'day_pass')) {
|
|
188
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'day_pass' });
|
|
189
|
+
}
|
|
186
190
|
const supabaseUrl = Deno.env.get('SUPABASE_URL');
|
|
187
191
|
const serviceKey = Deno.env.get('SUPABASE_SERVICE_ROLE_KEY');
|
|
188
192
|
const supabase = createClient(supabaseUrl, serviceKey);
|
|
@@ -18,6 +18,7 @@ import { clientIp, checkRateLimit } from '../rateLimit.js';
|
|
|
18
18
|
import { verifyRetellSignature } from '../retellSignature.js';
|
|
19
19
|
import { logOps } from '../ops.js';
|
|
20
20
|
import { syncVoiceInquiryToGhl } from '../ghlVoiceInquiry.js';
|
|
21
|
+
import { hasEntitlement } from '../entitlements.js';
|
|
21
22
|
const Body = z.object({
|
|
22
23
|
caller_name: z.string().min(1).max(200), // agent sends "unknown" literal if caller never gave one
|
|
23
24
|
callback_number: z.string().min(1).max(40),
|
|
@@ -57,7 +58,10 @@ function normalizePhone(value) {
|
|
|
57
58
|
return `+1${digits}`;
|
|
58
59
|
return `${plus}${digits}`;
|
|
59
60
|
}
|
|
60
|
-
export async function handleVoiceInquiry(req
|
|
61
|
+
export async function handleVoiceInquiry(req,
|
|
62
|
+
// D33 Phase E.1: planId is optional -- absent/unrecognized resolves to the
|
|
63
|
+
// full-featured legacy plan, so every existing caller is unaffected.
|
|
64
|
+
operator = {}) {
|
|
61
65
|
if (req.method === 'OPTIONS')
|
|
62
66
|
return new Response('ok', { headers: corsHeaders });
|
|
63
67
|
// Raw text first: the signature is over the exact bytes sent.
|
|
@@ -76,6 +80,9 @@ export async function handleVoiceInquiry(req) {
|
|
|
76
80
|
if (!parsed.success)
|
|
77
81
|
return json(400, { ok: false, error: 'invalid_request' });
|
|
78
82
|
const { caller_name, callback_number, request_type, reason, preferred_time, call_id, caller_id_number, } = parsed.data;
|
|
83
|
+
if (!hasEntitlement(operator, 'voice_ai')) {
|
|
84
|
+
return json(403, { ok: false, error: 'feature_not_enabled', feature: 'voice_ai' });
|
|
85
|
+
}
|
|
79
86
|
const supabase = createClient(Deno.env.get('SUPABASE_URL'), Deno.env.get('SUPABASE_SERVICE_ROLE_KEY'));
|
|
80
87
|
try {
|
|
81
88
|
const ipOk = await checkRateLimit(supabase, 'voice-inquiry-ip', clientIp(req), 10, 600);
|
|
@@ -153,4 +160,4 @@ export async function handleVoiceInquiry(req) {
|
|
|
153
160
|
// real listener — as the deployed edge function entrypoint this module is
|
|
154
161
|
// always the main module, so the guard is a no-op in production.
|
|
155
162
|
if (import.meta.main)
|
|
156
|
-
Deno.serve(handleVoiceInquiry);
|
|
163
|
+
Deno.serve((req) => handleVoiceInquiry(req));
|
|
@@ -4,10 +4,10 @@ export type VoiceMembershipSignupConfig = {
|
|
|
4
4
|
* Plan slugs sellable over this phone flow. Everything else in the
|
|
5
5
|
* operator's catalog (virtual office, private offices, ...) needs a
|
|
6
6
|
* product decision before it can be sold this way — see the caller's own
|
|
7
|
-
* comment for the reasoning behind
|
|
7
|
+
* comment for the reasoning behind the current tenant's exclusions.
|
|
8
8
|
*/
|
|
9
9
|
sellablePlanSlugs: readonly string[];
|
|
10
|
-
/** Spoken/texted business name, e.g. "
|
|
10
|
+
/** Spoken/texted business name, e.g. "Acme Coworking". */
|
|
11
11
|
businessName: string;
|
|
12
12
|
/** Spoken/texted support phone number, e.g. "(916) 836-0808". */
|
|
13
13
|
supportPhoneDisplay: string;
|
|
@@ -13,7 +13,7 @@ export type VoiceTourBookingConfig = {
|
|
|
13
13
|
* only a longer/shorter config array.
|
|
14
14
|
*/
|
|
15
15
|
calendars: readonly TourCalendarConfig[];
|
|
16
|
-
/** Spoken/texted business name, e.g. "
|
|
16
|
+
/** Spoken/texted business name, e.g. "Acme Coworking". */
|
|
17
17
|
businessName: string;
|
|
18
18
|
/** Spoken/texted support phone number, e.g. "(916) 836-0808". */
|
|
19
19
|
supportPhoneDisplay: string;
|
|
@@ -20,7 +20,7 @@ export type WelcomePlan = {
|
|
|
20
20
|
};
|
|
21
21
|
/** The operator (venue/business) identity interpolated into the emails. */
|
|
22
22
|
export type WelcomeOperator = {
|
|
23
|
-
/** Full legal/brand name, e.g. "
|
|
23
|
+
/** Full legal/brand name, e.g. "Acme Coworking". */
|
|
24
24
|
name: string;
|
|
25
25
|
/** Short brand name used in subject lines and GHL `source`. */
|
|
26
26
|
shortName: string;
|