Upload 56 files
Browse files- next-env.d.ts +6 -0
- src/app/api/dataset/route.ts +5 -3
- src/app/api/distillation/route.ts +5 -3
- src/lib/store.ts +2 -0
- supabase/.branches/_current_branch +1 -0
- supabase/.gitignore +8 -0
- supabase/.temp/cli-latest +1 -0
- supabase/config.toml +408 -0
- supabase/schema.sql +4 -4
- test.js +63 -0
next-env.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/// <reference types="next" />
|
| 2 |
+
/// <reference types="next/image-types/global" />
|
| 3 |
+
import "./.next/dev/types/routes.d.ts";
|
| 4 |
+
|
| 5 |
+
// NOTE: This file should not be edited
|
| 6 |
+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
src/app/api/dataset/route.ts
CHANGED
|
@@ -59,9 +59,11 @@ export async function PATCH(request: NextRequest) {
|
|
| 59 |
return NextResponse.json({ error: "Request ID is required" }, { status: 400 });
|
| 60 |
}
|
| 61 |
|
| 62 |
-
const
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
|
| 66 |
const result = await upvoteDataset(id, ip);
|
| 67 |
|
|
|
|
| 59 |
return NextResponse.json({ error: "Request ID is required" }, { status: 400 });
|
| 60 |
}
|
| 61 |
|
| 62 |
+
const realIp = request.headers.get("x-real-ip");
|
| 63 |
+
const forwardedFor = request.headers.get("x-forwarded-for");
|
| 64 |
+
const ip = request.ip ||
|
| 65 |
+
realIp ||
|
| 66 |
+
(forwardedFor ? forwardedFor.split(',').pop()?.trim() : "anonymous");
|
| 67 |
|
| 68 |
const result = await upvoteDataset(id, ip);
|
| 69 |
|
src/app/api/distillation/route.ts
CHANGED
|
@@ -57,9 +57,11 @@ export async function PATCH(request: NextRequest) {
|
|
| 57 |
return NextResponse.json({ error: "Request ID is required" }, { status: 400 });
|
| 58 |
}
|
| 59 |
|
| 60 |
-
const
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
|
| 64 |
const result = await upvoteDistillation(id, ip);
|
| 65 |
|
|
|
|
| 57 |
return NextResponse.json({ error: "Request ID is required" }, { status: 400 });
|
| 58 |
}
|
| 59 |
|
| 60 |
+
const realIp = request.headers.get("x-real-ip");
|
| 61 |
+
const forwardedFor = request.headers.get("x-forwarded-for");
|
| 62 |
+
const ip = request.ip ||
|
| 63 |
+
realIp ||
|
| 64 |
+
(forwardedFor ? forwardedFor.split(',').pop()?.trim() : "anonymous");
|
| 65 |
|
| 66 |
const result = await upvoteDistillation(id, ip);
|
| 67 |
|
src/lib/store.ts
CHANGED
|
@@ -447,6 +447,7 @@ export async function upvoteDistillation(
|
|
| 447 |
const { data, error } = await supabaseRest<any[]>("/rest/v1/rpc/toggle_upvote_distillation", {
|
| 448 |
method: "POST",
|
| 449 |
body: JSON.stringify({ request_id: id, voter_ip: ip }),
|
|
|
|
| 450 |
});
|
| 451 |
|
| 452 |
if (error) {
|
|
@@ -472,6 +473,7 @@ export async function upvoteDataset(
|
|
| 472 |
const { data, error } = await supabaseRest<any[]>("/rest/v1/rpc/toggle_upvote_dataset", {
|
| 473 |
method: "POST",
|
| 474 |
body: JSON.stringify({ request_id: id, voter_ip: ip }),
|
|
|
|
| 475 |
});
|
| 476 |
|
| 477 |
if (error) {
|
|
|
|
| 447 |
const { data, error } = await supabaseRest<any[]>("/rest/v1/rpc/toggle_upvote_distillation", {
|
| 448 |
method: "POST",
|
| 449 |
body: JSON.stringify({ request_id: id, voter_ip: ip }),
|
| 450 |
+
requireServiceRole: true,
|
| 451 |
});
|
| 452 |
|
| 453 |
if (error) {
|
|
|
|
| 473 |
const { data, error } = await supabaseRest<any[]>("/rest/v1/rpc/toggle_upvote_dataset", {
|
| 474 |
method: "POST",
|
| 475 |
body: JSON.stringify({ request_id: id, voter_ip: ip }),
|
| 476 |
+
requireServiceRole: true,
|
| 477 |
});
|
| 478 |
|
| 479 |
if (error) {
|
supabase/.branches/_current_branch
ADDED
|
@@ -0,0 +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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# For detailed configuration reference documentation, visit:
|
| 2 |
+
# https://supabase.com/docs/guides/local-development/cli/config
|
| 3 |
+
# A string used to distinguish different Supabase projects on the same host. Defaults to the
|
| 4 |
+
# working directory name when running `supabase init`.
|
| 5 |
+
project_id = "Requests"
|
| 6 |
+
|
| 7 |
+
[api]
|
| 8 |
+
enabled = true
|
| 9 |
+
# Port to use for the API URL.
|
| 10 |
+
port = 54321
|
| 11 |
+
# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API
|
| 12 |
+
# endpoints. `public` and `graphql_public` schemas are included by default.
|
| 13 |
+
schemas = ["public", "graphql_public"]
|
| 14 |
+
# Extra schemas to add to the search_path of every request.
|
| 15 |
+
extra_search_path = ["public", "extensions"]
|
| 16 |
+
# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size
|
| 17 |
+
# for accidental or malicious requests.
|
| 18 |
+
max_rows = 1000
|
| 19 |
+
|
| 20 |
+
[api.tls]
|
| 21 |
+
# Enable HTTPS endpoints locally using a self-signed certificate.
|
| 22 |
+
enabled = false
|
| 23 |
+
# Paths to self-signed certificate pair.
|
| 24 |
+
# cert_path = "../certs/my-cert.pem"
|
| 25 |
+
# key_path = "../certs/my-key.pem"
|
| 26 |
+
|
| 27 |
+
[db]
|
| 28 |
+
# Port to use for the local database URL.
|
| 29 |
+
port = 54322
|
| 30 |
+
# Port used by db diff command to initialize the shadow database.
|
| 31 |
+
shadow_port = 54320
|
| 32 |
+
# Maximum amount of time to wait for health check when starting the local database.
|
| 33 |
+
health_timeout = "2m"
|
| 34 |
+
# The database major version to use. This has to be the same as your remote database's. Run `SHOW
|
| 35 |
+
# server_version;` on the remote database to check.
|
| 36 |
+
major_version = 17
|
| 37 |
+
|
| 38 |
+
[db.pooler]
|
| 39 |
+
enabled = false
|
| 40 |
+
# Port to use for the local connection pooler.
|
| 41 |
+
port = 54329
|
| 42 |
+
# Specifies when a server connection can be reused by other clients.
|
| 43 |
+
# Configure one of the supported pooler modes: `transaction`, `session`.
|
| 44 |
+
pool_mode = "transaction"
|
| 45 |
+
# How many server connections to allow per user/database pair.
|
| 46 |
+
default_pool_size = 20
|
| 47 |
+
# Maximum number of client connections allowed.
|
| 48 |
+
max_client_conn = 100
|
| 49 |
+
|
| 50 |
+
# [db.vault]
|
| 51 |
+
# secret_key = "env(SECRET_VALUE)"
|
| 52 |
+
|
| 53 |
+
[db.migrations]
|
| 54 |
+
# If disabled, migrations will be skipped during a db push or reset.
|
| 55 |
+
enabled = true
|
| 56 |
+
# Specifies an ordered list of schema files that describe your database.
|
| 57 |
+
# Supports glob patterns relative to supabase directory: "./schemas/*.sql"
|
| 58 |
+
schema_paths = []
|
| 59 |
+
|
| 60 |
+
[db.seed]
|
| 61 |
+
# If enabled, seeds the database after migrations during a db reset.
|
| 62 |
+
enabled = true
|
| 63 |
+
# Specifies an ordered list of seed files to load during db reset.
|
| 64 |
+
# Supports glob patterns relative to supabase directory: "./seeds/*.sql"
|
| 65 |
+
sql_paths = ["./seed.sql"]
|
| 66 |
+
|
| 67 |
+
[db.network_restrictions]
|
| 68 |
+
# Enable management of network restrictions.
|
| 69 |
+
enabled = false
|
| 70 |
+
# List of IPv4 CIDR blocks allowed to connect to the database.
|
| 71 |
+
# Defaults to allow all IPv4 connections. Set empty array to block all IPs.
|
| 72 |
+
allowed_cidrs = ["0.0.0.0/0"]
|
| 73 |
+
# List of IPv6 CIDR blocks allowed to connect to the database.
|
| 74 |
+
# Defaults to allow all IPv6 connections. Set empty array to block all IPs.
|
| 75 |
+
allowed_cidrs_v6 = ["::/0"]
|
| 76 |
+
|
| 77 |
+
# Uncomment to reject non-secure connections to the database.
|
| 78 |
+
# [db.ssl_enforcement]
|
| 79 |
+
# enabled = true
|
| 80 |
+
|
| 81 |
+
[realtime]
|
| 82 |
+
enabled = true
|
| 83 |
+
# Bind realtime via either IPv4 or IPv6. (default: IPv4)
|
| 84 |
+
# ip_version = "IPv6"
|
| 85 |
+
# The maximum length in bytes of HTTP request headers. (default: 4096)
|
| 86 |
+
# max_header_length = 4096
|
| 87 |
+
|
| 88 |
+
[studio]
|
| 89 |
+
enabled = true
|
| 90 |
+
# Port to use for Supabase Studio.
|
| 91 |
+
port = 54323
|
| 92 |
+
# External URL of the API server that frontend connects to.
|
| 93 |
+
api_url = "http://127.0.0.1"
|
| 94 |
+
# OpenAI API Key to use for Supabase AI in the Supabase Studio.
|
| 95 |
+
openai_api_key = "env(OPENAI_API_KEY)"
|
| 96 |
+
|
| 97 |
+
# Email testing server. Emails sent with the local dev setup are not actually sent - rather, they
|
| 98 |
+
# are monitored, and you can view the emails that would have been sent from the web interface.
|
| 99 |
+
[inbucket]
|
| 100 |
+
enabled = true
|
| 101 |
+
# Port to use for the email testing server web interface.
|
| 102 |
+
port = 54324
|
| 103 |
+
# Uncomment to expose additional ports for testing user applications that send emails.
|
| 104 |
+
# smtp_port = 54325
|
| 105 |
+
# pop3_port = 54326
|
| 106 |
+
# admin_email = "admin@email.com"
|
| 107 |
+
# sender_name = "Admin"
|
| 108 |
+
|
| 109 |
+
[storage]
|
| 110 |
+
enabled = true
|
| 111 |
+
# The maximum file size allowed (e.g. "5MB", "500KB").
|
| 112 |
+
file_size_limit = "50MiB"
|
| 113 |
+
|
| 114 |
+
# Uncomment to configure local storage buckets
|
| 115 |
+
# [storage.buckets.images]
|
| 116 |
+
# public = false
|
| 117 |
+
# file_size_limit = "50MiB"
|
| 118 |
+
# allowed_mime_types = ["image/png", "image/jpeg"]
|
| 119 |
+
# objects_path = "./images"
|
| 120 |
+
|
| 121 |
+
# Allow connections via S3 compatible clients
|
| 122 |
+
[storage.s3_protocol]
|
| 123 |
+
enabled = true
|
| 124 |
+
|
| 125 |
+
# Image transformation API is available to Supabase Pro plan.
|
| 126 |
+
# [storage.image_transformation]
|
| 127 |
+
# enabled = true
|
| 128 |
+
|
| 129 |
+
# Store analytical data in S3 for running ETL jobs over Iceberg Catalog
|
| 130 |
+
# This feature is only available on the hosted platform.
|
| 131 |
+
[storage.analytics]
|
| 132 |
+
enabled = false
|
| 133 |
+
max_namespaces = 5
|
| 134 |
+
max_tables = 10
|
| 135 |
+
max_catalogs = 2
|
| 136 |
+
|
| 137 |
+
# Analytics Buckets is available to Supabase Pro plan.
|
| 138 |
+
# [storage.analytics.buckets.my-warehouse]
|
| 139 |
+
|
| 140 |
+
# Store vector embeddings in S3 for large and durable datasets
|
| 141 |
+
# This feature is only available on the hosted platform.
|
| 142 |
+
[storage.vector]
|
| 143 |
+
enabled = false
|
| 144 |
+
max_buckets = 10
|
| 145 |
+
max_indexes = 5
|
| 146 |
+
|
| 147 |
+
# Vector Buckets is available to Supabase Pro plan.
|
| 148 |
+
# [storage.vector.buckets.documents-openai]
|
| 149 |
+
|
| 150 |
+
[auth]
|
| 151 |
+
enabled = true
|
| 152 |
+
# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used
|
| 153 |
+
# in emails.
|
| 154 |
+
site_url = "http://127.0.0.1:3000"
|
| 155 |
+
# The public URL that Auth serves on. Defaults to the API external URL with `/auth/v1` appended.
|
| 156 |
+
# external_url = ""
|
| 157 |
+
# A list of *exact* URLs that auth providers are permitted to redirect to post authentication.
|
| 158 |
+
additional_redirect_urls = ["https://127.0.0.1:3000"]
|
| 159 |
+
# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week).
|
| 160 |
+
jwt_expiry = 3600
|
| 161 |
+
# JWT issuer URL. If not set, defaults to auth.external_url.
|
| 162 |
+
# jwt_issuer = ""
|
| 163 |
+
# Path to JWT signing key. DO NOT commit your signing keys file to git.
|
| 164 |
+
# signing_keys_path = "./signing_keys.json"
|
| 165 |
+
# If disabled, the refresh token will never expire.
|
| 166 |
+
enable_refresh_token_rotation = true
|
| 167 |
+
# Allows refresh tokens to be reused after expiry, up to the specified interval in seconds.
|
| 168 |
+
# Requires enable_refresh_token_rotation = true.
|
| 169 |
+
refresh_token_reuse_interval = 10
|
| 170 |
+
# Allow/disallow new user signups to your project.
|
| 171 |
+
enable_signup = true
|
| 172 |
+
# Allow/disallow anonymous sign-ins to your project.
|
| 173 |
+
enable_anonymous_sign_ins = false
|
| 174 |
+
# Allow/disallow testing manual linking of accounts
|
| 175 |
+
enable_manual_linking = false
|
| 176 |
+
# Passwords shorter than this value will be rejected as weak. Minimum 6, recommended 8 or more.
|
| 177 |
+
minimum_password_length = 6
|
| 178 |
+
# Passwords that do not meet the following requirements will be rejected as weak. Supported values
|
| 179 |
+
# are: `letters_digits`, `lower_upper_letters_digits`, `lower_upper_letters_digits_symbols`
|
| 180 |
+
password_requirements = ""
|
| 181 |
+
|
| 182 |
+
# Configure passkey sign-ins.
|
| 183 |
+
# [auth.passkey]
|
| 184 |
+
# enabled = false
|
| 185 |
+
|
| 186 |
+
# Configure WebAuthn relying party settings (required when passkey is enabled).
|
| 187 |
+
# [auth.webauthn]
|
| 188 |
+
# rp_display_name = "Supabase"
|
| 189 |
+
# rp_id = "localhost"
|
| 190 |
+
# rp_origins = ["http://127.0.0.1:3000"]
|
| 191 |
+
|
| 192 |
+
[auth.rate_limit]
|
| 193 |
+
# Number of emails that can be sent per hour. Requires auth.email.smtp to be enabled.
|
| 194 |
+
email_sent = 2
|
| 195 |
+
# Number of SMS messages that can be sent per hour. Requires auth.sms to be enabled.
|
| 196 |
+
sms_sent = 30
|
| 197 |
+
# Number of anonymous sign-ins that can be made per hour per IP address. Requires enable_anonymous_sign_ins = true.
|
| 198 |
+
anonymous_users = 30
|
| 199 |
+
# Number of sessions that can be refreshed in a 5 minute interval per IP address.
|
| 200 |
+
token_refresh = 150
|
| 201 |
+
# Number of sign up and sign-in requests that can be made in a 5 minute interval per IP address (excludes anonymous users).
|
| 202 |
+
sign_in_sign_ups = 30
|
| 203 |
+
# Number of OTP / Magic link verifications that can be made in a 5 minute interval per IP address.
|
| 204 |
+
token_verifications = 30
|
| 205 |
+
# Number of Web3 logins that can be made in a 5 minute interval per IP address.
|
| 206 |
+
web3 = 30
|
| 207 |
+
|
| 208 |
+
# Configure one of the supported captcha providers: `hcaptcha`, `turnstile`.
|
| 209 |
+
# [auth.captcha]
|
| 210 |
+
# enabled = true
|
| 211 |
+
# provider = "hcaptcha"
|
| 212 |
+
# secret = ""
|
| 213 |
+
|
| 214 |
+
[auth.email]
|
| 215 |
+
# Allow/disallow new user signups via email to your project.
|
| 216 |
+
enable_signup = true
|
| 217 |
+
# If enabled, a user will be required to confirm any email change on both the old, and new email
|
| 218 |
+
# addresses. If disabled, only the new email is required to confirm.
|
| 219 |
+
double_confirm_changes = true
|
| 220 |
+
# If enabled, users need to confirm their email address before signing in.
|
| 221 |
+
enable_confirmations = false
|
| 222 |
+
# If enabled, users will need to reauthenticate or have logged in recently to change their password.
|
| 223 |
+
secure_password_change = false
|
| 224 |
+
# Controls the minimum amount of time that must pass before sending another signup confirmation or password reset email.
|
| 225 |
+
max_frequency = "1s"
|
| 226 |
+
# Number of characters used in the email OTP.
|
| 227 |
+
otp_length = 6
|
| 228 |
+
# Number of seconds before the email OTP expires (defaults to 1 hour).
|
| 229 |
+
otp_expiry = 3600
|
| 230 |
+
|
| 231 |
+
# Use a production-ready SMTP server
|
| 232 |
+
# [auth.email.smtp]
|
| 233 |
+
# enabled = true
|
| 234 |
+
# host = "smtp.sendgrid.net"
|
| 235 |
+
# port = 587
|
| 236 |
+
# user = "apikey"
|
| 237 |
+
# pass = "env(SENDGRID_API_KEY)"
|
| 238 |
+
# admin_email = "admin@email.com"
|
| 239 |
+
# sender_name = "Admin"
|
| 240 |
+
|
| 241 |
+
# Uncomment to customize email template
|
| 242 |
+
# [auth.email.template.invite]
|
| 243 |
+
# subject = "You have been invited"
|
| 244 |
+
# content_path = "./supabase/templates/invite.html"
|
| 245 |
+
|
| 246 |
+
# Uncomment to customize notification email template
|
| 247 |
+
# [auth.email.notification.password_changed]
|
| 248 |
+
# enabled = true
|
| 249 |
+
# subject = "Your password has been changed"
|
| 250 |
+
# content_path = "./templates/password_changed_notification.html"
|
| 251 |
+
|
| 252 |
+
[auth.sms]
|
| 253 |
+
# Allow/disallow new user signups via SMS to your project.
|
| 254 |
+
enable_signup = false
|
| 255 |
+
# If enabled, users need to confirm their phone number before signing in.
|
| 256 |
+
enable_confirmations = false
|
| 257 |
+
# Template for sending OTP to users
|
| 258 |
+
template = "Your code is {{ .Code }}"
|
| 259 |
+
# Controls the minimum amount of time that must pass before sending another sms otp.
|
| 260 |
+
max_frequency = "5s"
|
| 261 |
+
|
| 262 |
+
# Use pre-defined map of phone number to OTP for testing.
|
| 263 |
+
# [auth.sms.test_otp]
|
| 264 |
+
# 4152127777 = "123456"
|
| 265 |
+
|
| 266 |
+
# Configure logged in session timeouts.
|
| 267 |
+
# [auth.sessions]
|
| 268 |
+
# Force log out after the specified duration.
|
| 269 |
+
# timebox = "24h"
|
| 270 |
+
# Force log out if the user has been inactive longer than the specified duration.
|
| 271 |
+
# inactivity_timeout = "8h"
|
| 272 |
+
|
| 273 |
+
# This hook runs before a new user is created and allows developers to reject the request based on the incoming user object.
|
| 274 |
+
# [auth.hook.before_user_created]
|
| 275 |
+
# enabled = true
|
| 276 |
+
# uri = "pg-functions://postgres/auth/before-user-created-hook"
|
| 277 |
+
|
| 278 |
+
# This hook runs before a token is issued and allows you to add additional claims based on the authentication method used.
|
| 279 |
+
# [auth.hook.custom_access_token]
|
| 280 |
+
# enabled = true
|
| 281 |
+
# uri = "pg-functions://<database>/<schema>/<hook_name>"
|
| 282 |
+
|
| 283 |
+
# Configure one of the supported SMS providers: `twilio`, `twilio_verify`, `messagebird`, `textlocal`, `vonage`.
|
| 284 |
+
[auth.sms.twilio]
|
| 285 |
+
enabled = false
|
| 286 |
+
account_sid = ""
|
| 287 |
+
message_service_sid = ""
|
| 288 |
+
# DO NOT commit your Twilio auth token to git. Use environment variable substitution instead:
|
| 289 |
+
auth_token = "env(SUPABASE_AUTH_SMS_TWILIO_AUTH_TOKEN)"
|
| 290 |
+
|
| 291 |
+
# Multi-factor-authentication is available to Supabase Pro plan.
|
| 292 |
+
[auth.mfa]
|
| 293 |
+
# Control how many MFA factors can be enrolled at once per user.
|
| 294 |
+
max_enrolled_factors = 10
|
| 295 |
+
|
| 296 |
+
# Control MFA via App Authenticator (TOTP)
|
| 297 |
+
[auth.mfa.totp]
|
| 298 |
+
enroll_enabled = false
|
| 299 |
+
verify_enabled = false
|
| 300 |
+
|
| 301 |
+
# Configure MFA via Phone Messaging
|
| 302 |
+
[auth.mfa.phone]
|
| 303 |
+
enroll_enabled = false
|
| 304 |
+
verify_enabled = false
|
| 305 |
+
otp_length = 6
|
| 306 |
+
template = "Your code is {{ .Code }}"
|
| 307 |
+
max_frequency = "5s"
|
| 308 |
+
|
| 309 |
+
# Configure MFA via WebAuthn
|
| 310 |
+
# [auth.mfa.web_authn]
|
| 311 |
+
# enroll_enabled = true
|
| 312 |
+
# verify_enabled = true
|
| 313 |
+
|
| 314 |
+
# Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`,
|
| 315 |
+
# `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin_oidc`, `notion`, `twitch`,
|
| 316 |
+
# `twitter`, `x`, `slack`, `spotify`, `workos`, `zoom`.
|
| 317 |
+
[auth.external.apple]
|
| 318 |
+
enabled = false
|
| 319 |
+
client_id = ""
|
| 320 |
+
# DO NOT commit your OAuth provider secret to git. Use environment variable substitution instead:
|
| 321 |
+
secret = "env(SUPABASE_AUTH_EXTERNAL_APPLE_SECRET)"
|
| 322 |
+
# Overrides the default auth callback URL derived from auth.external_url.
|
| 323 |
+
redirect_uri = ""
|
| 324 |
+
# Overrides the default auth provider URL. Used to support self-hosted gitlab, single-tenant Azure,
|
| 325 |
+
# or any other third-party OIDC providers.
|
| 326 |
+
url = ""
|
| 327 |
+
# If enabled, the nonce check will be skipped. Required for local sign in with Google auth.
|
| 328 |
+
skip_nonce_check = false
|
| 329 |
+
# If enabled, it will allow the user to successfully authenticate when the provider does not return an email address.
|
| 330 |
+
email_optional = false
|
| 331 |
+
|
| 332 |
+
# Allow Solana wallet holders to sign in to your project via the Sign in with Solana (SIWS, EIP-4361) standard.
|
| 333 |
+
# You can configure "web3" rate limit in the [auth.rate_limit] section and set up [auth.captcha] if self-hosting.
|
| 334 |
+
[auth.web3.solana]
|
| 335 |
+
enabled = false
|
| 336 |
+
|
| 337 |
+
# Use Firebase Auth as a third-party provider alongside Supabase Auth.
|
| 338 |
+
[auth.third_party.firebase]
|
| 339 |
+
enabled = false
|
| 340 |
+
# project_id = "my-firebase-project"
|
| 341 |
+
|
| 342 |
+
# Use Auth0 as a third-party provider alongside Supabase Auth.
|
| 343 |
+
[auth.third_party.auth0]
|
| 344 |
+
enabled = false
|
| 345 |
+
# tenant = "my-auth0-tenant"
|
| 346 |
+
# tenant_region = "us"
|
| 347 |
+
|
| 348 |
+
# Use AWS Cognito (Amplify) as a third-party provider alongside Supabase Auth.
|
| 349 |
+
[auth.third_party.aws_cognito]
|
| 350 |
+
enabled = false
|
| 351 |
+
# user_pool_id = "my-user-pool-id"
|
| 352 |
+
# user_pool_region = "us-east-1"
|
| 353 |
+
|
| 354 |
+
# Use Clerk as a third-party provider alongside Supabase Auth.
|
| 355 |
+
[auth.third_party.clerk]
|
| 356 |
+
enabled = false
|
| 357 |
+
# Obtain from https://clerk.com/setup/supabase
|
| 358 |
+
# domain = "example.clerk.accounts.dev"
|
| 359 |
+
|
| 360 |
+
# OAuth server configuration
|
| 361 |
+
[auth.oauth_server]
|
| 362 |
+
# Enable OAuth server functionality
|
| 363 |
+
enabled = false
|
| 364 |
+
# Path for OAuth consent flow UI
|
| 365 |
+
authorization_url_path = "/oauth/consent"
|
| 366 |
+
# Allow dynamic client registration
|
| 367 |
+
allow_dynamic_registration = false
|
| 368 |
+
|
| 369 |
+
[edge_runtime]
|
| 370 |
+
enabled = true
|
| 371 |
+
# Supported request policies: `oneshot`, `per_worker`.
|
| 372 |
+
# `per_worker` (default) — enables hot reload during local development.
|
| 373 |
+
# `oneshot` — fallback mode if hot reload causes issues (e.g. in large repos or with symlinks).
|
| 374 |
+
policy = "per_worker"
|
| 375 |
+
# Port to attach the Chrome inspector for debugging edge functions.
|
| 376 |
+
inspector_port = 8083
|
| 377 |
+
# The Deno major version to use.
|
| 378 |
+
deno_version = 2
|
| 379 |
+
|
| 380 |
+
# [edge_runtime.secrets]
|
| 381 |
+
# secret_key = "env(SECRET_VALUE)"
|
| 382 |
+
|
| 383 |
+
[analytics]
|
| 384 |
+
enabled = true
|
| 385 |
+
port = 54327
|
| 386 |
+
# Configure one of the supported backends: `postgres`, `bigquery`.
|
| 387 |
+
backend = "postgres"
|
| 388 |
+
|
| 389 |
+
# Experimental features may be deprecated any time
|
| 390 |
+
[experimental]
|
| 391 |
+
# Configures Postgres storage engine to use OrioleDB (S3)
|
| 392 |
+
orioledb_version = ""
|
| 393 |
+
# Configures S3 bucket URL, eg. <bucket_name>.s3-<region>.amazonaws.com
|
| 394 |
+
s3_host = "env(S3_HOST)"
|
| 395 |
+
# Configures S3 bucket region, eg. us-east-1
|
| 396 |
+
s3_region = "env(S3_REGION)"
|
| 397 |
+
# Configures AWS_ACCESS_KEY_ID for S3 bucket
|
| 398 |
+
s3_access_key = "env(S3_ACCESS_KEY)"
|
| 399 |
+
# Configures AWS_SECRET_ACCESS_KEY for S3 bucket
|
| 400 |
+
s3_secret_key = "env(S3_SECRET_KEY)"
|
| 401 |
+
|
| 402 |
+
# [experimental.pgdelta]
|
| 403 |
+
# When enabled, pg-delta becomes the active engine for supported schema flows.
|
| 404 |
+
# enabled = false
|
| 405 |
+
# Directory under `supabase/` where declarative files are written.
|
| 406 |
+
# declarative_schema_path = "./database"
|
| 407 |
+
# JSON string passed through to pg-delta SQL formatting.
|
| 408 |
+
# format_options = "{\"keywordCase\":\"upper\",\"indent\":2,\"maxWidth\":80,\"commaStyle\":\"trailing\"}"
|
supabase/schema.sql
CHANGED
|
@@ -212,10 +212,10 @@ select, insert on table public.dataset_requests to anon, authenticated;
|
|
| 212 |
grant
|
| 213 |
select, insert on table public.request_comments to anon, authenticated;
|
| 214 |
|
| 215 |
-
|
| 216 |
-
execute on function public.toggle_upvote_distillation (uuid, text)
|
| 217 |
authenticated;
|
| 218 |
|
| 219 |
-
|
| 220 |
-
execute on function public.toggle_upvote_dataset (uuid, text)
|
| 221 |
authenticated;
|
|
|
|
| 212 |
grant
|
| 213 |
select, insert on table public.request_comments to anon, authenticated;
|
| 214 |
|
| 215 |
+
revoke
|
| 216 |
+
execute on function public.toggle_upvote_distillation (uuid, text) from public, anon,
|
| 217 |
authenticated;
|
| 218 |
|
| 219 |
+
revoke
|
| 220 |
+
execute on function public.toggle_upvote_dataset (uuid, text) from public, anon,
|
| 221 |
authenticated;
|
test.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const http = require('http');
|
| 2 |
+
|
| 3 |
+
async function run() {
|
| 4 |
+
console.log("Creating a dataset request...");
|
| 5 |
+
const res = await fetch("http://localhost:3333/api/dataset", {
|
| 6 |
+
method: "POST",
|
| 7 |
+
headers: { "Content-Type": "application/json" },
|
| 8 |
+
body: JSON.stringify({
|
| 9 |
+
sourceModel: "test-model-123",
|
| 10 |
+
datasetSize: "1k",
|
| 11 |
+
reasoningDepth: "low",
|
| 12 |
+
topics: ["Science"]
|
| 13 |
+
})
|
| 14 |
+
});
|
| 15 |
+
|
| 16 |
+
if (!res.ok) {
|
| 17 |
+
console.error("Failed to create request:", await res.text());
|
| 18 |
+
return;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
const request = await res.json();
|
| 22 |
+
const id = request.id;
|
| 23 |
+
console.log(`Created request ${id} with upvotes: ${request.upvotes}`);
|
| 24 |
+
|
| 25 |
+
console.log("Upvoting normally (1st time)...");
|
| 26 |
+
const upvote1 = await fetch("http://localhost:3333/api/dataset", {
|
| 27 |
+
method: "PATCH",
|
| 28 |
+
headers: { "Content-Type": "application/json", "X-Forwarded-For": "127.0.0.1" },
|
| 29 |
+
body: JSON.stringify({ id })
|
| 30 |
+
});
|
| 31 |
+
const upvote1Res = await upvote1.json();
|
| 32 |
+
console.log(`Upvotes after 1st vote: ${upvote1Res.upvotes}`);
|
| 33 |
+
|
| 34 |
+
console.log("Upvoting again (same IP, should unvote)...");
|
| 35 |
+
const upvote2 = await fetch("http://localhost:3333/api/dataset", {
|
| 36 |
+
method: "PATCH",
|
| 37 |
+
headers: { "Content-Type": "application/json", "X-Forwarded-For": "127.0.0.1" },
|
| 38 |
+
body: JSON.stringify({ id })
|
| 39 |
+
});
|
| 40 |
+
const upvote2Res = await upvote2.json();
|
| 41 |
+
console.log(`Upvotes after 2nd vote: ${upvote2Res.upvotes}`);
|
| 42 |
+
|
| 43 |
+
// Re-upvote to have 1 upvote again
|
| 44 |
+
await fetch("http://localhost:3333/api/dataset", {
|
| 45 |
+
method: "PATCH",
|
| 46 |
+
headers: { "Content-Type": "application/json", "X-Forwarded-For": "127.0.0.1" },
|
| 47 |
+
body: JSON.stringify({ id })
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
console.log("Attempting to spoof IP via X-Forwarded-For (simulating proxy append)...");
|
| 51 |
+
const upvoteSpoof = await fetch("http://localhost:3333/api/dataset", {
|
| 52 |
+
method: "PATCH",
|
| 53 |
+
headers: {
|
| 54 |
+
"Content-Type": "application/json",
|
| 55 |
+
"X-Forwarded-For": "10.0.0.99, 127.0.0.1"
|
| 56 |
+
},
|
| 57 |
+
body: JSON.stringify({ id })
|
| 58 |
+
});
|
| 59 |
+
const upvoteSpoofRes = await upvoteSpoof.json();
|
| 60 |
+
console.log(`Upvotes after spoof vote: ${upvoteSpoofRes.upvotes}`);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
run().catch(console.error);
|