This commit is contained in:
SirRobert-1 2025-04-28 09:17:46 -06:00
parent f848f4ec11
commit 0da4b651f2
694 changed files with 101276 additions and 27 deletions
diplomas/src
node_modules

View File

@ -48,8 +48,7 @@ const data = {
},
{
title: "Agregar desde archivo",
url: "#",
isActive: true,
url: "/cursosArchivo",
},
],
},

View File

@ -20,7 +20,9 @@ export default function AlumnosVista() {
return (
<Layout>
<div className="w-[80vw] pt-10 flex flex-col items-center text-black">
<h1 className="text-2xl font-semibold mb-6 text-black">Lista de Alumnos</h1>
<h1 className="text-2xl font-semibold mb-6 text-black">
Lista de Alumnos
</h1>
<table className="min-w-full bg-white border">
<thead>
<tr>

View File

@ -1,7 +1,7 @@
import React, { useState } from 'react';
import Papa from 'papaparse';
import React, { useState } from "react";
import Papa from "papaparse";
const CursosArchivo = () => {
export default function CursosArchivo() {
const [modoManual, setModoManual] = useState(true);
const [archivo, setArchivo] = useState(null);
const [datosCSV, setDatosCSV] = useState([]);
@ -28,12 +28,12 @@ const CursosArchivo = () => {
header: true,
skipEmptyLines: true,
complete: (result) => {
console.log('Contenido CSV:', result.data);
console.log("Contenido CSV:", result.data);
setDatosCSV(result.data);
},
error: (error) => {
console.error('Error al leer el CSV:', error.message);
}
console.error("Error al leer el CSV:", error.message);
},
});
};
@ -43,7 +43,7 @@ const CursosArchivo = () => {
<button
onClick={() => setModoManual(true)}
className={`px-4 py-2 rounded-md mr-2 ${
modoManual ? 'bg-blue-300' : 'bg-gray-300'
modoManual ? "bg-blue-300" : "bg-gray-300"
}`}
>
Añadir curso manualmente
@ -51,7 +51,7 @@ const CursosArchivo = () => {
<button
onClick={() => setModoManual(false)}
className={`px-4 py-2 rounded-md ${
!modoManual ? 'bg-blue-300' : 'bg-gray-300'
!modoManual ? "bg-blue-300" : "bg-gray-300"
}`}
>
Añadir curso desde archivo
@ -95,6 +95,4 @@ const CursosArchivo = () => {
)}
</div>
);
};
export default CursosArchivo;
}

View File

@ -1,20 +1,21 @@
import React, { useState } from "react";
import { supabase } from "@/lib/supabaseClient";
import { supabaseClient } from "@/utils/supabase";
import Layout from "@/components/layout/Layout";
const CursosManual = () => {
export default function CursosManual() {
const [nombre, setNombre] = useState("");
const [descripcion, setDescripcion] = useState("");
const [horas, setHoras] = useState("");
const [horas, setHoras] = useState("");
const [competencia, setCompetencia] = useState("");
const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(false);
const manejarGuardar = async () => {
setLoading(true);
const { error } = await supabase.from("curso").insert([
const { error } = await supabaseClient.from("curso").insert([
{
nombre,
descripcion,
horas,
horas,
competencias: [competencia], // si es una sola, usa string. Si son varias, un array.
},
]);
@ -47,7 +48,7 @@ const CursosManual = () => {
placeholder="Descripción"
value={descripcion}
onChange={(e) => setDescripcion(e.target.value)}
className="w-full px-3 py-2 border border-gray-300 rounded-md mb-3 h-24 text-black"
className="w-full px-3 py-2 border border-gray-300 rounded-md mb-3 h-24 text-black"
/>
<Input
type="number"
@ -74,8 +75,6 @@ const CursosManual = () => {
</Button>
</div>
</div>
</div>
</Layout>
);
};
export default CursosManual;
}

View File

@ -0,0 +1,33 @@
import {
createServerClient,
serializeCookieHeader,
createBrowserClient,
} from "@supabase/ssr";
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
export const supabaseClient = createBrowserClient(supabaseUrl, supabaseKey);
export function createClient({ req, res }) {
const supabase = createServerClient(supabaseUrl, supabaseKey, {
cookies: {
getAll() {
return Object.keys(req.cookies).map((name) => ({
name,
value: req.cookies[name] || "",
}));
},
setAll(cookiesToSet) {
res.setHeader(
"Set-Cookie",
cookiesToSet.map(({ name, value, options }) =>
serializeCookieHeader(name, value, options)
)
);
},
},
});
return supabase;
}

12
node_modules/.bin/mkdirp generated vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../mkdirp/dist/cjs/src/bin.js" "$@"
else
exec node "$basedir/../mkdirp/dist/cjs/src/bin.js" "$@"
fi

17
node_modules/.bin/mkdirp.cmd generated vendored Normal file
View File

@ -0,0 +1,17 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mkdirp\dist\cjs\src\bin.js" %*

28
node_modules/.bin/mkdirp.ps1 generated vendored Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../mkdirp/dist/cjs/src/bin.js" $args
} else {
& "$basedir/node$exe" "$basedir/../mkdirp/dist/cjs/src/bin.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../mkdirp/dist/cjs/src/bin.js" $args
} else {
& "node$exe" "$basedir/../mkdirp/dist/cjs/src/bin.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
node_modules/.bin/supabase generated vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
exec "$basedir/../supabase/bin/supabase.exe" "$@"

9
node_modules/.bin/supabase.cmd generated vendored Normal file
View File

@ -0,0 +1,9 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
"%dp0%\..\supabase\bin\supabase.exe" %*

16
node_modules/.bin/supabase.ps1 generated vendored Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/../supabase/bin/supabase.exe" $args
} else {
& "$basedir/../supabase/bin/supabase.exe" $args
}
exit $LASTEXITCODE

317
node_modules/.package-lock.json generated vendored
View File

@ -3,6 +3,17 @@
"lockfileVersion": 3,
"requires": true,
"packages": {
"node_modules/@isaacs/fs-minipass": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz",
"integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==",
"dependencies": {
"minipass": "^7.0.4"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/@supabase/auth-js": {
"version": "2.69.1",
"resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.69.1.tgz",
@ -49,6 +60,17 @@
"ws": "^8.18.0"
}
},
"node_modules/@supabase/ssr": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/@supabase/ssr/-/ssr-0.6.1.tgz",
"integrity": "sha512-QtQgEMvaDzr77Mk3vZ3jWg2/y+D8tExYF7vcJT+wQ8ysuvOeGGjYbZlvj5bHYsj/SpC0bihcisnwPrM4Gp5G4g==",
"dependencies": {
"cookie": "^1.0.1"
},
"peerDependencies": {
"@supabase/supabase-js": "^2.43.4"
}
},
"node_modules/@supabase/storage-js": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.7.1.tgz",
@ -91,6 +113,273 @@
"@types/node": "*"
}
},
"node_modules/agent-base": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz",
"integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==",
"engines": {
"node": ">= 14"
}
},
"node_modules/bin-links": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/bin-links/-/bin-links-5.0.0.tgz",
"integrity": "sha512-sdleLVfCjBtgO5cNjA2HVRvWBJAHs4zwenaCPMNJAJU0yNxpzj80IpjOIimkpkr+mhlA+how5poQtt53PygbHA==",
"dependencies": {
"cmd-shim": "^7.0.0",
"npm-normalize-package-bin": "^4.0.0",
"proc-log": "^5.0.0",
"read-cmd-shim": "^5.0.0",
"write-file-atomic": "^6.0.0"
},
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/chownr": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
"integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==",
"engines": {
"node": ">=18"
}
},
"node_modules/cmd-shim": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-7.0.0.tgz",
"integrity": "sha512-rtpaCbr164TPPh+zFdkWpCyZuKkjpAzODfaZCf/SVJZzJN+4bHQb/LP3Jzq5/+84um3XXY8r548XiWKSborwVw==",
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/cookie": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz",
"integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==",
"engines": {
"node": ">=18"
}
},
"node_modules/data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"engines": {
"node": ">= 12"
}
},
"node_modules/debug": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
"integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "paypal",
"url": "https://paypal.me/jimmywarting"
}
],
"dependencies": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
},
"engines": {
"node": "^12.20 || >= 14.13"
}
},
"node_modules/formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"dependencies": {
"fetch-blob": "^3.1.2"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/https-proxy-agent": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
"integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
"dependencies": {
"agent-base": "^7.1.2",
"debug": "4"
},
"engines": {
"node": ">= 14"
}
},
"node_modules/imurmurhash": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
"integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==",
"engines": {
"node": ">=0.8.19"
}
},
"node_modules/minipass": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
"engines": {
"node": ">=16 || 14 >=14.17"
}
},
"node_modules/minizlib": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.0.2.tgz",
"integrity": "sha512-oG62iEk+CYt5Xj2YqI5Xi9xWUeZhDI8jjQmC5oThVH5JGCTgIjr7ciJDzC7MBzYd//WvR1OTmP5Q38Q8ShQtVA==",
"dependencies": {
"minipass": "^7.1.2"
},
"engines": {
"node": ">= 18"
}
},
"node_modules/mkdirp": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
"integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==",
"bin": {
"mkdirp": "dist/cjs/src/bin.js"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"deprecated": "Use your platform's native DOMException instead",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
],
"engines": {
"node": ">=10.5.0"
}
},
"node_modules/node-fetch": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
"dependencies": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/node-fetch"
}
},
"node_modules/npm-normalize-package-bin": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-4.0.0.tgz",
"integrity": "sha512-TZKxPvItzai9kN9H/TkmCtx/ZN/hvr3vUycjlfmH0ootY9yFBzNOpiXAdIn1Iteqsvk4lQn6B5PTrt+n6h8k/w==",
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/proc-log": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/proc-log/-/proc-log-5.0.0.tgz",
"integrity": "sha512-Azwzvl90HaF0aCz1JrDdXQykFakSSNPaPoiZ9fm5qJIMHioDZEi7OAdRwSm6rSoPtY3Qutnm3L7ogmg3dc+wbQ==",
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/read-cmd-shim": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-5.0.0.tgz",
"integrity": "sha512-SEbJV7tohp3DAAILbEMPXavBjAnMN0tVnh4+9G8ihV4Pq3HYF9h8QNez9zkJ1ILkv9G2BjdzwctznGZXgu/HGw==",
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/signal-exit": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/supabase": {
"version": "2.22.6",
"resolved": "https://registry.npmjs.org/supabase/-/supabase-2.22.6.tgz",
"integrity": "sha512-W/A5JlKqrp0pxSaFRYwlWpk+aCql9xUp1ZeLVarRVtqsT6QPLqLsLPIwES0005lQKS3QBbdWDgYThEStPM1kxQ==",
"hasInstallScript": true,
"dependencies": {
"bin-links": "^5.0.0",
"https-proxy-agent": "^7.0.2",
"node-fetch": "^3.3.2",
"tar": "7.4.3"
},
"bin": {
"supabase": "bin/supabase"
},
"engines": {
"npm": ">=8"
}
},
"node_modules/tar": {
"version": "7.4.3",
"resolved": "https://registry.npmjs.org/tar/-/tar-7.4.3.tgz",
"integrity": "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==",
"dependencies": {
"@isaacs/fs-minipass": "^4.0.0",
"chownr": "^3.0.0",
"minipass": "^7.1.2",
"minizlib": "^3.0.1",
"mkdirp": "^3.0.1",
"yallist": "^5.0.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
@ -101,6 +390,14 @@
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="
},
"node_modules/web-streams-polyfill": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
"integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==",
"engines": {
"node": ">= 8"
}
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
@ -115,6 +412,18 @@
"webidl-conversions": "^3.0.0"
}
},
"node_modules/write-file-atomic": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-6.0.0.tgz",
"integrity": "sha512-GmqrO8WJ1NuzJ2DrziEI2o57jKAVIQNf8a18W3nCYU3H7PNWqCCVTeH6/NQE93CIllIgQS98rrmVkYgTX9fFJQ==",
"dependencies": {
"imurmurhash": "^0.1.4",
"signal-exit": "^4.0.1"
},
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/ws": {
"version": "8.18.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.1.tgz",
@ -134,6 +443,14 @@
"optional": true
}
}
},
"node_modules/yallist": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz",
"integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==",
"engines": {
"node": ">=18"
}
}
}
}

15
node_modules/@isaacs/fs-minipass/LICENSE generated vendored Normal file
View File

@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

71
node_modules/@isaacs/fs-minipass/README.md generated vendored Normal file
View File

@ -0,0 +1,71 @@
# fs-minipass
Filesystem streams based on [minipass](http://npm.im/minipass).
4 classes are exported:
- ReadStream
- ReadStreamSync
- WriteStream
- WriteStreamSync
When using `ReadStreamSync`, all of the data is made available
immediately upon consuming the stream. Nothing is buffered in memory
when the stream is constructed. If the stream is piped to a writer,
then it will synchronously `read()` and emit data into the writer as
fast as the writer can consume it. (That is, it will respect
backpressure.) If you call `stream.read()` then it will read the
entire file and return the contents.
When using `WriteStreamSync`, every write is flushed to the file
synchronously. If your writes all come in a single tick, then it'll
write it all out in a single tick. It's as synchronous as you are.
The async versions work much like their node builtin counterparts,
with the exception of introducing significantly less Stream machinery
overhead.
## USAGE
It's just streams, you pipe them or read() them or write() to them.
```js
import { ReadStream, WriteStream } from 'fs-minipass'
// or: const { ReadStream, WriteStream } = require('fs-minipass')
const readStream = new ReadStream('file.txt')
const writeStream = new WriteStream('output.txt')
writeStream.write('some file header or whatever\n')
readStream.pipe(writeStream)
```
## ReadStream(path, options)
Path string is required, but somewhat irrelevant if an open file
descriptor is passed in as an option.
Options:
- `fd` Pass in a numeric file descriptor, if the file is already open.
- `readSize` The size of reads to do, defaults to 16MB
- `size` The size of the file, if known. Prevents zero-byte read()
call at the end.
- `autoClose` Set to `false` to prevent the file descriptor from being
closed when the file is done being read.
## WriteStream(path, options)
Path string is required, but somewhat irrelevant if an open file
descriptor is passed in as an option.
Options:
- `fd` Pass in a numeric file descriptor, if the file is already open.
- `mode` The mode to create the file with. Defaults to `0o666`.
- `start` The position in the file to start reading. If not
specified, then the file will start writing at position zero, and be
truncated by default.
- `autoClose` Set to `false` to prevent the file descriptor from being
closed when the stream is ended.
- `flags` Flags to use when opening the file. Irrelevant if `fd` is
passed in, since file won't be opened in that case. Defaults to
`'a'` if a `pos` is specified, or `'w'` otherwise.

View File

@ -0,0 +1,118 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import EE from 'events';
import { Minipass } from 'minipass';
declare const _autoClose: unique symbol;
declare const _close: unique symbol;
declare const _ended: unique symbol;
declare const _fd: unique symbol;
declare const _finished: unique symbol;
declare const _flags: unique symbol;
declare const _flush: unique symbol;
declare const _handleChunk: unique symbol;
declare const _makeBuf: unique symbol;
declare const _mode: unique symbol;
declare const _needDrain: unique symbol;
declare const _onerror: unique symbol;
declare const _onopen: unique symbol;
declare const _onread: unique symbol;
declare const _onwrite: unique symbol;
declare const _open: unique symbol;
declare const _path: unique symbol;
declare const _pos: unique symbol;
declare const _queue: unique symbol;
declare const _read: unique symbol;
declare const _readSize: unique symbol;
declare const _reading: unique symbol;
declare const _remain: unique symbol;
declare const _size: unique symbol;
declare const _write: unique symbol;
declare const _writing: unique symbol;
declare const _defaultFlag: unique symbol;
declare const _errored: unique symbol;
export type ReadStreamOptions = Minipass.Options<Minipass.ContiguousData> & {
fd?: number;
readSize?: number;
size?: number;
autoClose?: boolean;
};
export type ReadStreamEvents = Minipass.Events<Minipass.ContiguousData> & {
open: [fd: number];
};
export declare class ReadStream extends Minipass<Minipass.ContiguousData, Buffer, ReadStreamEvents> {
[_errored]: boolean;
[_fd]?: number;
[_path]: string;
[_readSize]: number;
[_reading]: boolean;
[_size]: number;
[_remain]: number;
[_autoClose]: boolean;
constructor(path: string, opt: ReadStreamOptions);
get fd(): number | undefined;
get path(): string;
write(): void;
end(): void;
[_open](): void;
[_onopen](er?: NodeJS.ErrnoException | null, fd?: number): void;
[_makeBuf](): Buffer;
[_read](): void;
[_onread](er?: NodeJS.ErrnoException | null, br?: number, buf?: Buffer): void;
[_close](): void;
[_onerror](er: NodeJS.ErrnoException): void;
[_handleChunk](br: number, buf: Buffer): boolean;
emit<Event extends keyof ReadStreamEvents>(ev: Event, ...args: ReadStreamEvents[Event]): boolean;
}
export declare class ReadStreamSync extends ReadStream {
[_open](): void;
[_read](): void;
[_close](): void;
}
export type WriteStreamOptions = {
fd?: number;
autoClose?: boolean;
mode?: number;
captureRejections?: boolean;
start?: number;
flags?: string;
};
export declare class WriteStream extends EE {
readable: false;
writable: boolean;
[_errored]: boolean;
[_writing]: boolean;
[_ended]: boolean;
[_queue]: Buffer[];
[_needDrain]: boolean;
[_path]: string;
[_mode]: number;
[_autoClose]: boolean;
[_fd]?: number;
[_defaultFlag]: boolean;
[_flags]: string;
[_finished]: boolean;
[_pos]?: number;
constructor(path: string, opt: WriteStreamOptions);
emit(ev: string, ...args: any[]): boolean;
get fd(): number | undefined;
get path(): string;
[_onerror](er: NodeJS.ErrnoException): void;
[_open](): void;
[_onopen](er?: null | NodeJS.ErrnoException, fd?: number): void;
end(buf: string, enc?: BufferEncoding): this;
end(buf?: Buffer, enc?: undefined): this;
write(buf: string, enc?: BufferEncoding): boolean;
write(buf: Buffer, enc?: undefined): boolean;
[_write](buf: Buffer): void;
[_onwrite](er?: null | NodeJS.ErrnoException, bw?: number): void;
[_flush](): void;
[_close](): void;
}
export declare class WriteStreamSync extends WriteStream {
[_open](): void;
[_close](): void;
[_write](buf: Buffer): void;
}
export {};
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAInC,QAAA,MAAM,UAAU,eAAuB,CAAA;AACvC,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,GAAG,eAAgB,CAAA;AACzB,QAAA,MAAM,SAAS,eAAsB,CAAA;AACrC,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,YAAY,eAAyB,CAAA;AAC3C,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,UAAU,eAAuB,CAAA;AACvC,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,OAAO,eAAoB,CAAA;AACjC,QAAA,MAAM,OAAO,eAAoB,CAAA;AACjC,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,IAAI,eAAiB,CAAA;AAC3B,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,SAAS,eAAsB,CAAA;AACrC,QAAA,MAAM,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Ac,EAAE,EAAE,CAAC,EAAE,MAAM;IAwBzD,CAAC,MAAM,CAAC;IAgBR,CAAC,MAAM,CAAC;CAST;AAED,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,CAAC,KAAK,CAAC,IAAI,IAAI;IAsBf,CAAC,MAAM,CAAC;IASR,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM;CAmBrB"}

430
node_modules/@isaacs/fs-minipass/dist/commonjs/index.js generated vendored Normal file
View File

@ -0,0 +1,430 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WriteStreamSync = exports.WriteStream = exports.ReadStreamSync = exports.ReadStream = void 0;
const events_1 = __importDefault(require("events"));
const fs_1 = __importDefault(require("fs"));
const minipass_1 = require("minipass");
const writev = fs_1.default.writev;
const _autoClose = Symbol('_autoClose');
const _close = Symbol('_close');
const _ended = Symbol('_ended');
const _fd = Symbol('_fd');
const _finished = Symbol('_finished');
const _flags = Symbol('_flags');
const _flush = Symbol('_flush');
const _handleChunk = Symbol('_handleChunk');
const _makeBuf = Symbol('_makeBuf');
const _mode = Symbol('_mode');
const _needDrain = Symbol('_needDrain');
const _onerror = Symbol('_onerror');
const _onopen = Symbol('_onopen');
const _onread = Symbol('_onread');
const _onwrite = Symbol('_onwrite');
const _open = Symbol('_open');
const _path = Symbol('_path');
const _pos = Symbol('_pos');
const _queue = Symbol('_queue');
const _read = Symbol('_read');
const _readSize = Symbol('_readSize');
const _reading = Symbol('_reading');
const _remain = Symbol('_remain');
const _size = Symbol('_size');
const _write = Symbol('_write');
const _writing = Symbol('_writing');
const _defaultFlag = Symbol('_defaultFlag');
const _errored = Symbol('_errored');
class ReadStream extends minipass_1.Minipass {
[_errored] = false;
[_fd];
[_path];
[_readSize];
[_reading] = false;
[_size];
[_remain];
[_autoClose];
constructor(path, opt) {
opt = opt || {};
super(opt);
this.readable = true;
this.writable = false;
if (typeof path !== 'string') {
throw new TypeError('path must be a string');
}
this[_errored] = false;
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
this[_path] = path;
this[_readSize] = opt.readSize || 16 * 1024 * 1024;
this[_reading] = false;
this[_size] = typeof opt.size === 'number' ? opt.size : Infinity;
this[_remain] = this[_size];
this[_autoClose] =
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
if (typeof this[_fd] === 'number') {
this[_read]();
}
else {
this[_open]();
}
}
get fd() {
return this[_fd];
}
get path() {
return this[_path];
}
//@ts-ignore
write() {
throw new TypeError('this is a readable stream');
}
//@ts-ignore
end() {
throw new TypeError('this is a readable stream');
}
[_open]() {
fs_1.default.open(this[_path], 'r', (er, fd) => this[_onopen](er, fd));
}
[_onopen](er, fd) {
if (er) {
this[_onerror](er);
}
else {
this[_fd] = fd;
this.emit('open', fd);
this[_read]();
}
}
[_makeBuf]() {
return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]));
}
[_read]() {
if (!this[_reading]) {
this[_reading] = true;
const buf = this[_makeBuf]();
/* c8 ignore start */
if (buf.length === 0) {
return process.nextTick(() => this[_onread](null, 0, buf));
}
/* c8 ignore stop */
fs_1.default.read(this[_fd], buf, 0, buf.length, null, (er, br, b) => this[_onread](er, br, b));
}
}
[_onread](er, br, buf) {
this[_reading] = false;
if (er) {
this[_onerror](er);
}
else if (this[_handleChunk](br, buf)) {
this[_read]();
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs_1.default.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
}
}
[_onerror](er) {
this[_reading] = true;
this[_close]();
this.emit('error', er);
}
[_handleChunk](br, buf) {
let ret = false;
// no effect if infinite
this[_remain] -= br;
if (br > 0) {
ret = super.write(br < buf.length ? buf.subarray(0, br) : buf);
}
if (br === 0 || this[_remain] <= 0) {
ret = false;
this[_close]();
super.end();
}
return ret;
}
emit(ev, ...args) {
switch (ev) {
case 'prefinish':
case 'finish':
return false;
case 'drain':
if (typeof this[_fd] === 'number') {
this[_read]();
}
return false;
case 'error':
if (this[_errored]) {
return false;
}
this[_errored] = true;
return super.emit(ev, ...args);
default:
return super.emit(ev, ...args);
}
}
}
exports.ReadStream = ReadStream;
class ReadStreamSync extends ReadStream {
[_open]() {
let threw = true;
try {
this[_onopen](null, fs_1.default.openSync(this[_path], 'r'));
threw = false;
}
finally {
if (threw) {
this[_close]();
}
}
}
[_read]() {
let threw = true;
try {
if (!this[_reading]) {
this[_reading] = true;
do {
const buf = this[_makeBuf]();
/* c8 ignore start */
const br = buf.length === 0
? 0
: fs_1.default.readSync(this[_fd], buf, 0, buf.length, null);
/* c8 ignore stop */
if (!this[_handleChunk](br, buf)) {
break;
}
} while (true);
this[_reading] = false;
}
threw = false;
}
finally {
if (threw) {
this[_close]();
}
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs_1.default.closeSync(fd);
this.emit('close');
}
}
}
exports.ReadStreamSync = ReadStreamSync;
class WriteStream extends events_1.default {
readable = false;
writable = true;
[_errored] = false;
[_writing] = false;
[_ended] = false;
[_queue] = [];
[_needDrain] = false;
[_path];
[_mode];
[_autoClose];
[_fd];
[_defaultFlag];
[_flags];
[_finished] = false;
[_pos];
constructor(path, opt) {
opt = opt || {};
super(opt);
this[_path] = path;
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
this[_mode] = opt.mode === undefined ? 0o666 : opt.mode;
this[_pos] = typeof opt.start === 'number' ? opt.start : undefined;
this[_autoClose] =
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
// truncating makes no sense when writing into the middle
const defaultFlag = this[_pos] !== undefined ? 'r+' : 'w';
this[_defaultFlag] = opt.flags === undefined;
this[_flags] = opt.flags === undefined ? defaultFlag : opt.flags;
if (this[_fd] === undefined) {
this[_open]();
}
}
emit(ev, ...args) {
if (ev === 'error') {
if (this[_errored]) {
return false;
}
this[_errored] = true;
}
return super.emit(ev, ...args);
}
get fd() {
return this[_fd];
}
get path() {
return this[_path];
}
[_onerror](er) {
this[_close]();
this[_writing] = true;
this.emit('error', er);
}
[_open]() {
fs_1.default.open(this[_path], this[_flags], this[_mode], (er, fd) => this[_onopen](er, fd));
}
[_onopen](er, fd) {
if (this[_defaultFlag] &&
this[_flags] === 'r+' &&
er &&
er.code === 'ENOENT') {
this[_flags] = 'w';
this[_open]();
}
else if (er) {
this[_onerror](er);
}
else {
this[_fd] = fd;
this.emit('open', fd);
if (!this[_writing]) {
this[_flush]();
}
}
}
end(buf, enc) {
if (buf) {
//@ts-ignore
this.write(buf, enc);
}
this[_ended] = true;
// synthetic after-write logic, where drain/finish live
if (!this[_writing] &&
!this[_queue].length &&
typeof this[_fd] === 'number') {
this[_onwrite](null, 0);
}
return this;
}
write(buf, enc) {
if (typeof buf === 'string') {
buf = Buffer.from(buf, enc);
}
if (this[_ended]) {
this.emit('error', new Error('write() after end()'));
return false;
}
if (this[_fd] === undefined || this[_writing] || this[_queue].length) {
this[_queue].push(buf);
this[_needDrain] = true;
return false;
}
this[_writing] = true;
this[_write](buf);
return true;
}
[_write](buf) {
fs_1.default.write(this[_fd], buf, 0, buf.length, this[_pos], (er, bw) => this[_onwrite](er, bw));
}
[_onwrite](er, bw) {
if (er) {
this[_onerror](er);
}
else {
if (this[_pos] !== undefined && typeof bw === 'number') {
this[_pos] += bw;
}
if (this[_queue].length) {
this[_flush]();
}
else {
this[_writing] = false;
if (this[_ended] && !this[_finished]) {
this[_finished] = true;
this[_close]();
this.emit('finish');
}
else if (this[_needDrain]) {
this[_needDrain] = false;
this.emit('drain');
}
}
}
}
[_flush]() {
if (this[_queue].length === 0) {
if (this[_ended]) {
this[_onwrite](null, 0);
}
}
else if (this[_queue].length === 1) {
this[_write](this[_queue].pop());
}
else {
const iovec = this[_queue];
this[_queue] = [];
writev(this[_fd], iovec, this[_pos], (er, bw) => this[_onwrite](er, bw));
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs_1.default.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
}
}
}
exports.WriteStream = WriteStream;
class WriteStreamSync extends WriteStream {
[_open]() {
let fd;
// only wrap in a try{} block if we know we'll retry, to avoid
// the rethrow obscuring the error's source frame in most cases.
if (this[_defaultFlag] && this[_flags] === 'r+') {
try {
fd = fs_1.default.openSync(this[_path], this[_flags], this[_mode]);
}
catch (er) {
if (er?.code === 'ENOENT') {
this[_flags] = 'w';
return this[_open]();
}
else {
throw er;
}
}
}
else {
fd = fs_1.default.openSync(this[_path], this[_flags], this[_mode]);
}
this[_onopen](null, fd);
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs_1.default.closeSync(fd);
this.emit('close');
}
}
[_write](buf) {
// throw the original, but try to close if it fails
let threw = true;
try {
this[_onwrite](null, fs_1.default.writeSync(this[_fd], buf, 0, buf.length, this[_pos]));
threw = false;
}
finally {
if (threw) {
try {
this[_close]();
}
catch {
// ok error
}
}
}
}
}
exports.WriteStreamSync = WriteStreamSync;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
{
"type": "commonjs"
}

118
node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,118 @@
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import EE from 'events';
import { Minipass } from 'minipass';
declare const _autoClose: unique symbol;
declare const _close: unique symbol;
declare const _ended: unique symbol;
declare const _fd: unique symbol;
declare const _finished: unique symbol;
declare const _flags: unique symbol;
declare const _flush: unique symbol;
declare const _handleChunk: unique symbol;
declare const _makeBuf: unique symbol;
declare const _mode: unique symbol;
declare const _needDrain: unique symbol;
declare const _onerror: unique symbol;
declare const _onopen: unique symbol;
declare const _onread: unique symbol;
declare const _onwrite: unique symbol;
declare const _open: unique symbol;
declare const _path: unique symbol;
declare const _pos: unique symbol;
declare const _queue: unique symbol;
declare const _read: unique symbol;
declare const _readSize: unique symbol;
declare const _reading: unique symbol;
declare const _remain: unique symbol;
declare const _size: unique symbol;
declare const _write: unique symbol;
declare const _writing: unique symbol;
declare const _defaultFlag: unique symbol;
declare const _errored: unique symbol;
export type ReadStreamOptions = Minipass.Options<Minipass.ContiguousData> & {
fd?: number;
readSize?: number;
size?: number;
autoClose?: boolean;
};
export type ReadStreamEvents = Minipass.Events<Minipass.ContiguousData> & {
open: [fd: number];
};
export declare class ReadStream extends Minipass<Minipass.ContiguousData, Buffer, ReadStreamEvents> {
[_errored]: boolean;
[_fd]?: number;
[_path]: string;
[_readSize]: number;
[_reading]: boolean;
[_size]: number;
[_remain]: number;
[_autoClose]: boolean;
constructor(path: string, opt: ReadStreamOptions);
get fd(): number | undefined;
get path(): string;
write(): void;
end(): void;
[_open](): void;
[_onopen](er?: NodeJS.ErrnoException | null, fd?: number): void;
[_makeBuf](): Buffer;
[_read](): void;
[_onread](er?: NodeJS.ErrnoException | null, br?: number, buf?: Buffer): void;
[_close](): void;
[_onerror](er: NodeJS.ErrnoException): void;
[_handleChunk](br: number, buf: Buffer): boolean;
emit<Event extends keyof ReadStreamEvents>(ev: Event, ...args: ReadStreamEvents[Event]): boolean;
}
export declare class ReadStreamSync extends ReadStream {
[_open](): void;
[_read](): void;
[_close](): void;
}
export type WriteStreamOptions = {
fd?: number;
autoClose?: boolean;
mode?: number;
captureRejections?: boolean;
start?: number;
flags?: string;
};
export declare class WriteStream extends EE {
readable: false;
writable: boolean;
[_errored]: boolean;
[_writing]: boolean;
[_ended]: boolean;
[_queue]: Buffer[];
[_needDrain]: boolean;
[_path]: string;
[_mode]: number;
[_autoClose]: boolean;
[_fd]?: number;
[_defaultFlag]: boolean;
[_flags]: string;
[_finished]: boolean;
[_pos]?: number;
constructor(path: string, opt: WriteStreamOptions);
emit(ev: string, ...args: any[]): boolean;
get fd(): number | undefined;
get path(): string;
[_onerror](er: NodeJS.ErrnoException): void;
[_open](): void;
[_onopen](er?: null | NodeJS.ErrnoException, fd?: number): void;
end(buf: string, enc?: BufferEncoding): this;
end(buf?: Buffer, enc?: undefined): this;
write(buf: string, enc?: BufferEncoding): boolean;
write(buf: Buffer, enc?: undefined): boolean;
[_write](buf: Buffer): void;
[_onwrite](er?: null | NodeJS.ErrnoException, bw?: number): void;
[_flush](): void;
[_close](): void;
}
export declare class WriteStreamSync extends WriteStream {
[_open](): void;
[_close](): void;
[_write](buf: Buffer): void;
}
export {};
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAInC,QAAA,MAAM,UAAU,eAAuB,CAAA;AACvC,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,GAAG,eAAgB,CAAA;AACzB,QAAA,MAAM,SAAS,eAAsB,CAAA;AACrC,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,MAAM,eAAmB,CAAA;AAC/B,QAAA,MAAM,YAAY,eAAyB,CAAA;AAC3C,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,UAAU,eAAuB,CAAA;AACvC,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,OAAO,eAAoB,CAAA;AACjC,QAAA,MAAM,OAAO,eAAoB,CAAA;AACjC,QAAA,MAAM,QAAQ,eAAqB,CAAA;AACnC,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,KAAK,eAAkB,CAAA;AAC7B,QAAA,MAAM,IAAI,eAAiB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,GAAG,OAAO;IAsB5C,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM;IAWpB,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,cAAc,EAAE,EAAE,CAAC,EAAE,MAAM;IAwBzD,CAAC,MAAM,CAAC;IAgBR,CAAC,MAAM,CAAC;CAST;AAED,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,CAAC,KAAK,CAAC,IAAI,IAAI;IAsBf,CAAC,MAAM,CAAC;IASR,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM;CAmBrB"}

420
node_modules/@isaacs/fs-minipass/dist/esm/index.js generated vendored Normal file
View File

@ -0,0 +1,420 @@
import EE from 'events';
import fs from 'fs';
import { Minipass } from 'minipass';
const writev = fs.writev;
const _autoClose = Symbol('_autoClose');
const _close = Symbol('_close');
const _ended = Symbol('_ended');
const _fd = Symbol('_fd');
const _finished = Symbol('_finished');
const _flags = Symbol('_flags');
const _flush = Symbol('_flush');
const _handleChunk = Symbol('_handleChunk');
const _makeBuf = Symbol('_makeBuf');
const _mode = Symbol('_mode');
const _needDrain = Symbol('_needDrain');
const _onerror = Symbol('_onerror');
const _onopen = Symbol('_onopen');
const _onread = Symbol('_onread');
const _onwrite = Symbol('_onwrite');
const _open = Symbol('_open');
const _path = Symbol('_path');
const _pos = Symbol('_pos');
const _queue = Symbol('_queue');
const _read = Symbol('_read');
const _readSize = Symbol('_readSize');
const _reading = Symbol('_reading');
const _remain = Symbol('_remain');
const _size = Symbol('_size');
const _write = Symbol('_write');
const _writing = Symbol('_writing');
const _defaultFlag = Symbol('_defaultFlag');
const _errored = Symbol('_errored');
export class ReadStream extends Minipass {
[_errored] = false;
[_fd];
[_path];
[_readSize];
[_reading] = false;
[_size];
[_remain];
[_autoClose];
constructor(path, opt) {
opt = opt || {};
super(opt);
this.readable = true;
this.writable = false;
if (typeof path !== 'string') {
throw new TypeError('path must be a string');
}
this[_errored] = false;
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
this[_path] = path;
this[_readSize] = opt.readSize || 16 * 1024 * 1024;
this[_reading] = false;
this[_size] = typeof opt.size === 'number' ? opt.size : Infinity;
this[_remain] = this[_size];
this[_autoClose] =
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
if (typeof this[_fd] === 'number') {
this[_read]();
}
else {
this[_open]();
}
}
get fd() {
return this[_fd];
}
get path() {
return this[_path];
}
//@ts-ignore
write() {
throw new TypeError('this is a readable stream');
}
//@ts-ignore
end() {
throw new TypeError('this is a readable stream');
}
[_open]() {
fs.open(this[_path], 'r', (er, fd) => this[_onopen](er, fd));
}
[_onopen](er, fd) {
if (er) {
this[_onerror](er);
}
else {
this[_fd] = fd;
this.emit('open', fd);
this[_read]();
}
}
[_makeBuf]() {
return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]));
}
[_read]() {
if (!this[_reading]) {
this[_reading] = true;
const buf = this[_makeBuf]();
/* c8 ignore start */
if (buf.length === 0) {
return process.nextTick(() => this[_onread](null, 0, buf));
}
/* c8 ignore stop */
fs.read(this[_fd], buf, 0, buf.length, null, (er, br, b) => this[_onread](er, br, b));
}
}
[_onread](er, br, buf) {
this[_reading] = false;
if (er) {
this[_onerror](er);
}
else if (this[_handleChunk](br, buf)) {
this[_read]();
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
}
}
[_onerror](er) {
this[_reading] = true;
this[_close]();
this.emit('error', er);
}
[_handleChunk](br, buf) {
let ret = false;
// no effect if infinite
this[_remain] -= br;
if (br > 0) {
ret = super.write(br < buf.length ? buf.subarray(0, br) : buf);
}
if (br === 0 || this[_remain] <= 0) {
ret = false;
this[_close]();
super.end();
}
return ret;
}
emit(ev, ...args) {
switch (ev) {
case 'prefinish':
case 'finish':
return false;
case 'drain':
if (typeof this[_fd] === 'number') {
this[_read]();
}
return false;
case 'error':
if (this[_errored]) {
return false;
}
this[_errored] = true;
return super.emit(ev, ...args);
default:
return super.emit(ev, ...args);
}
}
}
export class ReadStreamSync extends ReadStream {
[_open]() {
let threw = true;
try {
this[_onopen](null, fs.openSync(this[_path], 'r'));
threw = false;
}
finally {
if (threw) {
this[_close]();
}
}
}
[_read]() {
let threw = true;
try {
if (!this[_reading]) {
this[_reading] = true;
do {
const buf = this[_makeBuf]();
/* c8 ignore start */
const br = buf.length === 0
? 0
: fs.readSync(this[_fd], buf, 0, buf.length, null);
/* c8 ignore stop */
if (!this[_handleChunk](br, buf)) {
break;
}
} while (true);
this[_reading] = false;
}
threw = false;
}
finally {
if (threw) {
this[_close]();
}
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs.closeSync(fd);
this.emit('close');
}
}
}
export class WriteStream extends EE {
readable = false;
writable = true;
[_errored] = false;
[_writing] = false;
[_ended] = false;
[_queue] = [];
[_needDrain] = false;
[_path];
[_mode];
[_autoClose];
[_fd];
[_defaultFlag];
[_flags];
[_finished] = false;
[_pos];
constructor(path, opt) {
opt = opt || {};
super(opt);
this[_path] = path;
this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined;
this[_mode] = opt.mode === undefined ? 0o666 : opt.mode;
this[_pos] = typeof opt.start === 'number' ? opt.start : undefined;
this[_autoClose] =
typeof opt.autoClose === 'boolean' ? opt.autoClose : true;
// truncating makes no sense when writing into the middle
const defaultFlag = this[_pos] !== undefined ? 'r+' : 'w';
this[_defaultFlag] = opt.flags === undefined;
this[_flags] = opt.flags === undefined ? defaultFlag : opt.flags;
if (this[_fd] === undefined) {
this[_open]();
}
}
emit(ev, ...args) {
if (ev === 'error') {
if (this[_errored]) {
return false;
}
this[_errored] = true;
}
return super.emit(ev, ...args);
}
get fd() {
return this[_fd];
}
get path() {
return this[_path];
}
[_onerror](er) {
this[_close]();
this[_writing] = true;
this.emit('error', er);
}
[_open]() {
fs.open(this[_path], this[_flags], this[_mode], (er, fd) => this[_onopen](er, fd));
}
[_onopen](er, fd) {
if (this[_defaultFlag] &&
this[_flags] === 'r+' &&
er &&
er.code === 'ENOENT') {
this[_flags] = 'w';
this[_open]();
}
else if (er) {
this[_onerror](er);
}
else {
this[_fd] = fd;
this.emit('open', fd);
if (!this[_writing]) {
this[_flush]();
}
}
}
end(buf, enc) {
if (buf) {
//@ts-ignore
this.write(buf, enc);
}
this[_ended] = true;
// synthetic after-write logic, where drain/finish live
if (!this[_writing] &&
!this[_queue].length &&
typeof this[_fd] === 'number') {
this[_onwrite](null, 0);
}
return this;
}
write(buf, enc) {
if (typeof buf === 'string') {
buf = Buffer.from(buf, enc);
}
if (this[_ended]) {
this.emit('error', new Error('write() after end()'));
return false;
}
if (this[_fd] === undefined || this[_writing] || this[_queue].length) {
this[_queue].push(buf);
this[_needDrain] = true;
return false;
}
this[_writing] = true;
this[_write](buf);
return true;
}
[_write](buf) {
fs.write(this[_fd], buf, 0, buf.length, this[_pos], (er, bw) => this[_onwrite](er, bw));
}
[_onwrite](er, bw) {
if (er) {
this[_onerror](er);
}
else {
if (this[_pos] !== undefined && typeof bw === 'number') {
this[_pos] += bw;
}
if (this[_queue].length) {
this[_flush]();
}
else {
this[_writing] = false;
if (this[_ended] && !this[_finished]) {
this[_finished] = true;
this[_close]();
this.emit('finish');
}
else if (this[_needDrain]) {
this[_needDrain] = false;
this.emit('drain');
}
}
}
}
[_flush]() {
if (this[_queue].length === 0) {
if (this[_ended]) {
this[_onwrite](null, 0);
}
}
else if (this[_queue].length === 1) {
this[_write](this[_queue].pop());
}
else {
const iovec = this[_queue];
this[_queue] = [];
writev(this[_fd], iovec, this[_pos], (er, bw) => this[_onwrite](er, bw));
}
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs.close(fd, er => er ? this.emit('error', er) : this.emit('close'));
}
}
}
export class WriteStreamSync extends WriteStream {
[_open]() {
let fd;
// only wrap in a try{} block if we know we'll retry, to avoid
// the rethrow obscuring the error's source frame in most cases.
if (this[_defaultFlag] && this[_flags] === 'r+') {
try {
fd = fs.openSync(this[_path], this[_flags], this[_mode]);
}
catch (er) {
if (er?.code === 'ENOENT') {
this[_flags] = 'w';
return this[_open]();
}
else {
throw er;
}
}
}
else {
fd = fs.openSync(this[_path], this[_flags], this[_mode]);
}
this[_onopen](null, fd);
}
[_close]() {
if (this[_autoClose] && typeof this[_fd] === 'number') {
const fd = this[_fd];
this[_fd] = undefined;
fs.closeSync(fd);
this.emit('close');
}
}
[_write](buf) {
// throw the original, but try to close if it fails
let threw = true;
try {
this[_onwrite](null, fs.writeSync(this[_fd], buf, 0, buf.length, this[_pos]));
threw = false;
}
finally {
if (threw) {
try {
this[_close]();
}
catch {
// ok error
}
}
}
}
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
{
"type": "module"
}

72
node_modules/@isaacs/fs-minipass/package.json generated vendored Normal file
View File

@ -0,0 +1,72 @@
{
"name": "@isaacs/fs-minipass",
"version": "4.0.1",
"main": "./dist/commonjs/index.js",
"scripts": {
"prepare": "tshy",
"pretest": "npm run prepare",
"test": "tap",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"format": "prettier --write . --loglevel warn",
"typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
},
"keywords": [],
"author": "Isaac Z. Schlueter",
"license": "ISC",
"repository": {
"type": "git",
"url": "https://github.com/npm/fs-minipass.git"
},
"description": "fs read and write streams based on minipass",
"dependencies": {
"minipass": "^7.0.4"
},
"devDependencies": {
"@types/node": "^20.11.30",
"mutate-fs": "^2.1.1",
"prettier": "^3.2.5",
"tap": "^18.7.1",
"tshy": "^1.12.0",
"typedoc": "^0.25.12"
},
"files": [
"dist"
],
"engines": {
"node": ">=18.0.0"
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"types": "./dist/commonjs/index.d.ts",
"type": "module",
"prettier": {
"semi": false,
"printWidth": 75,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"jsxSingleQuote": false,
"bracketSameLine": true,
"arrowParens": "avoid",
"endOfLine": "lf"
}
}

135
node_modules/@supabase/ssr/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,135 @@
# @supabase/ssr
## [0.6.1](https://github.com/supabase/ssr/compare/v0.6.0...v0.6.1) (2025-03-16)
### Bug Fixes
* force release ([#98](https://github.com/supabase/ssr/issues/98)) ([66710e8](https://github.com/supabase/ssr/commit/66710e82aab5106f464e6754f2e75641a951c941))
* **revert:** "feat: improve cookie chunk handling via base64url+length encoding ([#90](https://github.com/supabase/ssr/issues/90))" ([#100](https://github.com/supabase/ssr/issues/100)) ([2ea8e23](https://github.com/supabase/ssr/commit/2ea8e23525f7e36e88bca3f9ae1fbce892c683e4))
## [0.5.2](https://github.com/supabase/ssr/compare/v0.5.1...v0.5.2) (2024-11-05)
### Bug Fixes
* add @types/cookies to dependencies ([#63](https://github.com/supabase/ssr/issues/63)) ([47e5f16](https://github.com/supabase/ssr/commit/47e5f16b48e4ffbe889339410f50630aba734eac))
* check chunkedCookie is string in server client ([#57](https://github.com/supabase/ssr/issues/57)) ([549fe62](https://github.com/supabase/ssr/commit/549fe62813fb9c7277f7eda9e46ee0420f8e0b5f))
* update type, remove unused imports, define AuthEvent type ([#47](https://github.com/supabase/ssr/issues/47)) ([4f4a375](https://github.com/supabase/ssr/commit/4f4a375ab3df0274980718b7ad98cd4841a52cc4))
## [0.5.1](https://github.com/supabase/ssr/compare/v0.5.0...v0.5.1) (2024-08-28)
### Bug Fixes
* remove optional dependencies ([#41](https://github.com/supabase/ssr/issues/41)) ([a48fe6f](https://github.com/supabase/ssr/commit/a48fe6fd9754786d0ec673ff1418b833a8cfbc70))
* set `max-age` default cookie option to 400 days ([#54](https://github.com/supabase/ssr/issues/54)) ([f4ed2e0](https://github.com/supabase/ssr/commit/f4ed2e0a29445781857c4526f84673693ca9679c))
## [0.5.0](https://github.com/supabase/ssr/compare/v0.4.0...v0.5.0) (2024-08-19)
### Features
* update CI so it runs on release as well ([#33](https://github.com/supabase/ssr/issues/33)) ([4517996](https://github.com/supabase/ssr/commit/4517996a4eea6d41b8ad07c769c78a10b9ee63aa))
### Bug Fixes
* re-apply update CI so it runs on release as well ([#49](https://github.com/supabase/ssr/issues/49)) ([51d5a43](https://github.com/supabase/ssr/commit/51d5a43e2300f46560dc22c67c61f95a6b8d1b3b))
* revert "update CI so it runs on release as well" ([#44](https://github.com/supabase/ssr/issues/44)) ([9d0e859](https://github.com/supabase/ssr/commit/9d0e859cb18b7669f452bc955c6d1c4897873f93))
* set cookies for password recovery event ([#32](https://github.com/supabase/ssr/issues/32)) ([7dc1837](https://github.com/supabase/ssr/commit/7dc1837dc4aba870b32792586969316df980ce07))
* set cookies when mfa challenge is verified ([#27](https://github.com/supabase/ssr/issues/27)) ([c217f53](https://github.com/supabase/ssr/commit/c217f5392b17a80a8e30709445c239e860a107d6))
* update conventional commits ci to use main instead of master ([#31](https://github.com/supabase/ssr/issues/31)) ([bebce89](https://github.com/supabase/ssr/commit/bebce8999d9b2ae554daa2aaffdaf37d972b7fe4))
## [0.4.0](https://github.com/supabase/ssr/compare/v0.3.0...v0.4.0) (2024-06-24)
### Features
- full rewrite using `getAll` and `setAll` cookie methods ([#1](https://github.com/supabase/ssr/issues/1)) ([b6ae192](https://github.com/supabase/ssr/commit/b6ae192aeb37ac6948637955cf1d3d6179b90065))
### Bug Fixes
- allow use of `createBrowserClient` without `window` present ([#20](https://github.com/supabase/ssr/issues/20)) ([27d868d](https://github.com/supabase/ssr/commit/27d868d530925805fe2f3577ae716ece40dd3ab6))
- deprecate `parse`, `serialize` exports for more useful functions ([#14](https://github.com/supabase/ssr/issues/14)) ([0b5f881](https://github.com/supabase/ssr/commit/0b5f881e90b7836f2b98b733aac1cc9f916286cb))
- fix `createBrowserClient` deprecation tsdoc ([#17](https://github.com/supabase/ssr/issues/17)) ([1df70ad](https://github.com/supabase/ssr/commit/1df70ad51e65caab46cbc00342dbb42f6d498c32))
## 0.3.0
### Minor Changes
- 8d85be4: fix custom cookie options in browser client
- 9e7ff76: upgrade supabase-js version to v2.42.0
## 0.2.0
### Minor Changes
- faf9eac: Miscellaneous fixes to createBrowserClient
## 0.1.0
### Minor Changes
- 18327fc: add isServer property to server-side storage adaptors
- 18327fc: fix cookie chunking length calculation
- 8ed42ff: use custom cookie name set
## 0.0.10
### Patch Changes
- 1e079c3: Set cookie default to httpOnly: false
## 0.0.9
### Patch Changes
- f7e5c2d: Revert cookie name to storage key change
## 0.0.8
### Patch Changes
- 5893215: Update storage key name with cookie name
## 0.0.7
### Patch Changes
- fc8ccfd: Reduce cookie chunk size
## 0.0.6
### Patch Changes
- 1c7f7e8: Implement cookie chunking
## 0.0.5
### Patch Changes
- 841fce0: Add cookie chunker methods and expose them to the SDK
## 0.0.4
### Patch Changes
- 4e5df45: Await get cookie function
## 0.0.3
### Patch Changes
- b9099fd: Fixed types for cookie methods
## 0.0.2
### Patch Changes
- 66e6b4c: Remove max-age option from cookieOptions
## 0.0.1
### Patch Changes
- 49f4043: The successor to the auth-helpers packages with sane defaults

21
node_modules/@supabase/ssr/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022-2023 Supabase, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

8
node_modules/@supabase/ssr/README.md generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Supabase clients for use in SSR frameworks
This package is useful for using the [Supabase JavaScript library](https://supabase.com/docs/reference/javascript/introduction) in
server-side rendering frameworks.
It provides a framework-agnostic way of creating a Supabase client.
Please refer to the [official server-side rendering guides](https://supabase.com/docs/guides/auth/server-side) for the latest best practices on using this package in your SSR framework of choice.

47
node_modules/@supabase/ssr/dist/main/cookies.d.ts generated vendored Normal file
View File

@ -0,0 +1,47 @@
import type { CookieMethodsServer, CookieMethodsServerDeprecated, CookieMethodsBrowser, CookieMethodsBrowserDeprecated, CookieOptions, CookieOptionsWithName, GetAllCookies, SetAllCookies } from "./types";
/**
* Creates a storage client that handles cookies correctly for browser and
* server clients with or without properly provided cookie methods.
*
* @param options The options passed to createBrowserClient or createServer client.
*
* @param isServerClient Whether it's called from createServerClient.
*/
export declare function createStorageFromOptions(options: {
cookieEncoding: "raw" | "base64url";
cookies?: CookieMethodsBrowser | CookieMethodsBrowserDeprecated | CookieMethodsServer | CookieMethodsServerDeprecated;
cookieOptions?: CookieOptionsWithName;
}, isServerClient: boolean): {
getAll: (keyHints: string[]) => ReturnType<GetAllCookies>;
setAll: SetAllCookies;
setItems: {
[key: string]: string;
};
removedItems: {
[key: string]: boolean;
};
storage: {
isServer: boolean;
getItem: (key: string) => Promise<string | null>;
setItem: (key: string, value: string) => Promise<void>;
removeItem: (key: string) => Promise<void>;
};
};
/**
* When createServerClient needs to apply the created storage to cookies, it
* should call this function which handles correcly setting cookies for stored
* and removed items in the storage.
*/
export declare function applyServerStorage({ getAll, setAll, setItems, removedItems, }: {
getAll: (keyHints: string[]) => ReturnType<GetAllCookies>;
setAll: SetAllCookies;
setItems: {
[name: string]: string;
};
removedItems: {
[name: string]: boolean;
};
}, options: {
cookieEncoding: "raw" | "base64url";
cookieOptions?: CookieOptions | null;
}): Promise<void>;

347
node_modules/@supabase/ssr/dist/main/cookies.js generated vendored Normal file
View File

@ -0,0 +1,347 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createStorageFromOptions = createStorageFromOptions;
exports.applyServerStorage = applyServerStorage;
const cookie_1 = require("cookie");
const utils_1 = require("./utils");
const BASE64_PREFIX = "base64-";
/**
* Creates a storage client that handles cookies correctly for browser and
* server clients with or without properly provided cookie methods.
*
* @param options The options passed to createBrowserClient or createServer client.
*
* @param isServerClient Whether it's called from createServerClient.
*/
function createStorageFromOptions(options, isServerClient) {
const cookies = options.cookies ?? null;
const cookieEncoding = options.cookieEncoding;
const setItems = {};
const removedItems = {};
let getAll;
let setAll;
if (cookies) {
if ("get" in cookies) {
// Just get is not enough, because the client needs to see what cookies
// are already set and unset them if necessary. To attempt to fix this
// behavior for most use cases, we pass "hints" which is the keys of the
// storage items. They are then converted to their corresponding cookie
// chunk names and are fetched with get. Only 5 chunks are fetched, which
// should be enough for the majority of use cases, but does not solve
// those with very large sessions.
const getWithHints = async (keyHints) => {
// optimistically find the first 5 potential chunks for the specified key
const chunkNames = keyHints.flatMap((keyHint) => [
keyHint,
...Array.from({ length: 5 }).map((_, i) => `${keyHint}.${i}`),
]);
const chunks = [];
for (let i = 0; i < chunkNames.length; i += 1) {
const value = await cookies.get(chunkNames[i]);
if (!value && typeof value !== "string") {
continue;
}
chunks.push({ name: chunkNames[i], value });
}
// TODO: detect and log stale chunks error
return chunks;
};
getAll = async (keyHints) => await getWithHints(keyHints);
if ("set" in cookies && "remove" in cookies) {
setAll = async (setCookies) => {
for (let i = 0; i < setCookies.length; i += 1) {
const { name, value, options } = setCookies[i];
if (value) {
await cookies.set(name, value, options);
}
else {
await cookies.remove(name, options);
}
}
};
}
else if (isServerClient) {
setAll = async () => {
console.warn("@supabase/ssr: createServerClient was configured without set and remove cookie methods, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness. Consider switching to the getAll and setAll cookie methods instead of get, set and remove which are deprecated and can be difficult to use correctly.");
};
}
else {
throw new Error("@supabase/ssr: createBrowserClient requires configuring a getAll and setAll cookie method (deprecated: alternatively both get, set and remove can be used)");
}
}
else if ("getAll" in cookies) {
getAll = async () => await cookies.getAll();
if ("setAll" in cookies) {
setAll = cookies.setAll;
}
else if (isServerClient) {
setAll = async () => {
console.warn("@supabase/ssr: createServerClient was configured without the setAll cookie method, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness.");
};
}
else {
throw new Error("@supabase/ssr: createBrowserClient requires configuring both getAll and setAll cookie methods (deprecated: alternatively both get, set and remove can be used)");
}
}
else {
// neither get nor getAll is present on cookies, only will occur if pure JavaScript is used, but cookies is an object
throw new Error(`@supabase/ssr: ${isServerClient ? "createServerClient" : "createBrowserClient"} requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).${(0, utils_1.isBrowser)() ? " As this is called in a browser runtime, consider removing the cookies option object to use the document.cookie API automatically." : ""}`);
}
}
else if (!isServerClient && (0, utils_1.isBrowser)()) {
// The environment is browser, so use the document.cookie API to implement getAll and setAll.
const noHintGetAll = () => {
const parsed = (0, cookie_1.parse)(document.cookie);
return Object.keys(parsed).map((name) => ({
name,
value: parsed[name] ?? "",
}));
};
getAll = () => noHintGetAll();
setAll = (setCookies) => {
setCookies.forEach(({ name, value, options }) => {
document.cookie = (0, cookie_1.serialize)(name, value, options);
});
};
}
else if (isServerClient) {
throw new Error("@supabase/ssr: createServerClient must be initialized with cookie options that specify getAll and setAll functions (deprecated, not recommended: alternatively use get, set and remove)");
}
else {
// getting cookies when there's no window but we're in browser mode can be OK, because the developer probably is not using auth functions
getAll = () => {
return [];
};
// this is NOT OK because the developer is using auth functions that require setting some state, so that must error out
setAll = () => {
throw new Error("@supabase/ssr: createBrowserClient in non-browser runtimes (including Next.js pre-rendering mode) was not initialized cookie options that specify getAll and setAll functions (deprecated: alternatively use get, set and remove), but they were needed");
};
}
if (!isServerClient) {
// This is the storage client to be used in browsers. It only
// works on the cookies abstraction, unlike the server client
// which only uses cookies to read the initial state. When an
// item is set, cookies are both cleared and set to values so
// that stale chunks are not left remaining.
return {
getAll, // for type consistency
setAll, // for type consistency
setItems, // for type consistency
removedItems, // for type consistency
storage: {
isServer: false,
getItem: async (key) => {
const allCookies = await getAll([key]);
const chunkedCookie = await (0, utils_1.combineChunks)(key, async (chunkName) => {
const cookie = allCookies?.find(({ name }) => name === chunkName) || null;
if (!cookie) {
return null;
}
return cookie.value;
});
if (!chunkedCookie) {
return null;
}
let decoded = chunkedCookie;
if (chunkedCookie.startsWith(BASE64_PREFIX)) {
decoded = (0, utils_1.stringFromBase64URL)(chunkedCookie.substring(BASE64_PREFIX.length));
}
return decoded;
},
setItem: async (key, value) => {
const allCookies = await getAll([key]);
const cookieNames = allCookies?.map(({ name }) => name) || [];
const removeCookies = new Set(cookieNames.filter((name) => (0, utils_1.isChunkLike)(name, key)));
let encoded = value;
if (cookieEncoding === "base64url") {
encoded = BASE64_PREFIX + (0, utils_1.stringToBase64URL)(value);
}
const setCookies = (0, utils_1.createChunks)(key, encoded);
setCookies.forEach(({ name }) => {
removeCookies.delete(name);
});
const removeCookieOptions = {
...utils_1.DEFAULT_COOKIE_OPTIONS,
...options?.cookieOptions,
maxAge: 0,
};
const setCookieOptions = {
...utils_1.DEFAULT_COOKIE_OPTIONS,
...options?.cookieOptions,
maxAge: utils_1.DEFAULT_COOKIE_OPTIONS.maxAge,
};
// the NextJS cookieStore API can get confused if the `name` from
// options.cookieOptions leaks
delete removeCookieOptions.name;
delete setCookieOptions.name;
const allToSet = [
...[...removeCookies].map((name) => ({
name,
value: "",
options: removeCookieOptions,
})),
...setCookies.map(({ name, value }) => ({
name,
value,
options: setCookieOptions,
})),
];
if (allToSet.length > 0) {
await setAll(allToSet);
}
},
removeItem: async (key) => {
const allCookies = await getAll([key]);
const cookieNames = allCookies?.map(({ name }) => name) || [];
const removeCookies = cookieNames.filter((name) => (0, utils_1.isChunkLike)(name, key));
const removeCookieOptions = {
...utils_1.DEFAULT_COOKIE_OPTIONS,
...options?.cookieOptions,
maxAge: 0,
};
// the NextJS cookieStore API can get confused if the `name` from
// options.cookieOptions leaks
delete removeCookieOptions.name;
if (removeCookies.length > 0) {
await setAll(removeCookies.map((name) => ({
name,
value: "",
options: removeCookieOptions,
})));
}
},
},
};
}
// This is the server client. It only uses getAll to read the initial
// state. Any subsequent changes to the items is persisted in the
// setItems and removedItems objects. createServerClient *must* use
// getAll, setAll and the values in setItems and removedItems to
// persist the changes *at once* when appropriate (usually only when
// the TOKEN_REFRESHED, USER_UPDATED or SIGNED_OUT events are fired by
// the Supabase Auth client).
return {
getAll,
setAll,
setItems,
removedItems,
storage: {
// to signal to the libraries that these cookies are
// coming from a server environment and their value
// should not be trusted
isServer: true,
getItem: async (key) => {
if (typeof setItems[key] === "string") {
return setItems[key];
}
if (removedItems[key]) {
return null;
}
const allCookies = await getAll([key]);
const chunkedCookie = await (0, utils_1.combineChunks)(key, async (chunkName) => {
const cookie = allCookies?.find(({ name }) => name === chunkName) || null;
if (!cookie) {
return null;
}
return cookie.value;
});
if (!chunkedCookie) {
return null;
}
let decoded = chunkedCookie;
if (typeof chunkedCookie === "string" &&
chunkedCookie.startsWith(BASE64_PREFIX)) {
decoded = (0, utils_1.stringFromBase64URL)(chunkedCookie.substring(BASE64_PREFIX.length));
}
return decoded;
},
setItem: async (key, value) => {
// We don't have an `onAuthStateChange` event that can let us know that
// the PKCE code verifier is being set. Therefore, if we see it being
// set, we need to apply the storage (call `setAll` so the cookie is
// set properly).
if (key.endsWith("-code-verifier")) {
await applyServerStorage({
getAll,
setAll,
// pretend only that the code verifier was set
setItems: { [key]: value },
// pretend that nothing was removed
removedItems: {},
}, {
cookieOptions: options?.cookieOptions ?? null,
cookieEncoding,
});
}
setItems[key] = value;
delete removedItems[key];
},
removeItem: async (key) => {
// Intentionally not applying the storage when the key is the PKCE code
// verifier, as usually right after it's removed other items are set,
// so application of the storage will be handled by the
// `onAuthStateChange` callback that follows removal -- usually as part
// of the `exchangeCodeForSession` call.
delete setItems[key];
removedItems[key] = true;
},
},
};
}
/**
* When createServerClient needs to apply the created storage to cookies, it
* should call this function which handles correcly setting cookies for stored
* and removed items in the storage.
*/
async function applyServerStorage({ getAll, setAll, setItems, removedItems, }, options) {
const cookieEncoding = options.cookieEncoding;
const cookieOptions = options.cookieOptions ?? null;
const allCookies = await getAll([
...(setItems ? Object.keys(setItems) : []),
...(removedItems ? Object.keys(removedItems) : []),
]);
const cookieNames = allCookies?.map(({ name }) => name) || [];
const removeCookies = Object.keys(removedItems).flatMap((itemName) => {
return cookieNames.filter((name) => (0, utils_1.isChunkLike)(name, itemName));
});
const setCookies = Object.keys(setItems).flatMap((itemName) => {
const removeExistingCookiesForItem = new Set(cookieNames.filter((name) => (0, utils_1.isChunkLike)(name, itemName)));
let encoded = setItems[itemName];
if (cookieEncoding === "base64url") {
encoded = BASE64_PREFIX + (0, utils_1.stringToBase64URL)(encoded);
}
const chunks = (0, utils_1.createChunks)(itemName, encoded);
chunks.forEach((chunk) => {
removeExistingCookiesForItem.delete(chunk.name);
});
removeCookies.push(...removeExistingCookiesForItem);
return chunks;
});
const removeCookieOptions = {
...utils_1.DEFAULT_COOKIE_OPTIONS,
...cookieOptions,
maxAge: 0,
};
const setCookieOptions = {
...utils_1.DEFAULT_COOKIE_OPTIONS,
...cookieOptions,
maxAge: utils_1.DEFAULT_COOKIE_OPTIONS.maxAge,
};
// the NextJS cookieStore API can get confused if the `name` from
// options.cookieOptions leaks
delete removeCookieOptions.name;
delete setCookieOptions.name;
await setAll([
...removeCookies.map((name) => ({
name,
value: "",
options: removeCookieOptions,
})),
...setCookies.map(({ name, value }) => ({
name,
value,
options: setCookieOptions,
})),
]);
}
//# sourceMappingURL=cookies.js.map

1
node_modules/@supabase/ssr/dist/main/cookies.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,37 @@
import { SupabaseClient } from "@supabase/supabase-js";
import type { GenericSchema, SupabaseClientOptions } from "@supabase/supabase-js/dist/module/lib/types";
import type { CookieMethodsBrowser, CookieMethodsBrowserDeprecated, CookieOptionsWithName } from "./types";
/**
* Creates a Supabase Client for use in a browser environment.
*
* In most cases you should not configure the `options.cookies` object, as this
* is automatically handled for you. If you do customize this, prefer using the
* `getAll` and `setAll` functions over `get`, `set` and `remove`. The latter
* are deprecated due to being difficult to correctly implement and not
* supporting some edge-cases. Both `getAll` and `setAll` (or both `get`, `set`
* and `remove`) must be provided. Failing to provide the methods for setting
* will throw an exception, and in previous versions of the library will result
* in difficult to debug authentication issues such as random logouts, early
* session termination or problems with inconsistent state.
*
* @param supabaseUrl The URL of the Supabase project.
* @param supabaseKey The `anon` API key of the Supabase project.
* @param options Various configuration options.
*/
export declare function createBrowserClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName> & {
cookies?: CookieMethodsBrowser;
cookieOptions?: CookieOptionsWithName;
cookieEncoding?: "raw" | "base64url";
isSingleton?: boolean;
}): SupabaseClient<Database, SchemaName, Schema>;
/**
* @deprecated Please specify `getAll` and `setAll` cookie methods instead of
* the `get`, `set` and `remove`. These will not be supported in the next major
* version.
*/
export declare function createBrowserClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName> & {
cookies: CookieMethodsBrowserDeprecated;
cookieOptions?: CookieOptionsWithName;
cookieEncoding?: "raw" | "base64url";
isSingleton?: boolean;
}): SupabaseClient<Database, SchemaName, Schema>;

View File

@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createBrowserClient = createBrowserClient;
const supabase_js_1 = require("@supabase/supabase-js");
const version_1 = require("./version");
const utils_1 = require("./utils");
const cookies_1 = require("./cookies");
let cachedBrowserClient;
function createBrowserClient(supabaseUrl, supabaseKey, options) {
// singleton client is created only if isSingleton is set to true, or if isSingleton is not defined and we detect a browser
const shouldUseSingleton = options?.isSingleton === true ||
((!options || !("isSingleton" in options)) && (0, utils_1.isBrowser)());
if (shouldUseSingleton && cachedBrowserClient) {
return cachedBrowserClient;
}
if (!supabaseUrl || !supabaseKey) {
throw new Error(`@supabase/ssr: Your project's URL and API key are required to create a Supabase client!\n\nCheck your Supabase project's API settings to find these values\n\nhttps://supabase.com/dashboard/project/_/settings/api`);
}
const { storage } = (0, cookies_1.createStorageFromOptions)({
...options,
cookieEncoding: options?.cookieEncoding ?? "base64url",
}, false);
const client = (0, supabase_js_1.createClient)(supabaseUrl, supabaseKey, {
...options,
global: {
...options?.global,
headers: {
...options?.global?.headers,
"X-Client-Info": `supabase-ssr/${version_1.VERSION} createBrowserClient`,
},
},
auth: {
...options?.auth,
...(options?.cookieOptions?.name
? { storageKey: options.cookieOptions.name }
: null),
flowType: "pkce",
autoRefreshToken: (0, utils_1.isBrowser)(),
detectSessionInUrl: (0, utils_1.isBrowser)(),
persistSession: true,
storage,
},
});
if (shouldUseSingleton) {
cachedBrowserClient = client;
}
return client;
}
//# sourceMappingURL=createBrowserClient.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"createBrowserClient.js","sourceRoot":"","s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,IAAA,iBAAS,GAAE;YAC7B,kBAAkB,EAAE,IAAA,iBAAS,GAAE;YAC/B,cAAc,EAAE,IAAI;YACpB,OAAO;SACR;KACF,CACF,CAAC;IAEF,IAAI,kBAAkB,EAAE,CAAC;QACvB,mBAAmB,GAAG,MAAM,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,79 @@
import { SupabaseClient } from "@supabase/supabase-js";
import type { GenericSchema, SupabaseClientOptions } from "@supabase/supabase-js/dist/module/lib/types";
import type { CookieOptionsWithName, CookieMethodsServer, CookieMethodsServerDeprecated } from "./types";
/**
* @deprecated Please specify `getAll` and `setAll` cookie methods instead of
* the `get`, `set` and `remove`. These will not be supported in the next major
* version.
*/
export declare function createServerClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options: SupabaseClientOptions<SchemaName> & {
cookieOptions?: CookieOptionsWithName;
cookies: CookieMethodsServerDeprecated;
cookieEncoding?: "raw" | "base64url";
}): SupabaseClient<Database, SchemaName, Schema>;
/**
* Creates a Supabase Client for use on the server-side of a server-side
* rendering (SSR) framework.
*
* There are two categories of uses for this function: use in middlewares and
* use in pages, components or routes.
*
* **Use in middlewares.**
*
* Middlewares are functions that run before any rendering logic is executed on
* the server-side. They typically have access to request headers (cookies) and
* can modify both the request and response headers.
*
* In most SSR frameworks, to use Supabase correctly you *must set up a
* middleware* and use this function in it.
*
* When using this in a middleware, the `cookie` option must be configured to
* use both `getAll` and `setAll`. Alternatively you can use the `get`, `set`
* and `remove` functions. The latter are deprecated **and not recommended**
* for most use cases due to being difficult to use properly and they do not
* cover important edge cases. In future major versions of the library, the
* option to configure `get`, `set` and `remove` will be removed.
*
* **IMPORTANT:** Failing to implement `getAll` and `setAll` correctly (or the
* deprecated `get`, `set` and `remove`) including omitting them **will cause
* significant and difficult to debug authentication issues**. They will
* manifest as: random logouts, early session termination, JSON parsing errors,
* increased number of refresh token requests, or relying on garbage state.
*
* **Use in pages, components or routes.**
*
* To use Supabase features server-side rendered in pages, components or routes
* (a.k.a. actions / APIs) you must create a client with this function. Not all
* frameworks allow the ability to set cookies or response headers when pages
* or components are rendered. In those cases you _can omit `setAll` (or the
* deprecated `set`, `remove`) cookie option methods_. **It is strongly
* recommended that if the ability to set cookies and response headers is
* present, you should configure the `setAll` (or the deprecated `set` and
* `remove`) cookie access methods.**
*
* **IMPORTANT:** If the ability to set cookies or response headers is not
* available **middleware or an equivalent must be used.** Failing to do this
* will cause significant and difficult to debug authentication issues.
*
* When `setAll` (or the deprecated `set`, `remove`) cookie methods are not
* configured, the Supabase Client will emit a warning if it is used in a way
* that requires setting cookies. If you see this warning, it usually means
* that you are using the Supabase Client in a wrong way:
*
* - You should have, but did not configure a middleware client.
* - There is a bug in your middleware function.
* - You are using features of the Supabase Client that change the User, e.g.
* by calling `supabase.auth.updateUser()` on the server.
*
* Please consult the latest Supabase guides for advice on how to avoid common
* pitfalls depending on SSR framework.
*
* @param supabaseUrl The URL of the Supabase project.
* @param supabaseKey The `anon` API key of the Supabase project.
* @param options Various configuration options.
*/
export declare function createServerClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options: SupabaseClientOptions<SchemaName> & {
cookieOptions?: CookieOptionsWithName;
cookies: CookieMethodsServer;
cookieEncoding?: "raw" | "base64url";
}): SupabaseClient<Database, SchemaName, Schema>;

View File

@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createServerClient = createServerClient;
const supabase_js_1 = require("@supabase/supabase-js");
const version_1 = require("./version");
const cookies_1 = require("./cookies");
function createServerClient(supabaseUrl, supabaseKey, options) {
if (!supabaseUrl || !supabaseKey) {
throw new Error(`Your project's URL and Key are required to create a Supabase client!\n\nCheck your Supabase project's API settings to find these values\n\nhttps://supabase.com/dashboard/project/_/settings/api`);
}
const { storage, getAll, setAll, setItems, removedItems } = (0, cookies_1.createStorageFromOptions)({
...options,
cookieEncoding: options?.cookieEncoding ?? "base64url",
}, true);
const client = (0, supabase_js_1.createClient)(supabaseUrl, supabaseKey, {
...options,
global: {
...options?.global,
headers: {
...options?.global?.headers,
"X-Client-Info": `supabase-ssr/${version_1.VERSION} createServerClient`,
},
},
auth: {
...(options?.cookieOptions?.name
? { storageKey: options.cookieOptions.name }
: null),
...options?.auth,
flowType: "pkce",
autoRefreshToken: false,
detectSessionInUrl: false,
persistSession: true,
storage,
},
});
client.auth.onAuthStateChange(async (event) => {
// The SIGNED_IN event is fired very often, but we don't need to
// apply the storage each time it fires, only if there are changes
// that need to be set -- which is if setItems / removeItems have
// data.
const hasStorageChanges = Object.keys(setItems).length > 0 || Object.keys(removedItems).length > 0;
if (hasStorageChanges &&
(event === "SIGNED_IN" ||
event === "TOKEN_REFRESHED" ||
event === "USER_UPDATED" ||
event === "PASSWORD_RECOVERY" ||
event === "SIGNED_OUT" ||
event === "MFA_CHALLENGE_VERIFIED")) {
await (0, cookies_1.applyServerStorage)({ getAll, setAll, setItems, removedItems }, {
cookieOptions: options?.cookieOptions ?? null,
cookieEncoding: options?.cookieEncoding ?? "base64url",
});
}
});
return client;
}
//# sourceMappingURL=createServerClient.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"createServerClient.js","sourceRoot":"","sources":["../../src/createServerClient.ts"],"names":[],"mappings":";;AAwHA,gDAsFC;AA9MD,uDAI+B;AAM/B,uCAAoC;AACpC,uCAAyE;AA6GzE,SAAgB,kBAAkB,CAShC,WAAmB,EACnB,WAAmB,EACnB,OAIC;IAED,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,kMAAkM,CACnM,CAAC;IACJ,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Y;gBACtB,KAAK,KAAK,wBAAwB,CAAC,EACrC,CAAC;YACD,MAAM,IAAA,4BAAkB,EACtB,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,EAC1C;gBACE,aAAa,EAAE,OAAO,EAAE,aAAa,IAAI,IAAI;gBAC7C,cAAc,EAAE,OAAO,EAAE,cAAc,IAAI,WAAW;aACvD,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}

View File

@ -0,0 +1 @@
export {};

4
node_modules/@supabase/ssr/dist/main/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,4 @@
export * from "./createBrowserClient";
export * from "./createServerClient";
export * from "./types";
export * from "./utils";

21
node_modules/@supabase/ssr/dist/main/index.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
"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 __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./createBrowserClient"), exports);
__exportStar(require("./createServerClient"), exports);
__exportStar(require("./types"), exports);
__exportStar(require("./utils"), exports);
//# sourceMappingURL=index.js.map

1
node_modules/@supabase/ssr/dist/main/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,uDAAqC;AACrC,0CAAwB;AACxB,0CAAwB"}

38
node_modules/@supabase/ssr/dist/main/types.d.ts generated vendored Normal file
View File

@ -0,0 +1,38 @@
import type { SerializeOptions } from "cookie";
export type CookieOptions = Partial<SerializeOptions>;
export type CookieOptionsWithName = {
name?: string;
} & CookieOptions;
export type GetCookie = (name: string) => Promise<string | null | undefined> | string | null | undefined;
export type SetCookie = (name: string, value: string, options: CookieOptions) => Promise<void> | void;
export type RemoveCookie = (name: string, options: CookieOptions) => Promise<void> | void;
export type GetAllCookies = () => Promise<{
name: string;
value: string;
}[] | null> | {
name: string;
value: string;
}[] | null;
export type SetAllCookies = (cookies: {
name: string;
value: string;
options: CookieOptions;
}[]) => Promise<void> | void;
export type CookieMethodsBrowserDeprecated = {
get: GetCookie;
set: SetCookie;
remove: RemoveCookie;
};
export type CookieMethodsBrowser = {
getAll: GetAllCookies;
setAll: SetAllCookies;
};
export type CookieMethodsServerDeprecated = {
get: GetCookie;
set?: SetCookie;
remove?: RemoveCookie;
};
export type CookieMethodsServer = {
getAll: GetAllCookies;
setAll?: SetAllCookies;
};

3
node_modules/@supabase/ssr/dist/main/types.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

1
node_modules/@supabase/ssr/dist/main/types.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,46 @@
/**
* Avoid modifying this file. It's part of
* https://github.com/supabase-community/base64url-js. Submit all fixes on
* that repo!
*/
/**
* Converts a JavaScript string (which may include any valid character) into a
* Base64-URL encoded string. The string is first encoded in UTF-8 which is
* then encoded as Base64-URL.
*
* @param str The string to convert.
*/
export declare function stringToBase64URL(str: string): string;
/**
* Converts a Base64-URL encoded string into a JavaScript string. It is assumed
* that the underlying string has been encoded as UTF-8.
*
* @param str The Base64-URL encoded string.
*/
export declare function stringFromBase64URL(str: string): string;
/**
* Converts a Unicode codepoint to a multi-byte UTF-8 sequence.
*
* @param codepoint The Unicode codepoint.
* @param emit Function which will be called for each UTF-8 byte that represents the codepoint.
*/
export declare function codepointToUTF8(codepoint: number, emit: (byte: number) => void): void;
/**
* Converts a JavaScript string to a sequence of UTF-8 bytes.
*
* @param str The string to convert to UTF-8.
* @param emit Function which will be called for each UTF-8 byte of the string.
*/
export declare function stringToUTF8(str: string, emit: (byte: number) => void): void;
/**
* Converts a UTF-8 byte to a Unicode codepoint.
*
* @param byte The UTF-8 byte next in the sequence.
* @param state The shared state between consecutive UTF-8 bytes in the
* sequence, an object with the shape `{ utf8seq: 0, codepoint: 0 }`.
* @param emit Function which will be called for each codepoint.
*/
export declare function stringFromUTF8(byte: number, state: {
utf8seq: number;
codepoint: number;
}, emit: (codepoint: number) => void): void;

209
node_modules/@supabase/ssr/dist/main/utils/base64url.js generated vendored Normal file
View File

@ -0,0 +1,209 @@
"use strict";
/**
* Avoid modifying this file. It's part of
* https://github.com/supabase-community/base64url-js. Submit all fixes on
* that repo!
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringToBase64URL = stringToBase64URL;
exports.stringFromBase64URL = stringFromBase64URL;
exports.codepointToUTF8 = codepointToUTF8;
exports.stringToUTF8 = stringToUTF8;
exports.stringFromUTF8 = stringFromUTF8;
/**
* An array of characters that encode 6 bits into a Base64-URL alphabet
* character.
*/
const TO_BASE64URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split("");
/**
* An array of characters that can appear in a Base64-URL encoded string but
* should be ignored.
*/
const IGNORE_BASE64URL = " \t\n\r=".split("");
/**
* An array of 128 numbers that map a Base64-URL character to 6 bits, or if -2
* used to skip the character, or if -1 used to error out.
*/
const FROM_BASE64URL = (() => {
const charMap = new Array(128);
for (let i = 0; i < charMap.length; i += 1) {
charMap[i] = -1;
}
for (let i = 0; i < IGNORE_BASE64URL.length; i += 1) {
charMap[IGNORE_BASE64URL[i].charCodeAt(0)] = -2;
}
for (let i = 0; i < TO_BASE64URL.length; i += 1) {
charMap[TO_BASE64URL[i].charCodeAt(0)] = i;
}
return charMap;
})();
/**
* Converts a JavaScript string (which may include any valid character) into a
* Base64-URL encoded string. The string is first encoded in UTF-8 which is
* then encoded as Base64-URL.
*
* @param str The string to convert.
*/
function stringToBase64URL(str) {
const base64 = [];
let queue = 0;
let queuedBits = 0;
const emitter = (byte) => {
queue = (queue << 8) | byte;
queuedBits += 8;
while (queuedBits >= 6) {
const pos = (queue >> (queuedBits - 6)) & 63;
base64.push(TO_BASE64URL[pos]);
queuedBits -= 6;
}
};
stringToUTF8(str, emitter);
if (queuedBits > 0) {
queue = queue << (6 - queuedBits);
queuedBits = 6;
while (queuedBits >= 6) {
const pos = (queue >> (queuedBits - 6)) & 63;
base64.push(TO_BASE64URL[pos]);
queuedBits -= 6;
}
}
return base64.join("");
}
/**
* Converts a Base64-URL encoded string into a JavaScript string. It is assumed
* that the underlying string has been encoded as UTF-8.
*
* @param str The Base64-URL encoded string.
*/
function stringFromBase64URL(str) {
const conv = [];
const emit = (codepoint) => {
conv.push(String.fromCodePoint(codepoint));
};
const state = {
utf8seq: 0,
codepoint: 0,
};
let queue = 0;
let queuedBits = 0;
for (let i = 0; i < str.length; i += 1) {
const codepoint = str.charCodeAt(i);
const bits = FROM_BASE64URL[codepoint];
if (bits > -1) {
// valid Base64-URL character
queue = (queue << 6) | bits;
queuedBits += 6;
while (queuedBits >= 8) {
stringFromUTF8((queue >> (queuedBits - 8)) & 0xff, state, emit);
queuedBits -= 8;
}
}
else if (bits === -2) {
// ignore spaces, tabs, newlines, =
continue;
}
else {
throw new Error(`Invalid Base64-URL character "${str.at(i)}" at position ${i}`);
}
}
return conv.join("");
}
/**
* Converts a Unicode codepoint to a multi-byte UTF-8 sequence.
*
* @param codepoint The Unicode codepoint.
* @param emit Function which will be called for each UTF-8 byte that represents the codepoint.
*/
function codepointToUTF8(codepoint, emit) {
if (codepoint <= 0x7f) {
emit(codepoint);
return;
}
else if (codepoint <= 0x7ff) {
emit(0xc0 | (codepoint >> 6));
emit(0x80 | (codepoint & 0x3f));
return;
}
else if (codepoint <= 0xffff) {
emit(0xe0 | (codepoint >> 12));
emit(0x80 | ((codepoint >> 6) & 0x3f));
emit(0x80 | (codepoint & 0x3f));
return;
}
else if (codepoint <= 0x10ffff) {
emit(0xf0 | (codepoint >> 18));
emit(0x80 | ((codepoint >> 12) & 0x3f));
emit(0x80 | ((codepoint >> 6) & 0x3f));
emit(0x80 | (codepoint & 0x3f));
return;
}
throw new Error(`Unrecognized Unicode codepoint: ${codepoint.toString(16)}`);
}
/**
* Converts a JavaScript string to a sequence of UTF-8 bytes.
*
* @param str The string to convert to UTF-8.
* @param emit Function which will be called for each UTF-8 byte of the string.
*/
function stringToUTF8(str, emit) {
for (let i = 0; i < str.length; i += 1) {
let codepoint = str.charCodeAt(i);
if (codepoint > 0xd7ff && codepoint <= 0xdbff) {
// most UTF-16 codepoints are Unicode codepoints, except values in this
// range where the next UTF-16 codepoint needs to be combined with the
// current one to get the Unicode codepoint
const highSurrogate = ((codepoint - 0xd800) * 0x400) & 0xffff;
const lowSurrogate = (str.charCodeAt(i + 1) - 0xdc00) & 0xffff;
codepoint = (lowSurrogate | highSurrogate) + 0x10000;
i += 1;
}
codepointToUTF8(codepoint, emit);
}
}
/**
* Converts a UTF-8 byte to a Unicode codepoint.
*
* @param byte The UTF-8 byte next in the sequence.
* @param state The shared state between consecutive UTF-8 bytes in the
* sequence, an object with the shape `{ utf8seq: 0, codepoint: 0 }`.
* @param emit Function which will be called for each codepoint.
*/
function stringFromUTF8(byte, state, emit) {
if (state.utf8seq === 0) {
if (byte <= 0x7f) {
emit(byte);
return;
}
// count the number of 1 leading bits until you reach 0
for (let leadingBit = 1; leadingBit < 6; leadingBit += 1) {
if (((byte >> (7 - leadingBit)) & 1) === 0) {
state.utf8seq = leadingBit;
break;
}
}
if (state.utf8seq === 2) {
state.codepoint = byte & 31;
}
else if (state.utf8seq === 3) {
state.codepoint = byte & 15;
}
else if (state.utf8seq === 4) {
state.codepoint = byte & 7;
}
else {
throw new Error("Invalid UTF-8 sequence");
}
state.utf8seq -= 1;
}
else if (state.utf8seq > 0) {
if (byte <= 0x7f) {
throw new Error("Invalid UTF-8 sequence");
}
state.codepoint = (state.codepoint << 6) | (byte & 63);
state.utf8seq -= 1;
if (state.utf8seq === 0) {
emit(state.codepoint);
}
}
}
//# sourceMappingURL=base64url.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const base64url_1 = require("./base64url");
const EXAMPLES = [
"a",
"ab",
"abc",
"abcd",
"hello world",
"нешто на кирилица",
"something with emojis 🤙🏾 ",
"Supabaseは、オープンソースの Firebase 代替製品です。エンタープライズグレードのオープンソースツールを使って、Firebase の機能を構築しています。",
];
(0, vitest_1.describe)("stringToBase64URL", () => {
EXAMPLES.forEach((example) => {
(0, vitest_1.test)(`encode "${example}"`, () => {
(0, vitest_1.expect)((0, base64url_1.stringToBase64URL)(example)).toEqual(Buffer.from(example).toString("base64url"));
});
});
});
(0, vitest_1.describe)("stringFromBase64URL", () => {
EXAMPLES.forEach((example) => {
(0, vitest_1.test)(`decode "${example}"`, () => {
(0, vitest_1.expect)((0, base64url_1.stringFromBase64URL)("\r\t\n " + Buffer.from(example).toString("base64url"))).toEqual(example);
});
});
(0, vitest_1.test)("decode with invalid Base64-URL character", () => {
(0, vitest_1.expect)(() => {
(0, base64url_1.stringFromBase64URL)("*");
}).toThrow(new Error(`Invalid Base64-URL character "*" at position 0`));
});
});
const BAD_UTF8 = [
[0xf8], // 11111000
[0xff], // 11111111
[0x80], // 10000000
[0xf8, 1], // 11110000 00000001
[0xe0, 1], // 11100000 00000001
[0xc0, 1], // 11100000 00000001
];
(0, vitest_1.describe)("stringFromUTF8", () => {
BAD_UTF8.forEach((example) => {
(0, vitest_1.test)(`should recognize bad UTF-8 sequence ${example.map((x) => x.toString(16)).join(" ")}`, () => {
(0, vitest_1.expect)(() => {
const state = { utf8seq: 0, codepoint: 0 };
example.forEach((byte) => {
(0, base64url_1.stringFromUTF8)(byte, state, () => { });
});
}).toThrow(new Error("Invalid UTF-8 sequence"));
});
});
});
(0, vitest_1.describe)("codepointToUTF8", () => {
(0, vitest_1.test)("invalid codepoints above 0x10ffff", () => {
const invalidCodepoint = 0x10ffff + 1;
(0, vitest_1.expect)(() => {
(0, base64url_1.codepointToUTF8)(invalidCodepoint, () => {
throw new Error("Should not becalled");
});
}).toThrow(new Error(`Unrecognized Unicode codepoint: ${invalidCodepoint.toString(16)}`));
});
});
//# sourceMappingURL=base64url.test.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"base64url.test.js","sourceRoot":"","sources":["../../../src/utils/base64url.test.ts"],"names":[],"mappings":";;AAAA,mCAAgD;AAChD,2CAKqB;AAErB,MAAM,QAAQ,GAAG;IACf,GAAG;IACH,IAAI;IACJ,KAAK;IACL,MAAM;IACN,aAAa;IACb,mBAAmB;IACnB,6BAA6B;IAC7B,sFAAsF;CACvF,CAAC;AAEF,IAAA,iBAAQ,EAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,IAAA,aAAI,EAAC,WAAW,OAAO,GAAG,EAAE,GAAG,EAAE;YAC/B,IAAA,eAAM,EAAC,IAAA,6BAAiB,EAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CACxC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAC3C,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAA,iBAAQ,EAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,IAA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EAAE,CAAC;gBAC3C,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;oBACvB,IAAA,0BAAc,EAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;gBACxC,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAA,iBAAQ,EAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAA,aAAI,EAAC,mCAAmC,EAAE,GAAG,EAAE;QAC7C,MAAM,gBAAgB,GAAG,QAAQ,GAAG,CAAC,CAAC;QACtC,IAAA,eAAM,EAAC,GAAG,EAAE;YACV,IAAA,2BAAe,EAAC,gBAAgB,EAAE,GAAG,EAAE;gBACrC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC,OAAO,CACR,IAAI,KAAK,CACP,mCAAmC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CACnE,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,13 @@
interface Chunk {
name: string;
value: string;
}
export declare const MAX_CHUNK_SIZE = 3180;
export declare function isChunkLike(cookieName: string, key: string): boolean;
/**
* create chunks from a string and return an array of object
*/
export declare function createChunks(key: string, value: string, chunkSize?: number): Chunk[];
export declare function combineChunks(key: string, retrieveChunk: (name: string) => Promise<string | null | undefined> | string | null | undefined): Promise<string | null>;
export declare function deleteChunks(key: string, retrieveChunk: (name: string) => Promise<string | null | undefined> | string | null | undefined, removeChunk: (name: string) => Promise<void> | void): Promise<void>;
export {};

99
node_modules/@supabase/ssr/dist/main/utils/chunker.js generated vendored Normal file
View File

@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MAX_CHUNK_SIZE = void 0;
exports.isChunkLike = isChunkLike;
exports.createChunks = createChunks;
exports.combineChunks = combineChunks;
exports.deleteChunks = deleteChunks;
exports.MAX_CHUNK_SIZE = 3180;
const CHUNK_LIKE_REGEX = /^(.*)[.](0|[1-9][0-9]*)$/;
function isChunkLike(cookieName, key) {
if (cookieName === key) {
return true;
}
const chunkLike = cookieName.match(CHUNK_LIKE_REGEX);
if (chunkLike && chunkLike[1] === key) {
return true;
}
return false;
}
/**
* create chunks from a string and return an array of object
*/
function createChunks(key, value, chunkSize) {
const resolvedChunkSize = chunkSize ?? exports.MAX_CHUNK_SIZE;
let encodedValue = encodeURIComponent(value);
if (encodedValue.length <= resolvedChunkSize) {
return [{ name: key, value }];
}
const chunks = [];
while (encodedValue.length > 0) {
let encodedChunkHead = encodedValue.slice(0, resolvedChunkSize);
const lastEscapePos = encodedChunkHead.lastIndexOf("%");
// Check if the last escaped character is truncated.
if (lastEscapePos > resolvedChunkSize - 3) {
// If so, reslice the string to exclude the whole escape sequence.
// We only reduce the size of the string as the chunk must
// be smaller than the chunk size.
encodedChunkHead = encodedChunkHead.slice(0, lastEscapePos);
}
let valueHead = "";
// Check if the chunk was split along a valid unicode boundary.
while (encodedChunkHead.length > 0) {
try {
// Try to decode the chunk back and see if it is valid.
// Stop when the chunk is valid.
valueHead = decodeURIComponent(encodedChunkHead);
break;
}
catch (error) {
if (error instanceof URIError &&
encodedChunkHead.at(-3) === "%" &&
encodedChunkHead.length > 3) {
encodedChunkHead = encodedChunkHead.slice(0, encodedChunkHead.length - 3);
}
else {
throw error;
}
}
}
chunks.push(valueHead);
encodedValue = encodedValue.slice(encodedChunkHead.length);
}
return chunks.map((value, i) => ({ name: `${key}.${i}`, value }));
}
// Get fully constructed chunks
async function combineChunks(key, retrieveChunk) {
const value = await retrieveChunk(key);
if (value) {
return value;
}
let values = [];
for (let i = 0;; i++) {
const chunkName = `${key}.${i}`;
const chunk = await retrieveChunk(chunkName);
if (!chunk) {
break;
}
values.push(chunk);
}
if (values.length > 0) {
return values.join("");
}
return null;
}
async function deleteChunks(key, retrieveChunk, removeChunk) {
const value = await retrieveChunk(key);
if (value) {
await removeChunk(key);
}
for (let i = 0;; i++) {
const chunkName = `${key}.${i}`;
const chunk = await retrieveChunk(chunkName);
if (!chunk) {
break;
}
await removeChunk(chunkName);
}
}
//# sourceMappingURL=chunker.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"chunker.js","sourceRoot":"","sources":["../../../src/utils/chunker.ts"],"names":[],"mappings":";;;AAQA,kCAWC;AAKD,oCA0DC;AAGD,sCA8BC;AAED,oCAuBC;AAvIY,QAAA,cAAc,GAAG,IAAI,CAAC;AAEnC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AACpD,SAAgB,WAAW,CAAC,UAAkB,EAAE,GAAW;IACzD,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACrD,IAAI,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAC1B,GAAW,EACX,KAAa,EACb,SAAkB;IAElB,MAAM,iBAAiB,GAAG,SAAS,IAAI,sBAAc,CAAC;IAEtD,IAAI,YAAY,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAE7C,IAAI,YAAY,CAAC,MAAM,IAAI,iBAAiB,EAAE,CAAC;QAC7C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,OAAO,YAAY,CAAC,MAAM,GAAG,CAAC,E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B,CAAC;AACH,CAAC"}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,2 @@
import { CookieOptions } from "../types";
export declare const DEFAULT_COOKIE_OPTIONS: CookieOptions;

View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_COOKIE_OPTIONS = void 0;
exports.DEFAULT_COOKIE_OPTIONS = {
path: "/",
sameSite: "lax",
httpOnly: false,
// https://developer.chrome.com/blog/cookie-max-age-expires
// https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-cookie-lifetime-limits
maxAge: 400 * 24 * 60 * 60,
};
//# sourceMappingURL=constants.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,sBAAsB,GAAkB;IACnD,IAAI,EAAE,GAAG;IACT,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,KAAK;IACf,2DAA2D;IAC3D,oGAAoG;IACpG,MAAM,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;CAC3B,CAAC"}

View File

@ -0,0 +1,32 @@
import type { SerializeOptions } from "cookie";
import { parse as cookieParse, serialize as cookieSerialize } from "cookie";
/**
* @deprecated Since v0.4.0: Please use {@link parseCookieHeader}. `parse` will
* not be available for import starting v1.0.0 of `@supabase/ssr`.
*/
export declare const parse: typeof cookieParse;
/**
* @deprecated Since v0.4.0: Please use {@link serializeCookieHeader}.
* `serialize` will not be available for import starting v1.0.0 of
* `@supabase/ssr`.
*/
export declare const serialize: typeof cookieSerialize;
/**
* Parses the `Cookie` HTTP header into an array of cookie name-value objects.
*
* @param header The `Cookie` HTTP header. Decodes cookie names and values from
* URI encoding first.
*/
export declare function parseCookieHeader(header: string): {
name: string;
value?: string;
}[];
/**
* Converts the arguments to a valid `Set-Cookie` header. Non US-ASCII chars
* and other forbidden cookie chars will be URI encoded.
*
* @param name Name of cookie.
* @param value Value of cookie.
*/
export declare function serializeCookieHeader(name: string, value: string, options: SerializeOptions): string;
export declare function isBrowser(): boolean;

45
node_modules/@supabase/ssr/dist/main/utils/helpers.js generated vendored Normal file
View File

@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serialize = exports.parse = void 0;
exports.parseCookieHeader = parseCookieHeader;
exports.serializeCookieHeader = serializeCookieHeader;
exports.isBrowser = isBrowser;
const cookie_1 = require("cookie");
/**
* @deprecated Since v0.4.0: Please use {@link parseCookieHeader}. `parse` will
* not be available for import starting v1.0.0 of `@supabase/ssr`.
*/
exports.parse = cookie_1.parse;
/**
* @deprecated Since v0.4.0: Please use {@link serializeCookieHeader}.
* `serialize` will not be available for import starting v1.0.0 of
* `@supabase/ssr`.
*/
exports.serialize = cookie_1.serialize;
/**
* Parses the `Cookie` HTTP header into an array of cookie name-value objects.
*
* @param header The `Cookie` HTTP header. Decodes cookie names and values from
* URI encoding first.
*/
function parseCookieHeader(header) {
const parsed = (0, cookie_1.parse)(header);
return Object.keys(parsed ?? {}).map((name) => ({
name,
value: parsed[name],
}));
}
/**
* Converts the arguments to a valid `Set-Cookie` header. Non US-ASCII chars
* and other forbidden cookie chars will be URI encoded.
*
* @param name Name of cookie.
* @param value Value of cookie.
*/
function serializeCookieHeader(name, value, options) {
return (0, cookie_1.serialize)(name, value, options);
}
function isBrowser() {
return (typeof window !== "undefined" && typeof window.document !== "undefined");
}
//# sourceMappingURL=helpers.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":";;;AAsBA,8CASC;AASD,sDAMC;AAED,8BAIC;AAnDD,mCAA4E;AAE5E;;;GAGG;AACU,QAAA,KAAK,GAAG,cAAW,CAAC;AAEjC;;;;GAIG;AACU,QAAA,SAAS,GAAG,kBAAe,CAAC;AAEzC;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,MAAc;IAEd,MAAM,MAAM,GAAG,IAAA,cAAW,EAAC,MAAM,CAAC,CAAC;IAEnC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI;QACJ,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC;KACpB,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,IAAY,EACZ,KAAa,EACb,OAAyB;IAEzB,OAAO,IAAA,kBAAe,EAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED,SAAgB,SAAS;IACvB,OAAO,CACL,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CACxE,CAAC;AACJ,CAAC"}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,4 @@
export * from "./helpers";
export * from "./constants";
export * from "./chunker";
export * from "./base64url";

21
node_modules/@supabase/ssr/dist/main/utils/index.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
"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 __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./helpers"), exports);
__exportStar(require("./constants"), exports);
__exportStar(require("./chunker"), exports);
__exportStar(require("./base64url"), exports);
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,8CAA4B;AAC5B,4CAA0B;AAC1B,8CAA4B"}

1
node_modules/@supabase/ssr/dist/main/version.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export declare const VERSION = "0.6.1";

5
node_modules/@supabase/ssr/dist/main/version.js generated vendored Normal file
View File

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION = void 0;
exports.VERSION = '0.6.1';
//# sourceMappingURL=version.js.map

1
node_modules/@supabase/ssr/dist/main/version.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC"}

47
node_modules/@supabase/ssr/dist/module/cookies.d.ts generated vendored Normal file
View File

@ -0,0 +1,47 @@
import type { CookieMethodsServer, CookieMethodsServerDeprecated, CookieMethodsBrowser, CookieMethodsBrowserDeprecated, CookieOptions, CookieOptionsWithName, GetAllCookies, SetAllCookies } from "./types";
/**
* Creates a storage client that handles cookies correctly for browser and
* server clients with or without properly provided cookie methods.
*
* @param options The options passed to createBrowserClient or createServer client.
*
* @param isServerClient Whether it's called from createServerClient.
*/
export declare function createStorageFromOptions(options: {
cookieEncoding: "raw" | "base64url";
cookies?: CookieMethodsBrowser | CookieMethodsBrowserDeprecated | CookieMethodsServer | CookieMethodsServerDeprecated;
cookieOptions?: CookieOptionsWithName;
}, isServerClient: boolean): {
getAll: (keyHints: string[]) => ReturnType<GetAllCookies>;
setAll: SetAllCookies;
setItems: {
[key: string]: string;
};
removedItems: {
[key: string]: boolean;
};
storage: {
isServer: boolean;
getItem: (key: string) => Promise<string | null>;
setItem: (key: string, value: string) => Promise<void>;
removeItem: (key: string) => Promise<void>;
};
};
/**
* When createServerClient needs to apply the created storage to cookies, it
* should call this function which handles correcly setting cookies for stored
* and removed items in the storage.
*/
export declare function applyServerStorage({ getAll, setAll, setItems, removedItems, }: {
getAll: (keyHints: string[]) => ReturnType<GetAllCookies>;
setAll: SetAllCookies;
setItems: {
[name: string]: string;
};
removedItems: {
[name: string]: boolean;
};
}, options: {
cookieEncoding: "raw" | "base64url";
cookieOptions?: CookieOptions | null;
}): Promise<void>;

343
node_modules/@supabase/ssr/dist/module/cookies.js generated vendored Normal file
View File

@ -0,0 +1,343 @@
import { parse, serialize } from "cookie";
import { DEFAULT_COOKIE_OPTIONS, combineChunks, createChunks, isBrowser, isChunkLike, stringFromBase64URL, stringToBase64URL, } from "./utils";
const BASE64_PREFIX = "base64-";
/**
* Creates a storage client that handles cookies correctly for browser and
* server clients with or without properly provided cookie methods.
*
* @param options The options passed to createBrowserClient or createServer client.
*
* @param isServerClient Whether it's called from createServerClient.
*/
export function createStorageFromOptions(options, isServerClient) {
const cookies = options.cookies ?? null;
const cookieEncoding = options.cookieEncoding;
const setItems = {};
const removedItems = {};
let getAll;
let setAll;
if (cookies) {
if ("get" in cookies) {
// Just get is not enough, because the client needs to see what cookies
// are already set and unset them if necessary. To attempt to fix this
// behavior for most use cases, we pass "hints" which is the keys of the
// storage items. They are then converted to their corresponding cookie
// chunk names and are fetched with get. Only 5 chunks are fetched, which
// should be enough for the majority of use cases, but does not solve
// those with very large sessions.
const getWithHints = async (keyHints) => {
// optimistically find the first 5 potential chunks for the specified key
const chunkNames = keyHints.flatMap((keyHint) => [
keyHint,
...Array.from({ length: 5 }).map((_, i) => `${keyHint}.${i}`),
]);
const chunks = [];
for (let i = 0; i < chunkNames.length; i += 1) {
const value = await cookies.get(chunkNames[i]);
if (!value && typeof value !== "string") {
continue;
}
chunks.push({ name: chunkNames[i], value });
}
// TODO: detect and log stale chunks error
return chunks;
};
getAll = async (keyHints) => await getWithHints(keyHints);
if ("set" in cookies && "remove" in cookies) {
setAll = async (setCookies) => {
for (let i = 0; i < setCookies.length; i += 1) {
const { name, value, options } = setCookies[i];
if (value) {
await cookies.set(name, value, options);
}
else {
await cookies.remove(name, options);
}
}
};
}
else if (isServerClient) {
setAll = async () => {
console.warn("@supabase/ssr: createServerClient was configured without set and remove cookie methods, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness. Consider switching to the getAll and setAll cookie methods instead of get, set and remove which are deprecated and can be difficult to use correctly.");
};
}
else {
throw new Error("@supabase/ssr: createBrowserClient requires configuring a getAll and setAll cookie method (deprecated: alternatively both get, set and remove can be used)");
}
}
else if ("getAll" in cookies) {
getAll = async () => await cookies.getAll();
if ("setAll" in cookies) {
setAll = cookies.setAll;
}
else if (isServerClient) {
setAll = async () => {
console.warn("@supabase/ssr: createServerClient was configured without the setAll cookie method, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness.");
};
}
else {
throw new Error("@supabase/ssr: createBrowserClient requires configuring both getAll and setAll cookie methods (deprecated: alternatively both get, set and remove can be used)");
}
}
else {
// neither get nor getAll is present on cookies, only will occur if pure JavaScript is used, but cookies is an object
throw new Error(`@supabase/ssr: ${isServerClient ? "createServerClient" : "createBrowserClient"} requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).${isBrowser() ? " As this is called in a browser runtime, consider removing the cookies option object to use the document.cookie API automatically." : ""}`);
}
}
else if (!isServerClient && isBrowser()) {
// The environment is browser, so use the document.cookie API to implement getAll and setAll.
const noHintGetAll = () => {
const parsed = parse(document.cookie);
return Object.keys(parsed).map((name) => ({
name,
value: parsed[name] ?? "",
}));
};
getAll = () => noHintGetAll();
setAll = (setCookies) => {
setCookies.forEach(({ name, value, options }) => {
document.cookie = serialize(name, value, options);
});
};
}
else if (isServerClient) {
throw new Error("@supabase/ssr: createServerClient must be initialized with cookie options that specify getAll and setAll functions (deprecated, not recommended: alternatively use get, set and remove)");
}
else {
// getting cookies when there's no window but we're in browser mode can be OK, because the developer probably is not using auth functions
getAll = () => {
return [];
};
// this is NOT OK because the developer is using auth functions that require setting some state, so that must error out
setAll = () => {
throw new Error("@supabase/ssr: createBrowserClient in non-browser runtimes (including Next.js pre-rendering mode) was not initialized cookie options that specify getAll and setAll functions (deprecated: alternatively use get, set and remove), but they were needed");
};
}
if (!isServerClient) {
// This is the storage client to be used in browsers. It only
// works on the cookies abstraction, unlike the server client
// which only uses cookies to read the initial state. When an
// item is set, cookies are both cleared and set to values so
// that stale chunks are not left remaining.
return {
getAll, // for type consistency
setAll, // for type consistency
setItems, // for type consistency
removedItems, // for type consistency
storage: {
isServer: false,
getItem: async (key) => {
const allCookies = await getAll([key]);
const chunkedCookie = await combineChunks(key, async (chunkName) => {
const cookie = allCookies?.find(({ name }) => name === chunkName) || null;
if (!cookie) {
return null;
}
return cookie.value;
});
if (!chunkedCookie) {
return null;
}
let decoded = chunkedCookie;
if (chunkedCookie.startsWith(BASE64_PREFIX)) {
decoded = stringFromBase64URL(chunkedCookie.substring(BASE64_PREFIX.length));
}
return decoded;
},
setItem: async (key, value) => {
const allCookies = await getAll([key]);
const cookieNames = allCookies?.map(({ name }) => name) || [];
const removeCookies = new Set(cookieNames.filter((name) => isChunkLike(name, key)));
let encoded = value;
if (cookieEncoding === "base64url") {
encoded = BASE64_PREFIX + stringToBase64URL(value);
}
const setCookies = createChunks(key, encoded);
setCookies.forEach(({ name }) => {
removeCookies.delete(name);
});
const removeCookieOptions = {
...DEFAULT_COOKIE_OPTIONS,
...options?.cookieOptions,
maxAge: 0,
};
const setCookieOptions = {
...DEFAULT_COOKIE_OPTIONS,
...options?.cookieOptions,
maxAge: DEFAULT_COOKIE_OPTIONS.maxAge,
};
// the NextJS cookieStore API can get confused if the `name` from
// options.cookieOptions leaks
delete removeCookieOptions.name;
delete setCookieOptions.name;
const allToSet = [
...[...removeCookies].map((name) => ({
name,
value: "",
options: removeCookieOptions,
})),
...setCookies.map(({ name, value }) => ({
name,
value,
options: setCookieOptions,
})),
];
if (allToSet.length > 0) {
await setAll(allToSet);
}
},
removeItem: async (key) => {
const allCookies = await getAll([key]);
const cookieNames = allCookies?.map(({ name }) => name) || [];
const removeCookies = cookieNames.filter((name) => isChunkLike(name, key));
const removeCookieOptions = {
...DEFAULT_COOKIE_OPTIONS,
...options?.cookieOptions,
maxAge: 0,
};
// the NextJS cookieStore API can get confused if the `name` from
// options.cookieOptions leaks
delete removeCookieOptions.name;
if (removeCookies.length > 0) {
await setAll(removeCookies.map((name) => ({
name,
value: "",
options: removeCookieOptions,
})));
}
},
},
};
}
// This is the server client. It only uses getAll to read the initial
// state. Any subsequent changes to the items is persisted in the
// setItems and removedItems objects. createServerClient *must* use
// getAll, setAll and the values in setItems and removedItems to
// persist the changes *at once* when appropriate (usually only when
// the TOKEN_REFRESHED, USER_UPDATED or SIGNED_OUT events are fired by
// the Supabase Auth client).
return {
getAll,
setAll,
setItems,
removedItems,
storage: {
// to signal to the libraries that these cookies are
// coming from a server environment and their value
// should not be trusted
isServer: true,
getItem: async (key) => {
if (typeof setItems[key] === "string") {
return setItems[key];
}
if (removedItems[key]) {
return null;
}
const allCookies = await getAll([key]);
const chunkedCookie = await combineChunks(key, async (chunkName) => {
const cookie = allCookies?.find(({ name }) => name === chunkName) || null;
if (!cookie) {
return null;
}
return cookie.value;
});
if (!chunkedCookie) {
return null;
}
let decoded = chunkedCookie;
if (typeof chunkedCookie === "string" &&
chunkedCookie.startsWith(BASE64_PREFIX)) {
decoded = stringFromBase64URL(chunkedCookie.substring(BASE64_PREFIX.length));
}
return decoded;
},
setItem: async (key, value) => {
// We don't have an `onAuthStateChange` event that can let us know that
// the PKCE code verifier is being set. Therefore, if we see it being
// set, we need to apply the storage (call `setAll` so the cookie is
// set properly).
if (key.endsWith("-code-verifier")) {
await applyServerStorage({
getAll,
setAll,
// pretend only that the code verifier was set
setItems: { [key]: value },
// pretend that nothing was removed
removedItems: {},
}, {
cookieOptions: options?.cookieOptions ?? null,
cookieEncoding,
});
}
setItems[key] = value;
delete removedItems[key];
},
removeItem: async (key) => {
// Intentionally not applying the storage when the key is the PKCE code
// verifier, as usually right after it's removed other items are set,
// so application of the storage will be handled by the
// `onAuthStateChange` callback that follows removal -- usually as part
// of the `exchangeCodeForSession` call.
delete setItems[key];
removedItems[key] = true;
},
},
};
}
/**
* When createServerClient needs to apply the created storage to cookies, it
* should call this function which handles correcly setting cookies for stored
* and removed items in the storage.
*/
export async function applyServerStorage({ getAll, setAll, setItems, removedItems, }, options) {
const cookieEncoding = options.cookieEncoding;
const cookieOptions = options.cookieOptions ?? null;
const allCookies = await getAll([
...(setItems ? Object.keys(setItems) : []),
...(removedItems ? Object.keys(removedItems) : []),
]);
const cookieNames = allCookies?.map(({ name }) => name) || [];
const removeCookies = Object.keys(removedItems).flatMap((itemName) => {
return cookieNames.filter((name) => isChunkLike(name, itemName));
});
const setCookies = Object.keys(setItems).flatMap((itemName) => {
const removeExistingCookiesForItem = new Set(cookieNames.filter((name) => isChunkLike(name, itemName)));
let encoded = setItems[itemName];
if (cookieEncoding === "base64url") {
encoded = BASE64_PREFIX + stringToBase64URL(encoded);
}
const chunks = createChunks(itemName, encoded);
chunks.forEach((chunk) => {
removeExistingCookiesForItem.delete(chunk.name);
});
removeCookies.push(...removeExistingCookiesForItem);
return chunks;
});
const removeCookieOptions = {
...DEFAULT_COOKIE_OPTIONS,
...cookieOptions,
maxAge: 0,
};
const setCookieOptions = {
...DEFAULT_COOKIE_OPTIONS,
...cookieOptions,
maxAge: DEFAULT_COOKIE_OPTIONS.maxAge,
};
// the NextJS cookieStore API can get confused if the `name` from
// options.cookieOptions leaks
delete removeCookieOptions.name;
delete setCookieOptions.name;
await setAll([
...removeCookies.map((name) => ({
name,
value: "",
options: removeCookieOptions,
})),
...setCookies.map(({ name, value }) => ({
name,
value,
options: setCookieOptions,
})),
]);
}
//# sourceMappingURL=cookies.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,37 @@
import { SupabaseClient } from "@supabase/supabase-js";
import type { GenericSchema, SupabaseClientOptions } from "@supabase/supabase-js/dist/module/lib/types";
import type { CookieMethodsBrowser, CookieMethodsBrowserDeprecated, CookieOptionsWithName } from "./types";
/**
* Creates a Supabase Client for use in a browser environment.
*
* In most cases you should not configure the `options.cookies` object, as this
* is automatically handled for you. If you do customize this, prefer using the
* `getAll` and `setAll` functions over `get`, `set` and `remove`. The latter
* are deprecated due to being difficult to correctly implement and not
* supporting some edge-cases. Both `getAll` and `setAll` (or both `get`, `set`
* and `remove`) must be provided. Failing to provide the methods for setting
* will throw an exception, and in previous versions of the library will result
* in difficult to debug authentication issues such as random logouts, early
* session termination or problems with inconsistent state.
*
* @param supabaseUrl The URL of the Supabase project.
* @param supabaseKey The `anon` API key of the Supabase project.
* @param options Various configuration options.
*/
export declare function createBrowserClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName> & {
cookies?: CookieMethodsBrowser;
cookieOptions?: CookieOptionsWithName;
cookieEncoding?: "raw" | "base64url";
isSingleton?: boolean;
}): SupabaseClient<Database, SchemaName, Schema>;
/**
* @deprecated Please specify `getAll` and `setAll` cookie methods instead of
* the `get`, `set` and `remove`. These will not be supported in the next major
* version.
*/
export declare function createBrowserClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options?: SupabaseClientOptions<SchemaName> & {
cookies: CookieMethodsBrowserDeprecated;
cookieOptions?: CookieOptionsWithName;
cookieEncoding?: "raw" | "base64url";
isSingleton?: boolean;
}): SupabaseClient<Database, SchemaName, Schema>;

View File

@ -0,0 +1,46 @@
import { createClient } from "@supabase/supabase-js";
import { VERSION } from "./version";
import { isBrowser } from "./utils";
import { createStorageFromOptions } from "./cookies";
let cachedBrowserClient;
export function createBrowserClient(supabaseUrl, supabaseKey, options) {
// singleton client is created only if isSingleton is set to true, or if isSingleton is not defined and we detect a browser
const shouldUseSingleton = options?.isSingleton === true ||
((!options || !("isSingleton" in options)) && isBrowser());
if (shouldUseSingleton && cachedBrowserClient) {
return cachedBrowserClient;
}
if (!supabaseUrl || !supabaseKey) {
throw new Error(`@supabase/ssr: Your project's URL and API key are required to create a Supabase client!\n\nCheck your Supabase project's API settings to find these values\n\nhttps://supabase.com/dashboard/project/_/settings/api`);
}
const { storage } = createStorageFromOptions({
...options,
cookieEncoding: options?.cookieEncoding ?? "base64url",
}, false);
const client = createClient(supabaseUrl, supabaseKey, {
...options,
global: {
...options?.global,
headers: {
...options?.global?.headers,
"X-Client-Info": `supabase-ssr/${VERSION} createBrowserClient`,
},
},
auth: {
...options?.auth,
...(options?.cookieOptions?.name
? { storageKey: options.cookieOptions.name }
: null),
flowType: "pkce",
autoRefreshToken: isBrowser(),
detectSessionInUrl: isBrowser(),
persistSession: true,
storage,
},
});
if (shouldUseSingleton) {
cachedBrowserClient = client;
}
return client;
}
//# sourceMappingURL=createBrowserClient.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"createBrowserClient.js","sourceRoot":"","sources":["../../src/createBrowserClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,uBAAuB,CAAC;AAMrE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAQpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD,IAAI,mBAA8D,CAAC;AA8DnE,MAAM,UAAU,mBAAmB,CASjC,WAAmB,EACnB,WAAmB,EACnB,OAKC;IAED,2HAA2H;IAC3H,MAAM,kBAAkB,GACtB,OAAO,EAAE,WAAW,KAAK,IAAI;QAC7B,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,aAAa,IAAI,OAAO,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC;IAE7D,IAAI,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QAC9C,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,qNAAqN,CACtN,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,wBAAwB,CAC1C;QACE,GAAG,OAAO;QACV,cAAc,EAAE,OAAO,EAAE,cAAc,IAAI,WAAW;KACvD,EACD,KAAK,CACN,CAAC;IAEF,MAAM,MAAM,GAAG,YAAY,CACzB,WAAW,EACX,WAAW,EACX;QACE,GAAG,OAAO;QACV,MAAM,EAAE;YACN,GAAG,OAAO,EAAE,MAAM;YAClB,OAAO,EAAE;gBACP,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO;gBAC3B,eAAe,EAAE,gBAAgB,OAAO,sBAAsB;aAC/D;SACF;QACD,IAAI,EAAE;YACJ,GAAG,OAAO,EAAE,IAAI;YAChB,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI;gBAC9B,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE;gBAC5C,CAAC,CAAC,IAAI,CAAC;YACT,QAAQ,EAAE,MAAM;YAChB,gBAAgB,EAAE,SAAS,EAAE;YAC7B,kBAAkB,EAAE,SAAS,EAAE;YAC/B,cAAc,EAAE,IAAI;YACpB,OAAO;SACR;KACF,CACF,CAAC;IAEF,IAAI,kBAAkB,EAAE,CAAC;QACvB,mBAAmB,GAAG,MAAM,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,79 @@
import { SupabaseClient } from "@supabase/supabase-js";
import type { GenericSchema, SupabaseClientOptions } from "@supabase/supabase-js/dist/module/lib/types";
import type { CookieOptionsWithName, CookieMethodsServer, CookieMethodsServerDeprecated } from "./types";
/**
* @deprecated Please specify `getAll` and `setAll` cookie methods instead of
* the `get`, `set` and `remove`. These will not be supported in the next major
* version.
*/
export declare function createServerClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options: SupabaseClientOptions<SchemaName> & {
cookieOptions?: CookieOptionsWithName;
cookies: CookieMethodsServerDeprecated;
cookieEncoding?: "raw" | "base64url";
}): SupabaseClient<Database, SchemaName, Schema>;
/**
* Creates a Supabase Client for use on the server-side of a server-side
* rendering (SSR) framework.
*
* There are two categories of uses for this function: use in middlewares and
* use in pages, components or routes.
*
* **Use in middlewares.**
*
* Middlewares are functions that run before any rendering logic is executed on
* the server-side. They typically have access to request headers (cookies) and
* can modify both the request and response headers.
*
* In most SSR frameworks, to use Supabase correctly you *must set up a
* middleware* and use this function in it.
*
* When using this in a middleware, the `cookie` option must be configured to
* use both `getAll` and `setAll`. Alternatively you can use the `get`, `set`
* and `remove` functions. The latter are deprecated **and not recommended**
* for most use cases due to being difficult to use properly and they do not
* cover important edge cases. In future major versions of the library, the
* option to configure `get`, `set` and `remove` will be removed.
*
* **IMPORTANT:** Failing to implement `getAll` and `setAll` correctly (or the
* deprecated `get`, `set` and `remove`) including omitting them **will cause
* significant and difficult to debug authentication issues**. They will
* manifest as: random logouts, early session termination, JSON parsing errors,
* increased number of refresh token requests, or relying on garbage state.
*
* **Use in pages, components or routes.**
*
* To use Supabase features server-side rendered in pages, components or routes
* (a.k.a. actions / APIs) you must create a client with this function. Not all
* frameworks allow the ability to set cookies or response headers when pages
* or components are rendered. In those cases you _can omit `setAll` (or the
* deprecated `set`, `remove`) cookie option methods_. **It is strongly
* recommended that if the ability to set cookies and response headers is
* present, you should configure the `setAll` (or the deprecated `set` and
* `remove`) cookie access methods.**
*
* **IMPORTANT:** If the ability to set cookies or response headers is not
* available **middleware or an equivalent must be used.** Failing to do this
* will cause significant and difficult to debug authentication issues.
*
* When `setAll` (or the deprecated `set`, `remove`) cookie methods are not
* configured, the Supabase Client will emit a warning if it is used in a way
* that requires setting cookies. If you see this warning, it usually means
* that you are using the Supabase Client in a wrong way:
*
* - You should have, but did not configure a middleware client.
* - There is a bug in your middleware function.
* - You are using features of the Supabase Client that change the User, e.g.
* by calling `supabase.auth.updateUser()` on the server.
*
* Please consult the latest Supabase guides for advice on how to avoid common
* pitfalls depending on SSR framework.
*
* @param supabaseUrl The URL of the Supabase project.
* @param supabaseKey The `anon` API key of the Supabase project.
* @param options Various configuration options.
*/
export declare function createServerClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(supabaseUrl: string, supabaseKey: string, options: SupabaseClientOptions<SchemaName> & {
cookieOptions?: CookieOptionsWithName;
cookies: CookieMethodsServer;
cookieEncoding?: "raw" | "base64url";
}): SupabaseClient<Database, SchemaName, Schema>;

View File

@ -0,0 +1,54 @@
import { createClient, } from "@supabase/supabase-js";
import { VERSION } from "./version";
import { createStorageFromOptions, applyServerStorage } from "./cookies";
export function createServerClient(supabaseUrl, supabaseKey, options) {
if (!supabaseUrl || !supabaseKey) {
throw new Error(`Your project's URL and Key are required to create a Supabase client!\n\nCheck your Supabase project's API settings to find these values\n\nhttps://supabase.com/dashboard/project/_/settings/api`);
}
const { storage, getAll, setAll, setItems, removedItems } = createStorageFromOptions({
...options,
cookieEncoding: options?.cookieEncoding ?? "base64url",
}, true);
const client = createClient(supabaseUrl, supabaseKey, {
...options,
global: {
...options?.global,
headers: {
...options?.global?.headers,
"X-Client-Info": `supabase-ssr/${VERSION} createServerClient`,
},
},
auth: {
...(options?.cookieOptions?.name
? { storageKey: options.cookieOptions.name }
: null),
...options?.auth,
flowType: "pkce",
autoRefreshToken: false,
detectSessionInUrl: false,
persistSession: true,
storage,
},
});
client.auth.onAuthStateChange(async (event) => {
// The SIGNED_IN event is fired very often, but we don't need to
// apply the storage each time it fires, only if there are changes
// that need to be set -- which is if setItems / removeItems have
// data.
const hasStorageChanges = Object.keys(setItems).length > 0 || Object.keys(removedItems).length > 0;
if (hasStorageChanges &&
(event === "SIGNED_IN" ||
event === "TOKEN_REFRESHED" ||
event === "USER_UPDATED" ||
event === "PASSWORD_RECOVERY" ||
event === "SIGNED_OUT" ||
event === "MFA_CHALLENGE_VERIFIED")) {
await applyServerStorage({ getAll, setAll, setItems, removedItems }, {
cookieOptions: options?.cookieOptions ?? null,
cookieEncoding: options?.cookieEncoding ?? "base64url",
});
}
});
return client;
}
//# sourceMappingURL=createServerClient.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"createServerClient.js","sourceRoot":"","sources":["../../src/createServerClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,GAEb,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AA6GzE,MAAM,UAAU,kBAAkB,CAShC,WAAmB,EACnB,WAAmB,EACnB,OAIC;IAED,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,kMAAkM,CACnM,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GACvD,wBAAwB,CACtB;QACE,GAAG,OAAO;QACV,cAAc,EAAE,OAAO,EAAE,cAAc,IAAI,WAAW;KACvD,EACD,IAAI,CACL,CAAC;IAEJ,MAAM,MAAM,GAAG,YAAY,CACzB,WAAW,EACX,WAAW,EACX;QACE,GAAG,OAAO;QACV,MAAM,EAAE;YACN,GAAG,OAAO,EAAE,MAAM;YAClB,OAAO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
export {};

4
node_modules/@supabase/ssr/dist/module/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,4 @@
export * from "./createBrowserClient";
export * from "./createServerClient";
export * from "./types";
export * from "./utils";

5
node_modules/@supabase/ssr/dist/module/index.js generated vendored Normal file
View File

@ -0,0 +1,5 @@
export * from "./createBrowserClient";
export * from "./createServerClient";
export * from "./types";
export * from "./utils";
//# sourceMappingURL=index.js.map

1
node_modules/@supabase/ssr/dist/module/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}

38
node_modules/@supabase/ssr/dist/module/types.d.ts generated vendored Normal file
View File

@ -0,0 +1,38 @@
import type { SerializeOptions } from "cookie";
export type CookieOptions = Partial<SerializeOptions>;
export type CookieOptionsWithName = {
name?: string;
} & CookieOptions;
export type GetCookie = (name: string) => Promise<string | null | undefined> | string | null | undefined;
export type SetCookie = (name: string, value: string, options: CookieOptions) => Promise<void> | void;
export type RemoveCookie = (name: string, options: CookieOptions) => Promise<void> | void;
export type GetAllCookies = () => Promise<{
name: string;
value: string;
}[] | null> | {
name: string;
value: string;
}[] | null;
export type SetAllCookies = (cookies: {
name: string;
value: string;
options: CookieOptions;
}[]) => Promise<void> | void;
export type CookieMethodsBrowserDeprecated = {
get: GetCookie;
set: SetCookie;
remove: RemoveCookie;
};
export type CookieMethodsBrowser = {
getAll: GetAllCookies;
setAll: SetAllCookies;
};
export type CookieMethodsServerDeprecated = {
get: GetCookie;
set?: SetCookie;
remove?: RemoveCookie;
};
export type CookieMethodsServer = {
getAll: GetAllCookies;
setAll?: SetAllCookies;
};

1
node_modules/@supabase/ssr/dist/module/types.js generated vendored Normal file
View File

@ -0,0 +1 @@
//# sourceMappingURL=types.js.map

1
node_modules/@supabase/ssr/dist/module/types.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,46 @@
/**
* Avoid modifying this file. It's part of
* https://github.com/supabase-community/base64url-js. Submit all fixes on
* that repo!
*/
/**
* Converts a JavaScript string (which may include any valid character) into a
* Base64-URL encoded string. The string is first encoded in UTF-8 which is
* then encoded as Base64-URL.
*
* @param str The string to convert.
*/
export declare function stringToBase64URL(str: string): string;
/**
* Converts a Base64-URL encoded string into a JavaScript string. It is assumed
* that the underlying string has been encoded as UTF-8.
*
* @param str The Base64-URL encoded string.
*/
export declare function stringFromBase64URL(str: string): string;
/**
* Converts a Unicode codepoint to a multi-byte UTF-8 sequence.
*
* @param codepoint The Unicode codepoint.
* @param emit Function which will be called for each UTF-8 byte that represents the codepoint.
*/
export declare function codepointToUTF8(codepoint: number, emit: (byte: number) => void): void;
/**
* Converts a JavaScript string to a sequence of UTF-8 bytes.
*
* @param str The string to convert to UTF-8.
* @param emit Function which will be called for each UTF-8 byte of the string.
*/
export declare function stringToUTF8(str: string, emit: (byte: number) => void): void;
/**
* Converts a UTF-8 byte to a Unicode codepoint.
*
* @param byte The UTF-8 byte next in the sequence.
* @param state The shared state between consecutive UTF-8 bytes in the
* sequence, an object with the shape `{ utf8seq: 0, codepoint: 0 }`.
* @param emit Function which will be called for each codepoint.
*/
export declare function stringFromUTF8(byte: number, state: {
utf8seq: number;
codepoint: number;
}, emit: (codepoint: number) => void): void;

View File

@ -0,0 +1,202 @@
/**
* Avoid modifying this file. It's part of
* https://github.com/supabase-community/base64url-js. Submit all fixes on
* that repo!
*/
/**
* An array of characters that encode 6 bits into a Base64-URL alphabet
* character.
*/
const TO_BASE64URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split("");
/**
* An array of characters that can appear in a Base64-URL encoded string but
* should be ignored.
*/
const IGNORE_BASE64URL = " \t\n\r=".split("");
/**
* An array of 128 numbers that map a Base64-URL character to 6 bits, or if -2
* used to skip the character, or if -1 used to error out.
*/
const FROM_BASE64URL = (() => {
const charMap = new Array(128);
for (let i = 0; i < charMap.length; i += 1) {
charMap[i] = -1;
}
for (let i = 0; i < IGNORE_BASE64URL.length; i += 1) {
charMap[IGNORE_BASE64URL[i].charCodeAt(0)] = -2;
}
for (let i = 0; i < TO_BASE64URL.length; i += 1) {
charMap[TO_BASE64URL[i].charCodeAt(0)] = i;
}
return charMap;
})();
/**
* Converts a JavaScript string (which may include any valid character) into a
* Base64-URL encoded string. The string is first encoded in UTF-8 which is
* then encoded as Base64-URL.
*
* @param str The string to convert.
*/
export function stringToBase64URL(str) {
const base64 = [];
let queue = 0;
let queuedBits = 0;
const emitter = (byte) => {
queue = (queue << 8) | byte;
queuedBits += 8;
while (queuedBits >= 6) {
const pos = (queue >> (queuedBits - 6)) & 63;
base64.push(TO_BASE64URL[pos]);
queuedBits -= 6;
}
};
stringToUTF8(str, emitter);
if (queuedBits > 0) {
queue = queue << (6 - queuedBits);
queuedBits = 6;
while (queuedBits >= 6) {
const pos = (queue >> (queuedBits - 6)) & 63;
base64.push(TO_BASE64URL[pos]);
queuedBits -= 6;
}
}
return base64.join("");
}
/**
* Converts a Base64-URL encoded string into a JavaScript string. It is assumed
* that the underlying string has been encoded as UTF-8.
*
* @param str The Base64-URL encoded string.
*/
export function stringFromBase64URL(str) {
const conv = [];
const emit = (codepoint) => {
conv.push(String.fromCodePoint(codepoint));
};
const state = {
utf8seq: 0,
codepoint: 0,
};
let queue = 0;
let queuedBits = 0;
for (let i = 0; i < str.length; i += 1) {
const codepoint = str.charCodeAt(i);
const bits = FROM_BASE64URL[codepoint];
if (bits > -1) {
// valid Base64-URL character
queue = (queue << 6) | bits;
queuedBits += 6;
while (queuedBits >= 8) {
stringFromUTF8((queue >> (queuedBits - 8)) & 0xff, state, emit);
queuedBits -= 8;
}
}
else if (bits === -2) {
// ignore spaces, tabs, newlines, =
continue;
}
else {
throw new Error(`Invalid Base64-URL character "${str.at(i)}" at position ${i}`);
}
}
return conv.join("");
}
/**
* Converts a Unicode codepoint to a multi-byte UTF-8 sequence.
*
* @param codepoint The Unicode codepoint.
* @param emit Function which will be called for each UTF-8 byte that represents the codepoint.
*/
export function codepointToUTF8(codepoint, emit) {
if (codepoint <= 0x7f) {
emit(codepoint);
return;
}
else if (codepoint <= 0x7ff) {
emit(0xc0 | (codepoint >> 6));
emit(0x80 | (codepoint & 0x3f));
return;
}
else if (codepoint <= 0xffff) {
emit(0xe0 | (codepoint >> 12));
emit(0x80 | ((codepoint >> 6) & 0x3f));
emit(0x80 | (codepoint & 0x3f));
return;
}
else if (codepoint <= 0x10ffff) {
emit(0xf0 | (codepoint >> 18));
emit(0x80 | ((codepoint >> 12) & 0x3f));
emit(0x80 | ((codepoint >> 6) & 0x3f));
emit(0x80 | (codepoint & 0x3f));
return;
}
throw new Error(`Unrecognized Unicode codepoint: ${codepoint.toString(16)}`);
}
/**
* Converts a JavaScript string to a sequence of UTF-8 bytes.
*
* @param str The string to convert to UTF-8.
* @param emit Function which will be called for each UTF-8 byte of the string.
*/
export function stringToUTF8(str, emit) {
for (let i = 0; i < str.length; i += 1) {
let codepoint = str.charCodeAt(i);
if (codepoint > 0xd7ff && codepoint <= 0xdbff) {
// most UTF-16 codepoints are Unicode codepoints, except values in this
// range where the next UTF-16 codepoint needs to be combined with the
// current one to get the Unicode codepoint
const highSurrogate = ((codepoint - 0xd800) * 0x400) & 0xffff;
const lowSurrogate = (str.charCodeAt(i + 1) - 0xdc00) & 0xffff;
codepoint = (lowSurrogate | highSurrogate) + 0x10000;
i += 1;
}
codepointToUTF8(codepoint, emit);
}
}
/**
* Converts a UTF-8 byte to a Unicode codepoint.
*
* @param byte The UTF-8 byte next in the sequence.
* @param state The shared state between consecutive UTF-8 bytes in the
* sequence, an object with the shape `{ utf8seq: 0, codepoint: 0 }`.
* @param emit Function which will be called for each codepoint.
*/
export function stringFromUTF8(byte, state, emit) {
if (state.utf8seq === 0) {
if (byte <= 0x7f) {
emit(byte);
return;
}
// count the number of 1 leading bits until you reach 0
for (let leadingBit = 1; leadingBit < 6; leadingBit += 1) {
if (((byte >> (7 - leadingBit)) & 1) === 0) {
state.utf8seq = leadingBit;
break;
}
}
if (state.utf8seq === 2) {
state.codepoint = byte & 31;
}
else if (state.utf8seq === 3) {
state.codepoint = byte & 15;
}
else if (state.utf8seq === 4) {
state.codepoint = byte & 7;
}
else {
throw new Error("Invalid UTF-8 sequence");
}
state.utf8seq -= 1;
}
else if (state.utf8seq > 0) {
if (byte <= 0x7f) {
throw new Error("Invalid UTF-8 sequence");
}
state.codepoint = (state.codepoint << 6) | (byte & 63);
state.utf8seq -= 1;
if (state.utf8seq === 0) {
emit(state.codepoint);
}
}
}
//# sourceMappingURL=base64url.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,62 @@
import { describe, expect, test } from "vitest";
import { stringToBase64URL, stringFromBase64URL, stringFromUTF8, codepointToUTF8, } from "./base64url";
const EXAMPLES = [
"a",
"ab",
"abc",
"abcd",
"hello world",
"нешто на кирилица",
"something with emojis 🤙🏾 ",
"Supabaseは、オープンソースの Firebase 代替製品です。エンタープライズグレードのオープンソースツールを使って、Firebase の機能を構築しています。",
];
describe("stringToBase64URL", () => {
EXAMPLES.forEach((example) => {
test(`encode "${example}"`, () => {
expect(stringToBase64URL(example)).toEqual(Buffer.from(example).toString("base64url"));
});
});
});
describe("stringFromBase64URL", () => {
EXAMPLES.forEach((example) => {
test(`decode "${example}"`, () => {
expect(stringFromBase64URL("\r\t\n " + Buffer.from(example).toString("base64url"))).toEqual(example);
});
});
test("decode with invalid Base64-URL character", () => {
expect(() => {
stringFromBase64URL("*");
}).toThrow(new Error(`Invalid Base64-URL character "*" at position 0`));
});
});
const BAD_UTF8 = [
[0xf8], // 11111000
[0xff], // 11111111
[0x80], // 10000000
[0xf8, 1], // 11110000 00000001
[0xe0, 1], // 11100000 00000001
[0xc0, 1], // 11100000 00000001
];
describe("stringFromUTF8", () => {
BAD_UTF8.forEach((example) => {
test(`should recognize bad UTF-8 sequence ${example.map((x) => x.toString(16)).join(" ")}`, () => {
expect(() => {
const state = { utf8seq: 0, codepoint: 0 };
example.forEach((byte) => {
stringFromUTF8(byte, state, () => { });
});
}).toThrow(new Error("Invalid UTF-8 sequence"));
});
});
});
describe("codepointToUTF8", () => {
test("invalid codepoints above 0x10ffff", () => {
const invalidCodepoint = 0x10ffff + 1;
expect(() => {
codepointToUTF8(invalidCodepoint, () => {
throw new Error("Should not becalled");
});
}).toThrow(new Error(`Unrecognized Unicode codepoint: ${invalidCodepoint.toString(16)}`));
});
});
//# sourceMappingURL=base64url.test.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"base64url.test.js","sourceRoot":"","sources":["../../../src/utils/base64url.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,MAAM,QAAQ,GAAG;IACf,GAAG;IACH,IAAI;IACJ,KAAK;IACL,MAAM;IACN,aAAa;IACb,mBAAmB;IACnB,6BAA6B;IAC7B,sFAAsF;CACvF,CAAC;AAEF,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,IAAI,CAAC,WAAW,OAAO,GAAG,EAAE,GAAG,EAAE;YAC/B,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CACxC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAC3C,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,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,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;gBAC3C,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;oBACvB,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;gBACxC,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC7C,MAAM,gBAAgB,GAAG,QAAQ,GAAG,CAAC,CAAC;QACtC,MAAM,CAAC,GAAG,EAAE;YACV,eAAe,CAAC,gBAAgB,EAAE,GAAG,EAAE;gBACrC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC,OAAO,CACR,IAAI,KAAK,CACP,mCAAmC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CACnE,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,13 @@
interface Chunk {
name: string;
value: string;
}
export declare const MAX_CHUNK_SIZE = 3180;
export declare function isChunkLike(cookieName: string, key: string): boolean;
/**
* create chunks from a string and return an array of object
*/
export declare function createChunks(key: string, value: string, chunkSize?: number): Chunk[];
export declare function combineChunks(key: string, retrieveChunk: (name: string) => Promise<string | null | undefined> | string | null | undefined): Promise<string | null>;
export declare function deleteChunks(key: string, retrieveChunk: (name: string) => Promise<string | null | undefined> | string | null | undefined, removeChunk: (name: string) => Promise<void> | void): Promise<void>;
export {};

View File

@ -0,0 +1,92 @@
export const MAX_CHUNK_SIZE = 3180;
const CHUNK_LIKE_REGEX = /^(.*)[.](0|[1-9][0-9]*)$/;
export function isChunkLike(cookieName, key) {
if (cookieName === key) {
return true;
}
const chunkLike = cookieName.match(CHUNK_LIKE_REGEX);
if (chunkLike && chunkLike[1] === key) {
return true;
}
return false;
}
/**
* create chunks from a string and return an array of object
*/
export function createChunks(key, value, chunkSize) {
const resolvedChunkSize = chunkSize ?? MAX_CHUNK_SIZE;
let encodedValue = encodeURIComponent(value);
if (encodedValue.length <= resolvedChunkSize) {
return [{ name: key, value }];
}
const chunks = [];
while (encodedValue.length > 0) {
let encodedChunkHead = encodedValue.slice(0, resolvedChunkSize);
const lastEscapePos = encodedChunkHead.lastIndexOf("%");
// Check if the last escaped character is truncated.
if (lastEscapePos > resolvedChunkSize - 3) {
// If so, reslice the string to exclude the whole escape sequence.
// We only reduce the size of the string as the chunk must
// be smaller than the chunk size.
encodedChunkHead = encodedChunkHead.slice(0, lastEscapePos);
}
let valueHead = "";
// Check if the chunk was split along a valid unicode boundary.
while (encodedChunkHead.length > 0) {
try {
// Try to decode the chunk back and see if it is valid.
// Stop when the chunk is valid.
valueHead = decodeURIComponent(encodedChunkHead);
break;
}
catch (error) {
if (error instanceof URIError &&
encodedChunkHead.at(-3) === "%" &&
encodedChunkHead.length > 3) {
encodedChunkHead = encodedChunkHead.slice(0, encodedChunkHead.length - 3);
}
else {
throw error;
}
}
}
chunks.push(valueHead);
encodedValue = encodedValue.slice(encodedChunkHead.length);
}
return chunks.map((value, i) => ({ name: `${key}.${i}`, value }));
}
// Get fully constructed chunks
export async function combineChunks(key, retrieveChunk) {
const value = await retrieveChunk(key);
if (value) {
return value;
}
let values = [];
for (let i = 0;; i++) {
const chunkName = `${key}.${i}`;
const chunk = await retrieveChunk(chunkName);
if (!chunk) {
break;
}
values.push(chunk);
}
if (values.length > 0) {
return values.join("");
}
return null;
}
export async function deleteChunks(key, retrieveChunk, removeChunk) {
const value = await retrieveChunk(key);
if (value) {
await removeChunk(key);
}
for (let i = 0;; i++) {
const chunkName = `${key}.${i}`;
const chunk = await retrieveChunk(chunkName);
if (!chunk) {
break;
}
await removeChunk(chunkName);
}
}
//# sourceMappingURL=chunker.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"chunker.js","sourceRoot":"","sources":["../../../src/utils/chunker.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AAEnC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AACpD,MAAM,UAAU,WAAW,CAAC,UAAkB,EAAE,GAAW;IACzD,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACrD,IAAI,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAW,EACX,KAAa,EACb,SAAkB;IAElB,MAAM,iBAAiB,GAAG,SAAS,IAAI,cAAc,CAAC;IAEtD,IAAI,YAAY,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAE7C,IAAI,YAAY,CAAC,MAAM,IAAI,iBAAiB,EAAE,CAAC;QAC7C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,OAAO,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,IAAI,gBAAgB,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAEhE,MAAM,aAAa,GAAG,gBAAgB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAExD,oDAAoD;QACpD,IAAI,aAAa,GAAG,iBAAiB,GAAG,C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C;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,MAAM,GAAa,EAAE,CAAC;IAE1B,KAAK,IAAI,CAAC,GAAG,CAAC,GAAI,CAAC,EAAE,EAAE,CAAC;QACtB,MAAM,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,CAAC;QAE7C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM;QACR,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAW,EACX,aAEmE,EACnE,WAAmD;IAEnD,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;IAEvC,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,GAAI,CAAC,EAAE,EAAE,CAAC;QACtB,MAAM,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,CAAC;QAE7C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM;QACR,CAAC;QAED,MAAM,WAAW,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,2 @@
import { CookieOptions } from "../types";
export declare const DEFAULT_COOKIE_OPTIONS: CookieOptions;

View File

@ -0,0 +1,9 @@
export const DEFAULT_COOKIE_OPTIONS = {
path: "/",
sameSite: "lax",
httpOnly: false,
// https://developer.chrome.com/blog/cookie-max-age-expires
// https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-cookie-lifetime-limits
maxAge: 400 * 24 * 60 * 60,
};
//# sourceMappingURL=constants.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,IAAI,EAAE,GAAG;IACT,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,KAAK;IACf,2DAA2D;IAC3D,oGAAoG;IACpG,MAAM,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;CAC3B,CAAC"}

Some files were not shown because too many files have changed in this diff Show More