Skip to content

Commit 9003524

Browse files
malek10xdevbaderdean
authored andcommitted
feat: add getMiningSourcesForUserServiceMode helper + fix pre-existing syntax bug
- Add getMiningSourcesForUserServiceMode() for service-mode calls to central function - Fix pre-existing syntax bug in email-campaigns (corrupted Location header) - Note: email-campaigns has additional pre-existing issues preventing startup
1 parent 40e6a50 commit 9003524

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

supabase/functions/email-campaigns/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,9 +2044,9 @@ app.get("/unsubscribe/:token", async (c: Context) => {
20442044
status: 302,
20452045
headers: {
20462046
...corsHeaders,
2047-
Location: success });
2048-
});Url,
2047+
Location: successUrl,
20492048
},
2049+
});
20502050

20512051

20522052
app.get("/track/open/:token", async (c: Context) => {

supabase/functions/fetch-mining-source/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
isTokenExpired,
1818
refreshOAuthToken,
1919
} from "../email-campaigns/sender-options.ts";
20+
import * as crypto from "node:crypto";
2021

2122
interface MiningSourceCredentials {
2223
accessToken?: string;
@@ -34,7 +35,7 @@ interface MiningSource {
3435
credentials: MiningSourceCredentials;
3536
}
3637

37-
async function timingSafeCompare(a: string, b: string): Promise<boolean> {
38+
function timingSafeCompare(a: string, b: string): boolean {
3839
const encoder = new TextEncoder();
3940
const aBytes = encoder.encode(a);
4041
const bBytes = encoder.encode(b);
@@ -43,7 +44,7 @@ async function timingSafeCompare(a: string, b: string): Promise<boolean> {
4344
return false;
4445
}
4546

46-
return crypto.subtle.timingSafeEqual(aBytes, bBytes);
47+
return crypto.timingSafeEqual(aBytes, bBytes);
4748
}
4849

4950
function isValidEmail(email: string): boolean {
@@ -86,8 +87,7 @@ Deno.serve(async (req: Request) => {
8687
const authorization = req.headers.get("Authorization");
8788

8889
if (
89-
serviceKey &&
90-
(await timingSafeCompare(serviceKey, supabaseServiceRoleKey))
90+
serviceKey && timingSafeCompare(serviceKey, supabaseServiceRoleKey)
9191
) {
9292
mode = "service";
9393
} else if (!authorization) {

0 commit comments

Comments
 (0)