From 6f1be7a4e1ff3fac596c118306dde644b5f4bb03 Mon Sep 17 00:00:00 2001 From: Jamie Brunton Date: Sat, 24 Jan 2026 21:55:35 +0000 Subject: [PATCH] Fix supabase-js Deno compatibility by pinning to v2.45.0 The latest supabase-js@2.92.0 has a Deno compatibility bug with createRequire that causes all edge functions to fail with: "The argument 'filename' must be a file URL object..." Pin all edge functions to @2.45.0 with ?target=deno parameter to ensure Deno-compatible builds from esm.sh. Co-Authored-By: Claude Opus 4.5 --- .../functions/admin-decrypt-media/index.ts | 2 +- .../functions/admin-decrypt-message/index.ts | 2 +- .../check-streak-milestones/index.ts | 2 +- .../functions/classify-message/index.ts | 2 +- .../functions/delete-account/index.ts | 2 +- .../functions/delete-relationship/index.ts | 2 +- .../supabase/functions/manage-couple/index.ts | 2 +- .../migrate-e2ee-to-plaintext/index.ts | 2 +- .../process-scheduled-releases/index.ts | 2 +- apps/supabase/functions/redeem-code/index.ts | 2 +- .../functions/reset-couple-progress/index.ts | 2 +- .../functions/revenuecat-webhook/index.ts | 2 +- .../send-discord-notification/index.ts | 2 +- .../send-match-notification-digest/index.ts | 2 +- .../send-message-notification/index.ts | 2 +- .../functions/send-notification/index.ts | 2 +- .../send-pack-change-notification/index.ts | 2 +- .../index.ts | 2 +- .../functions/submit-response/index.ts | 2 +- .../functions/sync-subscription/index.ts | 27 +++++++++++++++---- .../functions/update-response/index.ts | 2 +- 21 files changed, 42 insertions(+), 25 deletions(-) diff --git a/apps/supabase/functions/admin-decrypt-media/index.ts b/apps/supabase/functions/admin-decrypt-media/index.ts index df63173..32382de 100644 --- a/apps/supabase/functions/admin-decrypt-media/index.ts +++ b/apps/supabase/functions/admin-decrypt-media/index.ts @@ -1,6 +1,6 @@ // @ts-nocheck import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; import { decode } from "https://deno.land/std@0.208.0/encoding/base64.ts"; import { unwrapWithAdminKey, base64ToUint8Array, KeysMetadata } from "../_shared/encryption.ts"; diff --git a/apps/supabase/functions/admin-decrypt-message/index.ts b/apps/supabase/functions/admin-decrypt-message/index.ts index bcf8a74..faf9b1e 100644 --- a/apps/supabase/functions/admin-decrypt-message/index.ts +++ b/apps/supabase/functions/admin-decrypt-message/index.ts @@ -1,6 +1,6 @@ // @ts-nocheck import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; import { unwrapWithAdminKey, base64ToUint8Array, KeysMetadata } from "../_shared/encryption.ts"; const corsHeaders = { diff --git a/apps/supabase/functions/check-streak-milestones/index.ts b/apps/supabase/functions/check-streak-milestones/index.ts index 23a1cf3..e645527 100644 --- a/apps/supabase/functions/check-streak-milestones/index.ts +++ b/apps/supabase/functions/check-streak-milestones/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; /** * Check for streak milestones and send celebration notifications. diff --git a/apps/supabase/functions/classify-message/index.ts b/apps/supabase/functions/classify-message/index.ts index 36862c6..5495f8e 100644 --- a/apps/supabase/functions/classify-message/index.ts +++ b/apps/supabase/functions/classify-message/index.ts @@ -1,6 +1,6 @@ // @ts-nocheck import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; import { unwrapWithAdminKey, base64ToUint8Array, arrayBufferToBase64, KeysMetadata } from "../_shared/encryption.ts"; const corsHeaders = { diff --git a/apps/supabase/functions/delete-account/index.ts b/apps/supabase/functions/delete-account/index.ts index 4e1bd27..008a509 100644 --- a/apps/supabase/functions/delete-account/index.ts +++ b/apps/supabase/functions/delete-account/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", diff --git a/apps/supabase/functions/delete-relationship/index.ts b/apps/supabase/functions/delete-relationship/index.ts index b236756..5be0c09 100644 --- a/apps/supabase/functions/delete-relationship/index.ts +++ b/apps/supabase/functions/delete-relationship/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", diff --git a/apps/supabase/functions/manage-couple/index.ts b/apps/supabase/functions/manage-couple/index.ts index 1fd01aa..6aa7b38 100755 --- a/apps/supabase/functions/manage-couple/index.ts +++ b/apps/supabase/functions/manage-couple/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", diff --git a/apps/supabase/functions/migrate-e2ee-to-plaintext/index.ts b/apps/supabase/functions/migrate-e2ee-to-plaintext/index.ts index f802672..7babf40 100644 --- a/apps/supabase/functions/migrate-e2ee-to-plaintext/index.ts +++ b/apps/supabase/functions/migrate-e2ee-to-plaintext/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; import { unwrapWithAdminKey, base64ToUint8Array, diff --git a/apps/supabase/functions/process-scheduled-releases/index.ts b/apps/supabase/functions/process-scheduled-releases/index.ts index 0b93b04..36ba282 100644 --- a/apps/supabase/functions/process-scheduled-releases/index.ts +++ b/apps/supabase/functions/process-scheduled-releases/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; /** * Process scheduled pack releases. diff --git a/apps/supabase/functions/redeem-code/index.ts b/apps/supabase/functions/redeem-code/index.ts index 6ce7eca..18a6bb3 100644 --- a/apps/supabase/functions/redeem-code/index.ts +++ b/apps/supabase/functions/redeem-code/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", diff --git a/apps/supabase/functions/reset-couple-progress/index.ts b/apps/supabase/functions/reset-couple-progress/index.ts index 53dba63..ef4c3c4 100644 --- a/apps/supabase/functions/reset-couple-progress/index.ts +++ b/apps/supabase/functions/reset-couple-progress/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", diff --git a/apps/supabase/functions/revenuecat-webhook/index.ts b/apps/supabase/functions/revenuecat-webhook/index.ts index 156666e..769fef2 100644 --- a/apps/supabase/functions/revenuecat-webhook/index.ts +++ b/apps/supabase/functions/revenuecat-webhook/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", diff --git a/apps/supabase/functions/send-discord-notification/index.ts b/apps/supabase/functions/send-discord-notification/index.ts index e35e469..6116c9c 100644 --- a/apps/supabase/functions/send-discord-notification/index.ts +++ b/apps/supabase/functions/send-discord-notification/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", diff --git a/apps/supabase/functions/send-match-notification-digest/index.ts b/apps/supabase/functions/send-match-notification-digest/index.ts index 03993f5..bd850f5 100644 --- a/apps/supabase/functions/send-match-notification-digest/index.ts +++ b/apps/supabase/functions/send-match-notification-digest/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; /** * Send coalesced match notifications. diff --git a/apps/supabase/functions/send-message-notification/index.ts b/apps/supabase/functions/send-message-notification/index.ts index 38cc9cc..3323304 100644 --- a/apps/supabase/functions/send-message-notification/index.ts +++ b/apps/supabase/functions/send-message-notification/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", diff --git a/apps/supabase/functions/send-notification/index.ts b/apps/supabase/functions/send-notification/index.ts index 2ef82b2..74bef30 100755 --- a/apps/supabase/functions/send-notification/index.ts +++ b/apps/supabase/functions/send-notification/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", diff --git a/apps/supabase/functions/send-pack-change-notification/index.ts b/apps/supabase/functions/send-pack-change-notification/index.ts index 48fa44e..8bce2ef 100644 --- a/apps/supabase/functions/send-pack-change-notification/index.ts +++ b/apps/supabase/functions/send-pack-change-notification/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; /** * Send delayed pack change notifications. diff --git a/apps/supabase/functions/send-partner-activity-notification/index.ts b/apps/supabase/functions/send-partner-activity-notification/index.ts index 06317d8..20f295d 100644 --- a/apps/supabase/functions/send-partner-activity-notification/index.ts +++ b/apps/supabase/functions/send-partner-activity-notification/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; /** * Send batched partner activity notifications. diff --git a/apps/supabase/functions/submit-response/index.ts b/apps/supabase/functions/submit-response/index.ts index 6cd4a99..f9b3563 100755 --- a/apps/supabase/functions/submit-response/index.ts +++ b/apps/supabase/functions/submit-response/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", diff --git a/apps/supabase/functions/sync-subscription/index.ts b/apps/supabase/functions/sync-subscription/index.ts index 32a4189..8c5fc1c 100644 --- a/apps/supabase/functions/sync-subscription/index.ts +++ b/apps/supabase/functions/sync-subscription/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*", @@ -44,6 +44,15 @@ Deno.serve(async (req) => { console.log(`Checking subscription for user: ${user.id}`); console.log(`Using entitlement ID: ${ENTITLEMENT_ID}`); console.log(`API key present: ${!!REVENUECAT_API_KEY}`); + console.log(`API key length: ${REVENUECAT_API_KEY?.length || 0}`); + + if (!REVENUECAT_API_KEY) { + console.error("REVENUECAT_API_KEY is not set!"); + return new Response( + JSON.stringify({ error: "Server configuration error: missing API key" }), + { status: 500, headers: { ...corsHeaders, "Content-Type": "application/json" } } + ); + } // Fetch subscription status from RevenueCat API (server-side verification) const rcResponse = await fetch( @@ -60,9 +69,14 @@ Deno.serve(async (req) => { if (!rcResponse.ok) { const errorText = await rcResponse.text(); - console.error("RevenueCat API error:", errorText); + console.error(`RevenueCat API error (${rcResponse.status}):`, errorText); + // Return the actual error details for debugging return new Response( - JSON.stringify({ error: "Failed to verify subscription", details: errorText }), + JSON.stringify({ + error: "Failed to verify subscription", + status: rcResponse.status, + details: errorText + }), { status: 500, headers: { ...corsHeaders, "Content-Type": "application/json" } } ); } @@ -79,8 +93,11 @@ Deno.serve(async (req) => { } // Check if entitlement is active - const isActive = entitlement && - new Date(entitlement.expires_date) > new Date(); + // Note: expires_date can be null for lifetime subscriptions + const isActive = entitlement && ( + entitlement.expires_date === null || + new Date(entitlement.expires_date) > new Date() + ); console.log(`User ${user.id} subscription status: ${isActive ? "active" : "inactive"}`); diff --git a/apps/supabase/functions/update-response/index.ts b/apps/supabase/functions/update-response/index.ts index 12429df..200f6af 100644 --- a/apps/supabase/functions/update-response/index.ts +++ b/apps/supabase/functions/update-response/index.ts @@ -1,5 +1,5 @@ import "jsr:@supabase/functions-js/edge-runtime.d.ts"; -import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.0?target=deno"; const corsHeaders = { "Access-Control-Allow-Origin": "*",