From 37815af78180f4043f465a56e989a77053fe6d3b Mon Sep 17 00:00:00 2001 From: null Date: Tue, 30 Jun 2026 20:43:58 -0500 Subject: [PATCH] chore: rebuild functions dist (add onRestoreRequested + onRestoreFulfilled exports) --- functions/dist/backup/onRestoreRequested.js | 192 ++++++++++++++++++ .../dist/backup/onRestoreRequested.js.map | 1 + .../dist/backup/onRestoreRequested.test.js | 35 ++++ .../backup/onRestoreRequested.test.js.map | 1 + functions/dist/index.js | 5 +- functions/dist/index.js.map | 2 +- 6 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 functions/dist/backup/onRestoreRequested.js create mode 100644 functions/dist/backup/onRestoreRequested.js.map create mode 100644 functions/dist/backup/onRestoreRequested.test.js create mode 100644 functions/dist/backup/onRestoreRequested.test.js.map diff --git a/functions/dist/backup/onRestoreRequested.js b/functions/dist/backup/onRestoreRequested.js new file mode 100644 index 00000000..1d665357 --- /dev/null +++ b/functions/dist/backup/onRestoreRequested.js @@ -0,0 +1,192 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.onRestoreFulfilled = exports.onRestoreRequested = exports.SELF_ALERT_DEDUPE_MS = void 0; +exports.selfAlertAllowed = selfAlertAllowed; +exports.isRestoreReadyTransition = isRestoreReadyTransition; +const functions = __importStar(require("firebase-functions")); +const admin = __importStar(require("firebase-admin")); +const quietHours_1 = require("../notifications/quietHours"); +const CHANNEL = 'partner_activity'; +// Suppress duplicate "was this you?" pushes when a request doc is rapidly deleted+recreated (a compromised +// account could loop that to spam both partners). The in-app queue entry is still written every time. +exports.SELF_ALERT_DEDUPE_MS = 60 * 1000; +/** Pure dedupe decision: allow a self-alert push only if none was sent within the window. */ +function selfAlertAllowed(lastAlertAt, now) { + if (typeof lastAlertAt !== 'number') + return true; + return now - lastAlertAt >= exports.SELF_ALERT_DEDUPE_MS; +} +/** Pure guard: fire the completion alert only on the single REQUESTED→READY status transition. */ +function isRestoreReadyTransition(beforeStatus, afterStatus) { + return afterStatus === 'READY' && beforeStatus !== 'READY'; +} +/** All FCM tokens for a user: the legacy single field + the multi-device `fcmTokens` subcollection. */ +async function gatherTokens(db, uid) { + var _a; + const tokens = []; + const userDoc = await db.collection('users').doc(uid).get(); + const legacy = (_a = userDoc.data()) === null || _a === void 0 ? void 0 : _a.fcmToken; + if (typeof legacy === 'string' && legacy.length > 0) + tokens.push(legacy); + const tokenSnap = await db.collection('users').doc(uid).collection('fcmTokens').get(); + tokenSnap.docs.forEach((d) => { + var _a; + const t = (_a = d.data()) === null || _a === void 0 ? void 0 : _a.token; + if (typeof t === 'string' && t.length > 0 && !tokens.includes(t)) + tokens.push(t); + }); + return tokens; +} +/** + * Write the durable in-app queue entry (always) and — unless quiet hours suppress it — push to every device. + * `bypassQuietHours` is for security signals (the "was this you?" self-alert) that must not be silenced. + */ +async function queueAndPush(db, uid, opts) { + const { type, title, body, coupleId, bypassQuietHours } = opts; + await db.collection('users').doc(uid).collection('notification_queue').add({ + type, title, body, read: false, createdAt: admin.firestore.FieldValue.serverTimestamp(), + }); + const userDoc = await db.collection('users').doc(uid).get(); + if (!userDoc.exists) + return; + if (!bypassQuietHours && (0, quietHours_1.recipientInQuietHours)(userDoc.data())) + return; + const tokens = await gatherTokens(db, uid); + if (tokens.length === 0) + return; + const results = await Promise.allSettled(tokens.map((token) => admin.messaging().send({ + notification: { title, body }, + data: { type, couple_id: coupleId }, + token, + android: { notification: { channelId: CHANNEL } }, + }))); + results.forEach((r, i) => { + if (r.status === 'rejected') + console.warn(`[restore] FCM failed for ${tokens[i]}:`, r.reason); + }); +} +/** + * Fires when a member starts a partner-assisted restore + * (`couples/{coupleId}/restore_requests/{recipientUid}` created on a new/wiped device). Sends TWO + * notifications, isolated so one failing never blocks the other: + * 1. To the OTHER partner — "help them restore" (high-signal; only quiet hours suppress it). + * 2. To the RECIPIENT'S OWN devices — a security "was this you?" alert. If the real owner still holds a + * device (a phished password without device loss), this is how they learn a restore is happening. + * No key material is read or logged — the request carries only a public key + a nonce. + */ +exports.onRestoreRequested = functions.firestore + .document('couples/{coupleId}/restore_requests/{recipientUid}') + .onCreate(async (_snap, context) => { + var _a, _b, _c; + const { coupleId, recipientUid } = context.params; + const db = admin.firestore(); + const coupleRef = db.collection('couples').doc(coupleId); + const coupleDoc = await coupleRef.get(); + if (!coupleDoc.exists) + return; + const userIds = ((_b = (_a = coupleDoc.data()) === null || _a === void 0 ? void 0 : _a.userIds) !== null && _b !== void 0 ? _b : []); + // The recipient must be a member; notify the OTHER member (the partner who can help). + if (!userIds.includes(recipientUid)) + return; + const partnerId = userIds.find((u) => u !== recipientUid); + if (!partnerId) + return; + // Audit trail (no key material — actor/recipient/timestamp only). + console.log(`[onRestoreRequested] couple=${coupleId} recipient=${recipientUid} partner=${partnerId}`); + // 1) Partner "help them restore" — routine quiet hours apply. + try { + await queueAndPush(db, partnerId, { + type: 'restore_requested', + title: 'Help your partner restore 💜', + body: 'They’re setting up on a new device. Tap to help.', + coupleId, + }); + } + catch (e) { + console.warn('[onRestoreRequested] partner notify failed:', e); + } + // 2) Recipient self-alert — security signal, bypasses quiet hours, deduped against create-loops. + try { + const now = Date.now(); + if (selfAlertAllowed((_c = coupleDoc.data()) === null || _c === void 0 ? void 0 : _c.lastRestoreSelfAlertAt, now)) { + await coupleRef.set({ lastRestoreSelfAlertAt: now }, { merge: true }); + await queueAndPush(db, recipientUid, { + type: 'restore_self_alert', + title: 'New device is restoring your history', + body: 'If this wasn’t you, secure your account now.', + coupleId, + bypassQuietHours: true, + }); + } + } + catch (e) { + console.warn('[onRestoreRequested] self-alert failed:', e); + } +}); +/** + * Fires when the partner writes the keybox (status flips to READY) — the moment the couple key actually + * transfers. Alerts the RECIPIENT'S OWN devices that a restore just completed, the strongest "it happened" + * signal for the real owner. Guarded to the single REQUESTED→READY transition (ignores decline/expire). + */ +exports.onRestoreFulfilled = functions.firestore + .document('couples/{coupleId}/restore_requests/{recipientUid}') + .onUpdate(async (change, context) => { + var _a, _b; + const before = change.before.data(); + const after = change.after.data(); + if (!isRestoreReadyTransition(before === null || before === void 0 ? void 0 : before.status, after === null || after === void 0 ? void 0 : after.status)) + return; + const { coupleId, recipientUid } = context.params; + const db = admin.firestore(); + const coupleDoc = await db.collection('couples').doc(coupleId).get(); + const userIds = ((_b = (_a = coupleDoc.data()) === null || _a === void 0 ? void 0 : _a.userIds) !== null && _b !== void 0 ? _b : []); + if (!userIds.includes(recipientUid)) + return; + console.log(`[onRestoreFulfilled] couple=${coupleId} recipient=${recipientUid}`); + try { + await queueAndPush(db, recipientUid, { + type: 'restore_self_alert', + title: 'Your history was just restored', + body: 'A new device now has access. If this wasn’t you, secure your account now.', + coupleId, + bypassQuietHours: true, + }); + } + catch (e) { + console.warn('[onRestoreFulfilled] self-alert failed:', e); + } +}); +//# sourceMappingURL=onRestoreRequested.js.map \ No newline at end of file diff --git a/functions/dist/backup/onRestoreRequested.js.map b/functions/dist/backup/onRestoreRequested.js.map new file mode 100644 index 00000000..f2ce3e22 --- /dev/null +++ b/functions/dist/backup/onRestoreRequested.js.map @@ -0,0 +1 @@ +{"version":3,"file":"onRestoreRequested.js","sourceRoot":"","sources":["../../src/backup/onRestoreRequested.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,4CAGC;AAGD,4DAEC;AAlBD,8DAA+C;AAC/C,sDAAuC;AACvC,4DAAmE;AAEnE,MAAM,OAAO,GAAG,kBAAkB,CAAA;AAClC,2GAA2G;AAC3G,sGAAsG;AACzF,QAAA,oBAAoB,GAAG,EAAE,GAAG,IAAI,CAAA;AAE7C,6FAA6F;AAC7F,SAAgB,gBAAgB,CAAC,WAAoB,EAAE,GAAW;IAChE,IAAI,OAAO,WAAW,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IAChD,OAAO,GAAG,GAAG,WAAW,IAAI,4BAAoB,CAAA;AAClD,CAAC;AAED,kGAAkG;AAClG,SAAgB,wBAAwB,CAAC,YAAqB,EAAE,WAAoB;IAClF,OAAO,WAAW,KAAK,OAAO,IAAI,YAAY,KAAK,OAAO,CAAA;AAC5D,CAAC;AAED,uGAAuG;AACvG,KAAK,UAAU,YAAY,CAAC,EAA6B,EAAE,GAAW;;IACpE,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAA;IAC3D,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,IAAI,EAAE,0CAAE,QAAQ,CAAA;IACvC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxE,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC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AAA;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,yCAAyC,EAAE,CAAC,CAAC,CAAA;IAC5D,CAAC;AACH,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/functions/dist/backup/onRestoreRequested.test.js b/functions/dist/backup/onRestoreRequested.test.js new file mode 100644 index 00000000..e41dd43e --- /dev/null +++ b/functions/dist/backup/onRestoreRequested.test.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const onRestoreRequested_1 = require("./onRestoreRequested"); +// Both helpers are pure decisions extracted from the restore triggers, so no firebase-admin mock is needed. +describe('selfAlertAllowed (self-alert spam dedupe)', () => { + const now = 1000000000000; + it('allows the alert when no previous alert timestamp exists', () => { + expect((0, onRestoreRequested_1.selfAlertAllowed)(undefined, now)).toBe(true); + expect((0, onRestoreRequested_1.selfAlertAllowed)(null, now)).toBe(true); + expect((0, onRestoreRequested_1.selfAlertAllowed)('not-a-number', now)).toBe(true); + }); + it('suppresses a second alert inside the dedupe window', () => { + expect((0, onRestoreRequested_1.selfAlertAllowed)(now - (onRestoreRequested_1.SELF_ALERT_DEDUPE_MS - 1), now)).toBe(false); + expect((0, onRestoreRequested_1.selfAlertAllowed)(now - 1, now)).toBe(false); + }); + it('allows again once the window has elapsed', () => { + expect((0, onRestoreRequested_1.selfAlertAllowed)(now - onRestoreRequested_1.SELF_ALERT_DEDUPE_MS, now)).toBe(true); + expect((0, onRestoreRequested_1.selfAlertAllowed)(now - (onRestoreRequested_1.SELF_ALERT_DEDUPE_MS + 5000), now)).toBe(true); + }); +}); +describe('isRestoreReadyTransition (completion-alert guard)', () => { + it('fires only on the REQUESTED→READY edge', () => { + expect((0, onRestoreRequested_1.isRestoreReadyTransition)('REQUESTED', 'READY')).toBe(true); + }); + it('does not fire when already READY (no repeat on unrelated updates)', () => { + expect((0, onRestoreRequested_1.isRestoreReadyTransition)('READY', 'READY')).toBe(false); + }); + it('does not fire for non-READY outcomes', () => { + expect((0, onRestoreRequested_1.isRestoreReadyTransition)('REQUESTED', 'DECLINED')).toBe(false); + expect((0, onRestoreRequested_1.isRestoreReadyTransition)('REQUESTED', 'EXPIRED')).toBe(false); + expect((0, onRestoreRequested_1.isRestoreReadyTransition)('READY', 'RESTORED')).toBe(false); + expect((0, onRestoreRequested_1.isRestoreReadyTransition)(undefined, undefined)).toBe(false); + }); +}); +//# sourceMappingURL=onRestoreRequested.test.js.map \ No newline at end of file diff --git a/functions/dist/backup/onRestoreRequested.test.js.map b/functions/dist/backup/onRestoreRequested.test.js.map new file mode 100644 index 00000000..5c281973 --- /dev/null +++ b/functions/dist/backup/onRestoreRequested.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"onRestoreRequested.test.js","sourceRoot":"","sources":["../../src/backup/onRestoreRequested.test.ts"],"names":[],"mappings":";;AAAA,6DAAuG;AAEvG,4GAA4G;AAC5G,QAAQ,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACzD,MAAM,GAAG,GAAG,aAAiB,CAAA;IAE7B,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,CAAC,IAAA,qCAAgB,EAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACnD,MAAM,CAAC,IAAA,qCAAgB,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC9C,MAAM,CAAC,IAAA,qCAAgB,EAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,CAAC,IAAA,qCAAgB,EAAC,GAAG,GAAG,CAAC,yCAAoB,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;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KAAK,CAAC,CAAA;QACjE,MAAM,CAAC,IAAA,6CAAwB,EAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACpE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/functions/dist/index.js b/functions/dist/index.js index a0ebf5cf..fc583f1f 100644 --- a/functions/dist/index.js +++ b/functions/dist/index.js @@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -exports.wrapReleaseKeyCallable = exports.onGamePartFinished = exports.onGameSessionUpdate = exports.onUserDelete = exports.scheduledOutcomesReminder = exports.submitOutcomeCallable = exports.createInviteCallable = exports.acceptInviteCallable = exports.leaveCoupleCallable = exports.onCoupleLeave = exports.onMessageWritten = exports.onAnswerRevealed = exports.onAnswerWritten = exports.assignDailyQuestionCallable = exports.assignDailyQuestion = exports.onDateHistoryCreated = exports.onDateReflectionWritten = exports.notifyOnDateMatch = exports.checkDeviceIntegrity = exports.sendReengagementReminder = exports.sendStreakReminder = exports.sendDailyQuestionProactiveReminder = exports.unlockDueMemoryCapsules = exports.sendChallengeDayReminders = exports.sendThinkingOfYouCallable = exports.sendGentleReminderCallable = exports.sendPartnerAnsweredNotification = exports.sendDailyQuestionReminder = exports.onEntitlementChanged = exports.syncEntitlement = exports.revenueCatWebhook = void 0; +exports.wrapReleaseKeyCallable = exports.onGamePartFinished = exports.onGameSessionUpdate = exports.onUserDelete = exports.scheduledOutcomesReminder = exports.submitOutcomeCallable = exports.createInviteCallable = exports.acceptInviteCallable = exports.leaveCoupleCallable = exports.onCoupleLeave = exports.onMessageWritten = exports.onAnswerRevealed = exports.onAnswerWritten = exports.assignDailyQuestionCallable = exports.assignDailyQuestion = exports.onRestoreFulfilled = exports.onRestoreRequested = exports.onDateHistoryCreated = exports.onDateReflectionWritten = exports.notifyOnDateMatch = exports.checkDeviceIntegrity = exports.sendReengagementReminder = exports.sendStreakReminder = exports.sendDailyQuestionProactiveReminder = exports.unlockDueMemoryCapsules = exports.sendChallengeDayReminders = exports.sendThinkingOfYouCallable = exports.sendGentleReminderCallable = exports.sendPartnerAnsweredNotification = exports.sendDailyQuestionReminder = exports.onEntitlementChanged = exports.syncEntitlement = exports.revenueCatWebhook = void 0; const admin = __importStar(require("firebase-admin")); // Initialize the Admin SDK once for every function in this codebase. // Handlers call admin.firestore()/messaging() lazily at invocation time, so a @@ -71,6 +71,9 @@ var onDateReflectionWritten_1 = require("./dates/onDateReflectionWritten"); Object.defineProperty(exports, "onDateReflectionWritten", { enumerable: true, get: function () { return onDateReflectionWritten_1.onDateReflectionWritten; } }); var onDateHistoryCreated_1 = require("./dates/onDateHistoryCreated"); Object.defineProperty(exports, "onDateHistoryCreated", { enumerable: true, get: function () { return onDateHistoryCreated_1.onDateHistoryCreated; } }); +var onRestoreRequested_1 = require("./backup/onRestoreRequested"); +Object.defineProperty(exports, "onRestoreRequested", { enumerable: true, get: function () { return onRestoreRequested_1.onRestoreRequested; } }); +Object.defineProperty(exports, "onRestoreFulfilled", { enumerable: true, get: function () { return onRestoreRequested_1.onRestoreFulfilled; } }); var assignDailyQuestion_1 = require("./questions/assignDailyQuestion"); Object.defineProperty(exports, "assignDailyQuestion", { enumerable: true, get: function () { return assignDailyQuestion_1.assignDailyQuestion; } }); Object.defineProperty(exports, "assignDailyQuestionCallable", { enumerable: true, get: function () { return assignDailyQuestion_1.assignDailyQuestionCallable; } }); diff --git a/functions/dist/index.js.map b/functions/dist/index.js.map index 41d997ed..ea70fe5c 100644 --- a/functions/dist/index.js.map +++ b/functions/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAuC;AAEvC,qEAAqE;AACrE,8EAA8E;AAC9E,gFAAgF;AAChF,IAAI,KAAK,CAAC,IAAI,CAAC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