dev testing
This commit is contained in:
4
dist/admin.html
vendored
4
dist/admin.html
vendored
@@ -8,8 +8,8 @@
|
|||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
||||||
<script type="module" crossorigin src="/assets/admin-BaZpN3Uw.js"></script>
|
<script type="module" crossorigin src="/assets/admin-CsJ8T6K2.js"></script>
|
||||||
<link rel="modulepreload" crossorigin href="/assets/donors-DDFnEjnq.js">
|
<link rel="modulepreload" crossorigin href="/assets/donors-BfBdprwo.js">
|
||||||
<link rel="stylesheet" crossorigin href="/assets/admin-r6G2dek0.css">
|
<link rel="stylesheet" crossorigin href="/assets/admin-r6G2dek0.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import{i as C,j as A,n as p,p as D,f as b,d as S,v as k,x as M,y as $,t as x,z as T,A as F,B as Y,C as N}from"./donors-DDFnEjnq.js";const f=["pcgurudm@gmail.com"];let m=[];document.addEventListener("DOMContentLoaded",()=>{C(),H(),V(),P(),j(),_()});function H(){document.getElementById("loginGoogle").addEventListener("click",A),document.getElementById("logoutBtn").addEventListener("click",p),document.getElementById("unauthorizedLogout").addEventListener("click",p),D(q)}async function q(t){const e=document.getElementById("authSection"),n=document.getElementById("unauthorizedSection"),o=document.getElementById("adminContent"),d=document.getElementById("logoutBtn");if(!t){e.classList.remove("hidden"),n.classList.add("hidden"),o.classList.add("hidden"),d.style.display="none";return}if(d.style.display="",!await z(t.email)){e.classList.add("hidden"),n.classList.remove("hidden"),o.classList.add("hidden");return}e.classList.add("hidden"),n.classList.add("hidden"),o.classList.remove("hidden"),g()}async function z(t){try{const e=b(S,"config","admins"),n=await k(e);return n.exists()?(n.data()?.emails||[]).includes(t):f.includes(t)?(await M(e,{emails:f}),console.log("Admin allowlist created with seed admins."),!0):!1}catch(e){return console.error("Admin check failed:",e),!1}}function V(){document.querySelectorAll(".admin-tab").forEach(t=>{t.addEventListener("click",()=>{document.querySelectorAll(".admin-tab").forEach(e=>e.classList.remove("active")),document.querySelectorAll(".admin-panel").forEach(e=>e.classList.remove("active")),t.classList.add("active"),document.getElementById(`panel-${t.dataset.tab}`).classList.add("active")})})}async function g(){try{m=await $(),R(),L()}catch(t){console.error("Failed to load donors:",t),r("Failed to load donors.","error")}}function R(){const t=x(m);document.getElementById("statTotal").textContent=`$${t.toLocaleString()}`,document.getElementById("statCount").textContent=m.length}function P(){const t=document.getElementById("addDonorForm");t.addEventListener("submit",async e=>{e.preventDefault();const n=document.getElementById("addDonorBtn");n.disabled=!0,n.textContent="Adding...";try{await T({name:document.getElementById("donorName").value.trim(),amount:document.getElementById("donorAmount").value,classYear:document.getElementById("donorClassYear").value.trim(),message:document.getElementById("donorMessage").value.trim(),anonymous:document.getElementById("donorAnonymous").checked,date:document.getElementById("donorDate").value||null}),r("Donor added!","success"),t.reset(),await g()}catch(o){console.error("Failed to add donor:",o),r("Failed to add donor.","error")}finally{n.disabled=!1,n.textContent="Add Donor"}})}let u=[],h=[];function j(){document.getElementById("csvFile").addEventListener("change",G),document.getElementById("importBtn").addEventListener("click",O),document.getElementById("csvCancelBtn").addEventListener("click",I),document.querySelectorAll(".mapping-grid select").forEach(e=>{e.addEventListener("change",B)})}function G(t){const e=t.target.files[0];if(!e)return;const n=new FileReader;n.onload=o=>{const d=o.target.result,a=U(d);if(a.length<2){r("CSV file appears empty or has no data rows.","error");return}h=a[0],u=a.slice(1),W(),document.getElementById("csvMapping").classList.remove("hidden")},n.readAsText(e)}function U(t){const e=[];let n=[],o="",d=!1;for(let a=0;a<t.length;a++){const s=t[a],i=t[a+1];d?s==='"'&&i==='"'?(o+='"',a++):s==='"'?d=!1:o+=s:s==='"'?d=!0:s===","?(n.push(o.trim()),o=""):s===`
|
import{i as C,j as A,k as p,m as D,f as b,d as S,t as k,u as M,v as $,p as x,x as T,y as F,z as Y,A as N}from"./donors-BfBdprwo.js";const f=["pcgurudm@gmail.com"];let m=[];document.addEventListener("DOMContentLoaded",()=>{C(),H(),V(),P(),j(),_()});function H(){document.getElementById("loginGoogle").addEventListener("click",A),document.getElementById("logoutBtn").addEventListener("click",p),document.getElementById("unauthorizedLogout").addEventListener("click",p),D(q)}async function q(t){const e=document.getElementById("authSection"),n=document.getElementById("unauthorizedSection"),o=document.getElementById("adminContent"),d=document.getElementById("logoutBtn");if(!t){e.classList.remove("hidden"),n.classList.add("hidden"),o.classList.add("hidden"),d.style.display="none";return}if(d.style.display="",!await z(t.email)){e.classList.add("hidden"),n.classList.remove("hidden"),o.classList.add("hidden");return}e.classList.add("hidden"),n.classList.add("hidden"),o.classList.remove("hidden"),g()}async function z(t){try{const e=b(S,"config","admins"),n=await k(e);return n.exists()?(n.data()?.emails||[]).includes(t):f.includes(t)?(await M(e,{emails:f}),console.log("Admin allowlist created with seed admins."),!0):!1}catch(e){return console.error("Admin check failed:",e),!1}}function V(){document.querySelectorAll(".admin-tab").forEach(t=>{t.addEventListener("click",()=>{document.querySelectorAll(".admin-tab").forEach(e=>e.classList.remove("active")),document.querySelectorAll(".admin-panel").forEach(e=>e.classList.remove("active")),t.classList.add("active"),document.getElementById(`panel-${t.dataset.tab}`).classList.add("active")})})}async function g(){try{m=await $(),R(),L()}catch(t){console.error("Failed to load donors:",t),r("Failed to load donors.","error")}}function R(){const t=x(m);document.getElementById("statTotal").textContent=`$${t.toLocaleString()}`,document.getElementById("statCount").textContent=m.length}function P(){const t=document.getElementById("addDonorForm");t.addEventListener("submit",async e=>{e.preventDefault();const n=document.getElementById("addDonorBtn");n.disabled=!0,n.textContent="Adding...";try{await T({name:document.getElementById("donorName").value.trim(),amount:document.getElementById("donorAmount").value,classYear:document.getElementById("donorClassYear").value.trim(),message:document.getElementById("donorMessage").value.trim(),anonymous:document.getElementById("donorAnonymous").checked,date:document.getElementById("donorDate").value||null}),r("Donor added!","success"),t.reset(),await g()}catch(o){console.error("Failed to add donor:",o),r("Failed to add donor.","error")}finally{n.disabled=!1,n.textContent="Add Donor"}})}let u=[],h=[];function j(){document.getElementById("csvFile").addEventListener("change",G),document.getElementById("importBtn").addEventListener("click",O),document.getElementById("csvCancelBtn").addEventListener("click",I),document.querySelectorAll(".mapping-grid select").forEach(e=>{e.addEventListener("change",B)})}function G(t){const e=t.target.files[0];if(!e)return;const n=new FileReader;n.onload=o=>{const d=o.target.result,a=U(d);if(a.length<2){r("CSV file appears empty or has no data rows.","error");return}h=a[0],u=a.slice(1),W(),document.getElementById("csvMapping").classList.remove("hidden")},n.readAsText(e)}function U(t){const e=[];let n=[],o="",d=!1;for(let a=0;a<t.length;a++){const s=t[a],i=t[a+1];d?s==='"'&&i==='"'?(o+='"',a++):s==='"'?d=!1:o+=s:s==='"'?d=!0:s===","?(n.push(o.trim()),o=""):s===`
|
||||||
`||s==="\r"&&i===`
|
`||s==="\r"&&i===`
|
||||||
`?(n.push(o.trim()),n.some(l=>l!=="")&&e.push(n),n=[],o="",s==="\r"&&a++):o+=s}return n.push(o.trim()),n.some(a=>a!=="")&&e.push(n),e}function W(){const t=["mapName","mapAmount","mapClassYear","mapMessage","mapDate","mapAnonymous"],e={mapName:["name","donor","first","full"],mapAmount:["amount","donation","gift","total","sum"],mapClassYear:["class","year","grad"],mapMessage:["message","note","comment"],mapDate:["date","time","when"],mapAnonymous:["anonymous","anon"]};for(const n of t){const o=document.getElementById(n);o.innerHTML='<option value="">-- skip --</option>',h.forEach((s,i)=>{const l=document.createElement("option");l.value=i,l.textContent=s,o.appendChild(l)});const d=e[n],a=h.findIndex(s=>d.some(i=>s.toLowerCase().includes(i)));a!==-1&&(o.value=a)}B()}function E(t){const e=n=>{const o=document.getElementById(n).value;return o!==""&&t[Number(o)]||""};return{name:e("mapName"),amount:e("mapAmount"),classYear:e("mapClassYear"),message:e("mapMessage"),date:e("mapDate"),anonymous:e("mapAnonymous")}}function B(){const t=document.getElementById("csvPreviewHead"),e=document.getElementById("csvPreviewBody");t.innerHTML="<tr><th>Name</th><th>Amount</th><th>Class Year</th><th>Date</th><th>Message</th><th>Anon</th></tr>";const n=u.slice(0,5);e.innerHTML=n.map(o=>{const d=E(o);return`<tr>
|
`?(n.push(o.trim()),n.some(l=>l!=="")&&e.push(n),n=[],o="",s==="\r"&&a++):o+=s}return n.push(o.trim()),n.some(a=>a!=="")&&e.push(n),e}function W(){const t=["mapName","mapAmount","mapClassYear","mapMessage","mapDate","mapAnonymous"],e={mapName:["name","donor","first","full"],mapAmount:["amount","donation","gift","total","sum"],mapClassYear:["class","year","grad"],mapMessage:["message","note","comment"],mapDate:["date","time","when"],mapAnonymous:["anonymous","anon"]};for(const n of t){const o=document.getElementById(n);o.innerHTML='<option value="">-- skip --</option>',h.forEach((s,i)=>{const l=document.createElement("option");l.value=i,l.textContent=s,o.appendChild(l)});const d=e[n],a=h.findIndex(s=>d.some(i=>s.toLowerCase().includes(i)));a!==-1&&(o.value=a)}B()}function E(t){const e=n=>{const o=document.getElementById(n).value;return o!==""&&t[Number(o)]||""};return{name:e("mapName"),amount:e("mapAmount"),classYear:e("mapClassYear"),message:e("mapMessage"),date:e("mapDate"),anonymous:e("mapAnonymous")}}function B(){const t=document.getElementById("csvPreviewHead"),e=document.getElementById("csvPreviewBody");t.innerHTML="<tr><th>Name</th><th>Amount</th><th>Class Year</th><th>Date</th><th>Message</th><th>Anon</th></tr>";const n=u.slice(0,5);e.innerHTML=n.map(o=>{const d=E(o);return`<tr>
|
||||||
<td>${c(d.name)}</td>
|
<td>${c(d.name)}</td>
|
||||||
File diff suppressed because one or more lines are too long
1
dist/assets/main-BYboBf7A.css
vendored
1
dist/assets/main-BYboBf7A.css
vendored
File diff suppressed because one or more lines are too long
32
dist/assets/main-CCpTsy09.js
vendored
Normal file
32
dist/assets/main-CCpTsy09.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import{c as y,d as u,q as B,o as I,a as A,b as f,s as v,e as k,f as T,l as M,w as E,g as U,i as D,h as N,j as R,k as H,m as P,n as F,p as q,r as C}from"./donors-BfBdprwo.js";/* empty css */const S=y(u,"comments");let b=null;function O(e){const o=B(S,I("timestamp","desc"));return b=A(o,n=>{const t=[];n.forEach(a=>{t.push({id:a.id,...a.data()})}),e(t)},n=>{console.error("Error fetching comments:",n),e([])}),b}async function Y(e,o){return!e||!o.trim()?null:f(S,{userId:e.uid,userName:e.displayName||"Anonymous",userPhoto:e.photoURL||"",text:o.trim(),timestamp:v()})}async function _(e){return k(T(u,"comments",e))}const j=y(u,"students");async function W(e){const o=e.trim().toLowerCase();if(!o)return[];const n=o+"",t=B(j,E("nameLower",">=",o),E("nameLower","<=",n),I("nameLower"),M(50));try{const a=await U(t),s=[];return a.forEach(r=>{s.push({id:r.id,...r.data()})}),s}catch(a){return console.error("Error searching students:",a),[]}}const G=y(u,"subscribers");async function J(e){return f(G,{email:e,subscribedAt:v()})}const X=y(u,"pendingDonations"),z="dominica-methodist-circuit",K="https://pay.shopdm.store";async function Q({name:e,amount:o,classYear:n,message:t,anonymous:a}){return(await f(X,{name:a?"Anonymous":e,amount:Number(o),classYear:n||"",message:t||"",anonymous:!!a,status:"pending",env:"production",createdAt:v()})).id}function V(e,o,n){const t=Number(o).toFixed(2),a=`WHS 100th Anniversary Donation - ${n}`,s=new URLSearchParams({total_xcd:t,reason:a,invoice_id:e,redirect:"true"});return`${K}/${z}?${s.toString()}`}let w=[],g=[];document.addEventListener("DOMContentLoaded",()=>{D(),Z(),ee(),te(),ne(),se(),ie(),me(),ue(),le(),he(),N(re),O(de)});function Z(){const e=document.getElementById("tabNav");e.addEventListener("click",o=>{const n=o.target.closest(".tab-btn");if(!n)return;e.querySelectorAll(".tab-btn").forEach(a=>a.classList.remove("active")),n.classList.add("active"),document.querySelectorAll(".tab-panel").forEach(a=>a.classList.remove("active"));const t=document.getElementById(`tab-${n.dataset.tab}`);t&&t.classList.add("active")})}function ee(){const e=document.getElementById("carouselTrack"),o=e.querySelectorAll(".carousel-slide"),n=document.querySelectorAll(".dot"),t=document.getElementById("carouselPrev"),a=document.getElementById("carouselNext");let s=0,r;function i(c){s=(c%o.length+o.length)%o.length,e.style.transform=`translateX(-${s*100}%)`,n.forEach((p,$)=>p.classList.toggle("active",$===s))}function l(){h(),r=setInterval(()=>i(s+1),5e3)}function h(){clearInterval(r)}t.addEventListener("click",()=>{i(s-1),l()}),a.addEventListener("click",()=>{i(s+1),l()}),n.forEach(c=>{c.addEventListener("click",()=>{i(Number(c.dataset.index)),l()})}),l()}function te(){const e=window.location.href,o="Wesley High School - 100th Anniversary Fundraiser",n="Support Wesley High School's 100th Anniversary Celebrations! Help us celebrate a century of excellence.";document.getElementById("shareFacebook").addEventListener("click",()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(e)}`,"_blank","width=600,height=400")}),document.getElementById("shareTwitter").addEventListener("click",()=>{window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(n)}&url=${encodeURIComponent(e)}`,"_blank","width=600,height=400")}),document.getElementById("shareEmail").addEventListener("click",()=>{window.location.href=`mailto:?subject=${encodeURIComponent(o)}&body=${encodeURIComponent(n+`
|
||||||
|
|
||||||
|
`+e)}`})}function ne(){document.getElementById("loginGoogle").addEventListener("click",R),document.getElementById("logoutBtn").addEventListener("click",H),P(oe)}function oe(e){const o=document.getElementById("authPrompt"),n=document.getElementById("commentForm"),t=document.getElementById("userAvatar"),a=document.getElementById("userName");e?(o.classList.add("hidden"),n.classList.remove("hidden"),t.src=e.photoURL||ae(e.displayName||"U"),t.alt=e.displayName||"User",a.textContent=e.displayName||e.email||"User"):(o.classList.remove("hidden"),n.classList.add("hidden"))}function ae(e){const o=e.charAt(0).toUpperCase(),n=document.createElement("canvas");n.width=80,n.height=80;const t=n.getContext("2d");return t.fillStyle="#1a1a6e",t.fillRect(0,0,80,80),t.fillStyle="#ffffff",t.font="bold 36px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(o,40,40),n.toDataURL()}function se(){const e=document.getElementById("commentText"),o=document.getElementById("charCount"),n=document.getElementById("postCommentBtn");e.addEventListener("input",()=>{o.textContent=`${e.value.length}/500`}),n.addEventListener("click",async()=>{const t=C(),a=e.value.trim();if(!(!t||!a)){n.disabled=!0,n.textContent="Posting...";try{await Y(t,a),e.value="",o.textContent="0/500"}catch(s){console.error("Error posting comment:",s),m("Failed to post comment. Please try again.","error")}finally{n.disabled=!1,n.textContent="Post Comment"}}})}function re(e){w=e.filter(n=>!n.status||n.status==="confirmed");const o=q(e);document.getElementById("totalRaised").textContent=`$${o.toLocaleString()}`,x()}function ie(){document.getElementById("donorSort").addEventListener("change",x)}function x(){const e=document.getElementById("donorsList"),o=document.getElementById("donorsEmpty"),n=document.getElementById("donorSort").value,t=F(w,n);if(t.length===0){e.innerHTML="",e.appendChild(o),o.classList.remove("hidden");return}e.innerHTML=t.map(a=>{const s=(a.name||"A").charAt(0).toUpperCase(),r=a.date?.toDate?a.date.toDate().toLocaleDateString():"",i=a.classYear?` · Class of ${a.classYear}`:"";return`
|
||||||
|
<div class="donor-card">
|
||||||
|
<div class="donor-info">
|
||||||
|
<div class="donor-avatar">${s}</div>
|
||||||
|
<div class="donor-details">
|
||||||
|
<h4>${d(a.name)}</h4>
|
||||||
|
<p>${r}${i}</p>
|
||||||
|
${a.message?`<p style="margin-top:4px;color:#374151;font-size:0.85rem">"${d(a.message)}"</p>`:""}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="donor-amount">$${(a.amount||0).toLocaleString()}</div>
|
||||||
|
</div>`}).join("")}function de(e){g=e,ce()}function ce(){const e=document.getElementById("commentsList"),o=document.getElementById("commentsEmpty"),n=C();if(g.length===0){e.innerHTML="",e.appendChild(o),o.classList.remove("hidden");return}e.innerHTML=g.map(t=>{const a=t.timestamp?.toDate?ye(t.timestamp.toDate()):"just now",s=t.userPhoto?`<img class="comment-avatar" src="${d(t.userPhoto)}" alt="${d(t.userName)}" />`:`<div class="comment-avatar-placeholder">${(t.userName||"U").charAt(0).toUpperCase()}</div>`,r=n&&n.uid===t.userId?`<button class="comment-delete" data-id="${t.id}">Delete</button>`:"";return`
|
||||||
|
<div class="comment-card">
|
||||||
|
${s}
|
||||||
|
<div class="comment-body">
|
||||||
|
<div class="comment-header">
|
||||||
|
<span class="comment-author">${d(t.userName)}</span>
|
||||||
|
<span class="comment-time">${a}</span>
|
||||||
|
</div>
|
||||||
|
<p class="comment-text">${d(t.text)}</p>
|
||||||
|
${r}
|
||||||
|
</div>
|
||||||
|
</div>`}).join(""),e.querySelectorAll(".comment-delete").forEach(t=>{t.addEventListener("click",async()=>{if(confirm("Delete this comment?"))try{await _(t.dataset.id)}catch(a){console.error("Error deleting comment:",a),m("Failed to delete comment.","error")}})})}function le(){const e=document.getElementById("studentSearch"),o=document.getElementById("studentResults"),n=document.getElementById("studentSearchEmpty");let t;e.addEventListener("input",()=>{clearTimeout(t);const a=e.value.trim();if(!a){o.innerHTML="",o.appendChild(n),n.querySelector("p").textContent="Enter a name above to search for students.",n.classList.remove("hidden");return}t=setTimeout(async()=>{o.innerHTML='<div class="search-loading"><div class="loading-spinner"></div> Searching...</div>';const s=await W(a);if(s.length===0){o.innerHTML="",o.appendChild(n),n.querySelector("p").textContent=`No students found matching "${d(a)}".`,n.classList.remove("hidden");return}o.innerHTML=s.map(r=>`
|
||||||
|
<div class="student-card">
|
||||||
|
<div class="student-avatar">${(r.name||"?").charAt(0).toUpperCase()}</div>
|
||||||
|
<div class="student-info">
|
||||||
|
<h4>${d(r.name)}</h4>
|
||||||
|
<p>Class of ${d(String(r.classYear||"N/A"))}</p>
|
||||||
|
</div>
|
||||||
|
</div>`).join("")},350)})}function me(){const e=document.getElementById("newsletterForm"),o=e.querySelector('button[type="submit"]');e.addEventListener("submit",async n=>{n.preventDefault();const t=document.getElementById("newsletterEmail").value.trim();if(t){o.disabled=!0,o.textContent="Joining...";try{await J(t),m("Thank you for subscribing!","success"),e.reset()}catch(a){console.error("Newsletter subscribe error:",a),m("Failed to subscribe. Please try again.","error")}finally{o.disabled=!1,o.textContent="Join"}}})}function ue(){const e=document.getElementById("modalOverlay");document.getElementById("modalClose").addEventListener("click",()=>e.classList.add("hidden")),e.addEventListener("click",t=>{t.target===e&&e.classList.add("hidden")}),document.getElementById("becomeFundraiserBtn").addEventListener("click",()=>{L(`<h2>Become a Fundraiser</h2><p style="margin-top:12px">Create your own fundraising page and rally your classmates! Share the donation link with friends and family to help Wesley High School reach its goal.</p><button class="btn btn-primary open-donation-modal" style="margin-top:20px;display:inline-flex" onclick="document.getElementById('modalOverlay').classList.add('hidden');document.getElementById('donationModalOverlay').classList.remove('hidden')">Start Fundraising</button>`)});const n=document.getElementById("startFundraiserBtn");n&&n.addEventListener("click",()=>{L(`<h2>Start Your Fundraiser</h2><p style="margin-top:12px">Share the Wesley High School donation page with your network and help us celebrate 100 years!</p><button class="btn btn-primary open-donation-modal" style="margin-top:20px;display:inline-flex" onclick="document.getElementById('modalOverlay').classList.add('hidden');document.getElementById('donationModalOverlay').classList.remove('hidden')">Get Started</button>`)})}function L(e){document.getElementById("modalContent").innerHTML=e,document.getElementById("modalOverlay").classList.remove("hidden")}function he(){const e=document.getElementById("donationModalOverlay"),o=document.getElementById("donationModalClose"),n=document.getElementById("donationForm"),t=document.getElementById("donationSubmitBtn");document.querySelectorAll(".open-donation-modal").forEach(a=>{a.addEventListener("click",()=>e.classList.remove("hidden"))}),o.addEventListener("click",()=>e.classList.add("hidden")),e.addEventListener("click",a=>{a.target===e&&e.classList.add("hidden")}),n.addEventListener("submit",async a=>{a.preventDefault();const s=document.getElementById("donorName").value.trim(),r=document.getElementById("donorAmount").value,i=document.getElementById("donorClassYear").value.trim(),l=document.getElementById("donorMessage").value.trim(),h=document.getElementById("donorAnonymous").checked;if(!(!s||!r)){t.disabled=!0,t.textContent="Processing...";try{const c=await Q({name:s,amount:r,classYear:i,message:l,anonymous:h}),p=V(c,r,h?"Anonymous":s);window.open(p,"_blank"),e.classList.add("hidden"),n.reset(),m("Redirecting to payment. Complete your donation on the Shopdm Pay page.","success")}catch(c){console.error("Error creating donation:",c),m("Failed to process donation. Please try again.","error")}finally{t.disabled=!1,t.textContent="Proceed to Payment"}}})}function d(e){const o=document.createElement("div");return o.textContent=e||"",o.innerHTML}function ye(e){const o=Math.floor((Date.now()-e.getTime())/1e3);if(o<60)return"just now";const n=Math.floor(o/60);if(n<60)return`${n}m ago`;const t=Math.floor(n/60);if(t<24)return`${t}h ago`;const a=Math.floor(t/24);if(a<30)return`${a}d ago`;const s=Math.floor(a/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}function m(e,o="info"){const n=document.querySelector(".toast");n&&n.remove();const t=document.createElement("div");t.className=`toast ${o}`,t.textContent=e,document.body.appendChild(t),setTimeout(()=>t.remove(),4e3)}
|
||||||
32
dist/assets/main-f9-9VaoM.js
vendored
32
dist/assets/main-f9-9VaoM.js
vendored
@@ -1,32 +0,0 @@
|
|||||||
import{c as p,d as u,q as v,o as E,a as k,b,s as L,e as T,f as A,l as U,w as g,g as D,i as M,h as N,j as H,k as F,m as R,n as q,p as P,r as j,t as W,u as B}from"./donors-DDFnEjnq.js";const I=p(u,"comments");let y=null;function Y(t){const n=v(I,E("timestamp","desc"));return y=k(n,o=>{const e=[];o.forEach(s=>{e.push({id:s.id,...s.data()})}),t(e)},o=>{console.error("Error fetching comments:",o),t([])}),y}async function _(t,n){return!t||!n.trim()?null:b(I,{userId:t.uid,userName:t.displayName||"Anonymous",userPhoto:t.photoURL||"",text:n.trim(),timestamp:L()})}async function G(t){return T(A(u,"comments",t))}const O=p(u,"students");async function J(t){const n=t.trim().toLowerCase();if(!n)return[];const o=n+"",e=v(O,g("nameLower",">=",n),g("nameLower","<=",o),E("nameLower"),U(50));try{const s=await D(e),a=[];return s.forEach(r=>{a.push({id:r.id,...r.data()})}),a}catch(s){return console.error("Error searching students:",s),[]}}const z=p(u,"subscribers");async function X(t){return b(z,{email:t,subscribedAt:L()})}let C=[],h=[];document.addEventListener("DOMContentLoaded",()=>{M(),K(),Q(),V(),Z(),nt(),st(),ct(),dt(),it(),N(ot),Y(at)});function K(){const t=document.getElementById("tabNav");t.addEventListener("click",n=>{const o=n.target.closest(".tab-btn");if(!o)return;t.querySelectorAll(".tab-btn").forEach(s=>s.classList.remove("active")),o.classList.add("active"),document.querySelectorAll(".tab-panel").forEach(s=>s.classList.remove("active"));const e=document.getElementById(`tab-${o.dataset.tab}`);e&&e.classList.add("active")})}function Q(){const t=document.getElementById("carouselTrack"),n=t.querySelectorAll(".carousel-slide"),o=document.querySelectorAll(".dot"),e=document.getElementById("carouselPrev"),s=document.getElementById("carouselNext");let a=0,r;function c(l){a=(l%n.length+n.length)%n.length,t.style.transform=`translateX(-${a*100}%)`,o.forEach((x,$)=>x.classList.toggle("active",$===a))}function d(){S(),r=setInterval(()=>c(a+1),5e3)}function S(){clearInterval(r)}e.addEventListener("click",()=>{c(a-1),d()}),s.addEventListener("click",()=>{c(a+1),d()}),o.forEach(l=>{l.addEventListener("click",()=>{c(Number(l.dataset.index)),d()})}),d()}function V(){const t=window.location.href,n="Wesley High School - 100th Anniversary Fundraiser",o="Support Wesley High School's 100th Anniversary Celebrations! Help us celebrate a century of excellence.";document.getElementById("shareFacebook").addEventListener("click",()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(t)}`,"_blank","width=600,height=400")}),document.getElementById("shareTwitter").addEventListener("click",()=>{window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(o)}&url=${encodeURIComponent(t)}`,"_blank","width=600,height=400")}),document.getElementById("shareEmail").addEventListener("click",()=>{window.location.href=`mailto:?subject=${encodeURIComponent(n)}&body=${encodeURIComponent(o+`
|
|
||||||
|
|
||||||
`+t)}`})}function Z(){document.getElementById("loginGoogle").addEventListener("click",H),document.getElementById("loginFacebook").addEventListener("click",F),document.getElementById("loginTwitter").addEventListener("click",R),document.getElementById("logoutBtn").addEventListener("click",q),P(tt)}function tt(t){const n=document.getElementById("authPrompt"),o=document.getElementById("commentForm"),e=document.getElementById("userAvatar"),s=document.getElementById("userName");t?(n.classList.add("hidden"),o.classList.remove("hidden"),e.src=t.photoURL||et(t.displayName||"U"),e.alt=t.displayName||"User",s.textContent=t.displayName||t.email||"User"):(n.classList.remove("hidden"),o.classList.add("hidden"))}function et(t){const n=t.charAt(0).toUpperCase(),o=document.createElement("canvas");o.width=80,o.height=80;const e=o.getContext("2d");return e.fillStyle="#1a1a6e",e.fillRect(0,0,80,80),e.fillStyle="#ffffff",e.font="bold 36px Inter, sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,40,40),o.toDataURL()}function nt(){const t=document.getElementById("commentText"),n=document.getElementById("charCount"),o=document.getElementById("postCommentBtn");t.addEventListener("input",()=>{n.textContent=`${t.value.length}/500`}),o.addEventListener("click",async()=>{const e=B(),s=t.value.trim();if(!(!e||!s)){o.disabled=!0,o.textContent="Posting...";try{await _(e,s),t.value="",n.textContent="0/500"}catch(a){console.error("Error posting comment:",a),m("Failed to post comment. Please try again.","error")}finally{o.disabled=!1,o.textContent="Post Comment"}}})}function ot(t){C=t;const n=W(t);document.getElementById("totalRaised").textContent=`$${n.toLocaleString()}`,w()}function st(){document.getElementById("donorSort").addEventListener("change",w)}function w(){const t=document.getElementById("donorsList"),n=document.getElementById("donorsEmpty"),o=document.getElementById("donorSort").value,e=j(C,o);if(e.length===0){t.innerHTML="",t.appendChild(n),n.classList.remove("hidden");return}t.innerHTML=e.map(s=>{const a=(s.name||"A").charAt(0).toUpperCase(),r=s.date?.toDate?s.date.toDate().toLocaleDateString():"",c=s.classYear?` · Class of ${s.classYear}`:"";return`
|
|
||||||
<div class="donor-card">
|
|
||||||
<div class="donor-info">
|
|
||||||
<div class="donor-avatar">${a}</div>
|
|
||||||
<div class="donor-details">
|
|
||||||
<h4>${i(s.name)}</h4>
|
|
||||||
<p>${r}${c}</p>
|
|
||||||
${s.message?`<p style="margin-top:4px;color:#374151;font-size:0.85rem">"${i(s.message)}"</p>`:""}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="donor-amount">$${(s.amount||0).toLocaleString()}</div>
|
|
||||||
</div>`}).join("")}function at(t){h=t,rt()}function rt(){const t=document.getElementById("commentsList"),n=document.getElementById("commentsEmpty"),o=B();if(h.length===0){t.innerHTML="",t.appendChild(n),n.classList.remove("hidden");return}t.innerHTML=h.map(e=>{const s=e.timestamp?.toDate?lt(e.timestamp.toDate()):"just now",a=e.userPhoto?`<img class="comment-avatar" src="${i(e.userPhoto)}" alt="${i(e.userName)}" />`:`<div class="comment-avatar-placeholder">${(e.userName||"U").charAt(0).toUpperCase()}</div>`,r=o&&o.uid===e.userId?`<button class="comment-delete" data-id="${e.id}">Delete</button>`:"";return`
|
|
||||||
<div class="comment-card">
|
|
||||||
${a}
|
|
||||||
<div class="comment-body">
|
|
||||||
<div class="comment-header">
|
|
||||||
<span class="comment-author">${i(e.userName)}</span>
|
|
||||||
<span class="comment-time">${s}</span>
|
|
||||||
</div>
|
|
||||||
<p class="comment-text">${i(e.text)}</p>
|
|
||||||
${r}
|
|
||||||
</div>
|
|
||||||
</div>`}).join(""),t.querySelectorAll(".comment-delete").forEach(e=>{e.addEventListener("click",async()=>{if(confirm("Delete this comment?"))try{await G(e.dataset.id)}catch(s){console.error("Error deleting comment:",s),m("Failed to delete comment.","error")}})})}function it(){const t=document.getElementById("studentSearch"),n=document.getElementById("studentResults"),o=document.getElementById("studentSearchEmpty");let e;t.addEventListener("input",()=>{clearTimeout(e);const s=t.value.trim();if(!s){n.innerHTML="",n.appendChild(o),o.querySelector("p").textContent="Enter a name above to search for students.",o.classList.remove("hidden");return}e=setTimeout(async()=>{n.innerHTML='<div class="search-loading"><div class="loading-spinner"></div> Searching...</div>';const a=await J(s);if(a.length===0){n.innerHTML="",n.appendChild(o),o.querySelector("p").textContent=`No students found matching "${i(s)}".`,o.classList.remove("hidden");return}n.innerHTML=a.map(r=>`
|
|
||||||
<div class="student-card">
|
|
||||||
<div class="student-avatar">${(r.name||"?").charAt(0).toUpperCase()}</div>
|
|
||||||
<div class="student-info">
|
|
||||||
<h4>${i(r.name)}</h4>
|
|
||||||
<p>Class of ${i(String(r.classYear||"N/A"))}</p>
|
|
||||||
</div>
|
|
||||||
</div>`).join("")},350)})}function ct(){const t=document.getElementById("newsletterForm"),n=t.querySelector('button[type="submit"]');t.addEventListener("submit",async o=>{o.preventDefault();const e=document.getElementById("newsletterEmail").value.trim();if(e){n.disabled=!0,n.textContent="Joining...";try{await X(e),m("Thank you for subscribing!","success"),t.reset()}catch(s){console.error("Newsletter subscribe error:",s),m("Failed to subscribe. Please try again.","error")}finally{n.disabled=!1,n.textContent="Join"}}})}function dt(){const t=document.getElementById("modalOverlay");document.getElementById("modalClose").addEventListener("click",()=>t.classList.add("hidden")),t.addEventListener("click",e=>{e.target===t&&t.classList.add("hidden")}),document.getElementById("becomeFundraiserBtn").addEventListener("click",()=>{f('<h2>Become a Fundraiser</h2><p style="margin-top:12px">Create your own fundraising page and rally your classmates! Share the donation link with friends and family to help Wesley High School reach its goal.</p><a href="https://pay.shopdm.store/dominica-methodist-circuit" target="_blank" rel="noopener" class="btn btn-primary" style="margin-top:20px;display:inline-flex">Start Fundraising</a>')});const o=document.getElementById("startFundraiserBtn");o&&o.addEventListener("click",()=>{f('<h2>Start Your Fundraiser</h2><p style="margin-top:12px">Share the Wesley High School donation page with your network and help us celebrate 100 years!</p><a href="https://pay.shopdm.store/dominica-methodist-circuit" target="_blank" rel="noopener" class="btn btn-primary" style="margin-top:20px;display:inline-flex">Get Started</a>')})}function f(t){document.getElementById("modalContent").innerHTML=t,document.getElementById("modalOverlay").classList.remove("hidden")}function i(t){const n=document.createElement("div");return n.textContent=t||"",n.innerHTML}function lt(t){const n=Math.floor((Date.now()-t.getTime())/1e3);if(n<60)return"just now";const o=Math.floor(n/60);if(o<60)return`${o}m ago`;const e=Math.floor(o/60);if(e<24)return`${e}h ago`;const s=Math.floor(e/24);if(s<30)return`${s}d ago`;const a=Math.floor(s/30);return a<12?`${a}mo ago`:`${Math.floor(a/12)}y ago`}function m(t,n="info"){const o=document.querySelector(".toast");o&&o.remove();const e=document.createElement("div");e.className=`toast ${n}`,e.textContent=t,document.body.appendChild(e),setTimeout(()=>e.remove(),4e3)}
|
|
||||||
1
dist/assets/style-B2qcWQAK.css
vendored
Normal file
1
dist/assets/style-B2qcWQAK.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
dist/images/logo-black.jpeg
vendored
Normal file
BIN
dist/images/logo-black.jpeg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 224 KiB |
BIN
dist/images/logo-blue.jpeg
vendored
Normal file
BIN
dist/images/logo-blue.jpeg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 253 KiB |
BIN
dist/images/logo-blue.png
vendored
Normal file
BIN
dist/images/logo-blue.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1022 KiB |
BIN
dist/images/logo-orange.jpeg
vendored
Normal file
BIN
dist/images/logo-orange.jpeg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 182 KiB |
58
dist/index.html
vendored
58
dist/index.html
vendored
@@ -9,9 +9,9 @@
|
|||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
||||||
<script type="module" crossorigin src="/assets/main-f9-9VaoM.js"></script>
|
<script type="module" crossorigin src="/assets/main-CCpTsy09.js"></script>
|
||||||
<link rel="modulepreload" crossorigin href="/assets/donors-DDFnEjnq.js">
|
<link rel="modulepreload" crossorigin href="/assets/donors-BfBdprwo.js">
|
||||||
<link rel="stylesheet" crossorigin href="/assets/main-BYboBf7A.css">
|
<link rel="stylesheet" crossorigin href="/assets/style-B2qcWQAK.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- Top Header Bar -->
|
<!-- Top Header Bar -->
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<svg viewBox="0 0 24 24" fill="currentColor" width="20" height="20"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/></svg>
|
<svg viewBox="0 0 24 24" fill="currentColor" width="20" height="20"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/></svg>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<a href="https://pay.shopdm.store/dominica-methodist-circuit" target="_blank" rel="noopener" class="btn btn-donate-header">Donate</a>
|
<button class="btn btn-donate-header open-donation-modal">Donate</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
<span class="amount" id="totalRaised">$0</span>
|
<span class="amount" id="totalRaised">$0</span>
|
||||||
<span class="label">Total Raised</span>
|
<span class="label">Total Raised</span>
|
||||||
</div>
|
</div>
|
||||||
<a href="https://pay.shopdm.store/dominica-methodist-circuit" target="_blank" rel="noopener" class="btn btn-primary btn-large">Make a Donation</a>
|
<button class="btn btn-primary btn-large open-donation-modal">Make a Donation</button>
|
||||||
<button class="btn btn-outline btn-large" id="becomeFundraiserBtn">Become a Fundraiser</button>
|
<button class="btn btn-outline btn-large" id="becomeFundraiserBtn">Become a Fundraiser</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,7 +154,7 @@
|
|||||||
<p>Wesley High School has been a cornerstone of education in Dominica since 1926. As we celebrate our centennial, we invite all alumni, students, and supporters to contribute to our legacy.</p>
|
<p>Wesley High School has been a cornerstone of education in Dominica since 1926. As we celebrate our centennial, we invite all alumni, students, and supporters to contribute to our legacy.</p>
|
||||||
<p>Our goal is to raise funds that will support scholarships, and a science lab for our students.</p>
|
<p>Our goal is to raise funds that will support scholarships, and a science lab for our students.</p>
|
||||||
<div class="about-cta">
|
<div class="about-cta">
|
||||||
<a href="https://pay.shopdm.store/dominica-methodist-circuit" target="_blank" rel="noopener" class="btn btn-primary">Donate Now</a>
|
<button class="btn btn-primary open-donation-modal">Donate Now</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Share Section -->
|
<!-- Share Section -->
|
||||||
@@ -218,7 +218,7 @@
|
|||||||
<div class="donors-list" id="donorsList">
|
<div class="donors-list" id="donorsList">
|
||||||
<div class="empty-state" id="donorsEmpty">
|
<div class="empty-state" id="donorsEmpty">
|
||||||
<p>No donations yet. Be the first to donate!</p>
|
<p>No donations yet. Be the first to donate!</p>
|
||||||
<a href="https://pay.shopdm.store/dominica-methodist-circuit" target="_blank" rel="noopener" class="btn btn-primary">Make a Donation</a>
|
<button class="btn btn-primary open-donation-modal">Make a Donation</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -235,14 +235,6 @@
|
|||||||
<svg viewBox="0 0 24 24" width="18" height="18"><path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"/><path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/><path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/><path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/></svg>
|
<svg viewBox="0 0 24 24" width="18" height="18"><path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"/><path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/><path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/><path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/></svg>
|
||||||
Sign in with Google
|
Sign in with Google
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-auth btn-facebook" id="loginFacebook">
|
|
||||||
<svg viewBox="0 0 24 24" fill="#fff" width="18" height="18"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>
|
|
||||||
Sign in with Facebook
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-auth btn-twitter" id="loginTwitter">
|
|
||||||
<svg viewBox="0 0 24 24" fill="#fff" width="18" height="18"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
|
|
||||||
Sign in with X
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-form hidden" id="commentForm">
|
<div class="comment-form hidden" id="commentForm">
|
||||||
@@ -297,6 +289,42 @@
|
|||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
<!-- Donation Modal -->
|
||||||
|
<div class="modal-overlay hidden" id="donationModalOverlay">
|
||||||
|
<div class="modal" id="donationModal">
|
||||||
|
<button class="modal-close" id="donationModalClose">×</button>
|
||||||
|
<div class="modal-content">
|
||||||
|
<h2>Make a Donation</h2>
|
||||||
|
<p style="margin-top:8px;color:#4b5563">Your information will appear on our donors wall after payment.</p>
|
||||||
|
<form id="donationForm" class="donation-form">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="donorName">Name <span class="required">*</span></label>
|
||||||
|
<input type="text" id="donorName" placeholder="Your full name" required />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="donorAmount">Amount (XCD) <span class="required">*</span></label>
|
||||||
|
<input type="number" id="donorAmount" placeholder="e.g. 100" min="1" step="0.01" required />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="donorClassYear">Class Year <span class="optional">(optional)</span></label>
|
||||||
|
<input type="text" id="donorClassYear" placeholder="e.g. 1995" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="donorMessage">Message <span class="optional">(optional)</span></label>
|
||||||
|
<textarea id="donorMessage" placeholder="Leave a message of support..." rows="3" maxlength="255"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="checkbox-label">
|
||||||
|
<input type="checkbox" id="donorAnonymous" />
|
||||||
|
Make my donation anonymous
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary btn-large" id="donationSubmitBtn">Proceed to Payment</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Login Modal (for showing auth errors) -->
|
<!-- Login Modal (for showing auth errors) -->
|
||||||
<div class="modal-overlay hidden" id="modalOverlay">
|
<div class="modal-overlay hidden" id="modalOverlay">
|
||||||
<div class="modal" id="modal">
|
<div class="modal" id="modal">
|
||||||
|
|||||||
82
dist/thank-you.html
vendored
Normal file
82
dist/thank-you.html
vendored
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Thank You - Wesley High School Fundraiser</title>
|
||||||
|
<meta name="description" content="Thank you for your donation to Wesley High School's 100th Anniversary Celebrations." />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/images/favicon.svg" />
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
||||||
|
<link rel="stylesheet" crossorigin href="/assets/style-B2qcWQAK.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- Top Header Bar -->
|
||||||
|
<header class="top-bar">
|
||||||
|
<div class="top-bar-inner">
|
||||||
|
<div class="top-bar-left">
|
||||||
|
<a href="/">
|
||||||
|
<img src="/images/logo-white.png" alt="Wesley High School" class="top-bar-logo" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="top-bar-right">
|
||||||
|
<div class="social-icons">
|
||||||
|
<a href="https://www.facebook.com/WesleyHighSchoolDominica" target="_blank" rel="noopener" aria-label="Facebook" class="social-icon">
|
||||||
|
<svg viewBox="0 0 24 24" fill="currentColor" width="20" height="20"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="thank-you-page">
|
||||||
|
<div class="thank-you-card">
|
||||||
|
<div class="thank-you-icon">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="64" height="64">
|
||||||
|
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
|
||||||
|
<polyline points="22 4 12 14.01 9 11.01" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<h1>Thank You for Your Donation!</h1>
|
||||||
|
<p>Your generous contribution to the Wesley High School 100th Anniversary Fund has been received and is being processed.</p>
|
||||||
|
<p>Your name will appear on our donors wall shortly. Together, we are building the next 100 years of excellence.</p>
|
||||||
|
<div class="thank-you-actions">
|
||||||
|
<a href="/" class="btn btn-primary btn-large">Return to Homepage</a>
|
||||||
|
<div class="share-section">
|
||||||
|
<p class="share-prompt">Spread the word and help us reach our goal!</p>
|
||||||
|
<div class="share-buttons">
|
||||||
|
<button class="share-btn share-facebook" id="shareFacebook">
|
||||||
|
<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>
|
||||||
|
Share on Facebook
|
||||||
|
</button>
|
||||||
|
<button class="share-btn share-email" id="shareEmail">
|
||||||
|
<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18"><path d="M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>
|
||||||
|
Share via Email
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="site-footer">
|
||||||
|
<div class="footer-bottom">
|
||||||
|
<p>Copyright © 2026 Wesley High School. All rights reserved.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const siteUrl = 'https://alumni.whsdominica.com/';
|
||||||
|
const text = 'I just donated to Wesley High School\'s 100th Anniversary Fund! Join me in supporting a century of excellence.';
|
||||||
|
|
||||||
|
document.getElementById('shareFacebook').addEventListener('click', () => {
|
||||||
|
window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(siteUrl), '_blank', 'width=600,height=400');
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('shareEmail').addEventListener('click', () => {
|
||||||
|
window.location.href = 'mailto:?subject=' + encodeURIComponent('Support Wesley High School') + '&body=' + encodeURIComponent(text + '\n\n' + siteUrl);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -11,5 +11,8 @@
|
|||||||
},
|
},
|
||||||
"firestore": {
|
"firestore": {
|
||||||
"rules": "firestore.rules"
|
"rules": "firestore.rules"
|
||||||
|
},
|
||||||
|
"functions": {
|
||||||
|
"source": "functions"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
124
functions/index.js
Normal file
124
functions/index.js
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
const { onRequest } = require("firebase-functions/v2/https");
|
||||||
|
const { initializeApp } = require("firebase-admin/app");
|
||||||
|
const { getFirestore, FieldValue } = require("firebase-admin/firestore");
|
||||||
|
const crypto = require("crypto");
|
||||||
|
|
||||||
|
initializeApp();
|
||||||
|
const db = getFirestore();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shopdm Pay Webhook Handler
|
||||||
|
*
|
||||||
|
* Receives payment.successful events from Shopdm Pay.
|
||||||
|
* Matches the invoice_id to a pending donation and creates
|
||||||
|
* a confirmed donor record.
|
||||||
|
*/
|
||||||
|
exports.shopdmPayWebhook = onRequest(
|
||||||
|
{ secrets: ["SHOPDM_MERCHANT_SECRET_DEV"] },
|
||||||
|
async (req, res) => {
|
||||||
|
// Only accept POST requests
|
||||||
|
if (req.method !== "POST") {
|
||||||
|
res.status(405).send("Method not allowed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = req.body;
|
||||||
|
|
||||||
|
// Verify webhook signature
|
||||||
|
// Supports both dev and prod secrets
|
||||||
|
const secrets = [
|
||||||
|
process.env.SHOPDM_MERCHANT_SECRET,
|
||||||
|
process.env.SHOPDM_MERCHANT_SECRET_DEV,
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
if (secrets.length > 0) {
|
||||||
|
const signature = req.headers["x-shopdm-signature"];
|
||||||
|
if (!signature) {
|
||||||
|
console.error("Missing X-Shopdm-Signature header");
|
||||||
|
res.status(401).send("Unauthorized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sortedPayload = JSON.stringify(
|
||||||
|
payload,
|
||||||
|
Object.keys(payload).sort()
|
||||||
|
);
|
||||||
|
|
||||||
|
const isValid = secrets.some((secret) => {
|
||||||
|
const expected = crypto
|
||||||
|
.createHmac("sha256", secret)
|
||||||
|
.update(sortedPayload, "utf8")
|
||||||
|
.digest("hex");
|
||||||
|
return signature === expected;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isValid) {
|
||||||
|
console.error("Invalid webhook signature");
|
||||||
|
res.status(401).send("Unauthorized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only process successful payments
|
||||||
|
if (payload.event !== "payment.successful") {
|
||||||
|
res.status(200).send("Event ignored");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const invoiceId = payload.metadata?.invoice_id;
|
||||||
|
if (!invoiceId) {
|
||||||
|
console.log("No invoice_id in webhook payload, skipping donor creation");
|
||||||
|
res.status(200).send("OK - no invoice_id");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Look up the pending donation
|
||||||
|
const pendingRef = db.collection("pendingDonations").doc(invoiceId);
|
||||||
|
const pendingDoc = await pendingRef.get();
|
||||||
|
|
||||||
|
if (!pendingDoc.exists) {
|
||||||
|
console.log(`No pending donation found for invoice_id: ${invoiceId}`);
|
||||||
|
res.status(200).send("OK - no matching pending donation");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pending = pendingDoc.data();
|
||||||
|
|
||||||
|
// Check if already processed (idempotency)
|
||||||
|
if (pending.status === "confirmed") {
|
||||||
|
console.log(`Donation ${invoiceId} already confirmed, skipping`);
|
||||||
|
res.status(200).send("OK - already processed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the actual payment amount from the webhook
|
||||||
|
const paidAmount = payload.data?.amount_xcd || pending.amount;
|
||||||
|
|
||||||
|
// Create the confirmed donor record
|
||||||
|
await db.collection("donors").add({
|
||||||
|
name: pending.name,
|
||||||
|
amount: Number(paidAmount),
|
||||||
|
classYear: pending.classYear || "",
|
||||||
|
message: pending.message || "",
|
||||||
|
anonymous: !!pending.anonymous,
|
||||||
|
status: "confirmed",
|
||||||
|
pendingDonationId: invoiceId,
|
||||||
|
paymentId: payload.data?.object_id || "",
|
||||||
|
date: FieldValue.serverTimestamp(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mark the pending donation as confirmed
|
||||||
|
await pendingRef.update({
|
||||||
|
status: "confirmed",
|
||||||
|
confirmedAt: FieldValue.serverTimestamp(),
|
||||||
|
paymentId: payload.data?.object_id || "",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`Donation confirmed for invoice_id: ${invoiceId}, amount: ${paidAmount}`);
|
||||||
|
res.status(200).send("OK");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error processing webhook:", error);
|
||||||
|
res.status(500).send("Internal server error");
|
||||||
|
}
|
||||||
|
});
|
||||||
1
functions/node_modules/.bin/firebase-functions
generated
vendored
Symbolic link
1
functions/node_modules/.bin/firebase-functions
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../firebase-functions/lib/bin/firebase-functions.js
|
||||||
1
functions/node_modules/.bin/fxparser
generated
vendored
Symbolic link
1
functions/node_modules/.bin/fxparser
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../fast-xml-parser/src/cli/cli.js
|
||||||
1
functions/node_modules/.bin/mime
generated
vendored
Symbolic link
1
functions/node_modules/.bin/mime
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../mime/cli.js
|
||||||
1
functions/node_modules/.bin/proto-loader-gen-types
generated
vendored
Symbolic link
1
functions/node_modules/.bin/proto-loader-gen-types
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../@grpc/proto-loader/build/bin/proto-loader-gen-types.js
|
||||||
1
functions/node_modules/.bin/semver
generated
vendored
Symbolic link
1
functions/node_modules/.bin/semver
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../semver/bin/semver.js
|
||||||
1
functions/node_modules/.bin/uuid
generated
vendored
Symbolic link
1
functions/node_modules/.bin/uuid
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../uuid/dist/bin/uuid
|
||||||
2471
functions/node_modules/.package-lock.json
generated
vendored
Normal file
2471
functions/node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
functions/node_modules/@fastify/busboy/LICENSE
generated
vendored
Normal file
24
functions/node_modules/@fastify/busboy/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright Brian White. All rights reserved.
|
||||||
|
Copyright (c) 2021-present The Fastify team
|
||||||
|
|
||||||
|
The Fastify team members are listed at https://github.com/fastify/fastify#team.
|
||||||
|
|
||||||
|
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.
|
||||||
270
functions/node_modules/@fastify/busboy/README.md
generated
vendored
Normal file
270
functions/node_modules/@fastify/busboy/README.md
generated
vendored
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
# busboy
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
[](https://github.com/fastify/busboy/actions)
|
||||||
|
[](https://standardjs.com/)
|
||||||
|
[](https://github.com/fastify/.github/blob/main/SECURITY.md)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
[](https://www.npmjs.com/package/@fastify/busboy)
|
||||||
|
[](https://www.npmjs.com/package/@fastify/busboy)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Description
|
||||||
|
===========
|
||||||
|
|
||||||
|
A Node.js module for parsing incoming HTML form data.
|
||||||
|
|
||||||
|
This is an officially supported fork by [fastify](https://github.com/fastify/) organization of the amazing library [originally created](https://github.com/mscdex/busboy) by Brian White,
|
||||||
|
aimed at addressing long-standing issues with it.
|
||||||
|
|
||||||
|
Benchmark (Mean time for 500 Kb payload, 2000 cycles, 1000 cycle warmup):
|
||||||
|
|
||||||
|
| Library | Version | Mean time in nanoseconds (less is better) |
|
||||||
|
|-----------------------|---------|-------------------------------------------|
|
||||||
|
| busboy | 0.3.1 | `340114` |
|
||||||
|
| @fastify/busboy | 1.0.0 | `270984` |
|
||||||
|
|
||||||
|
[Changelog](https://github.com/fastify/busboy/blob/main/CHANGELOG.md) since busboy 0.31.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
============
|
||||||
|
|
||||||
|
* [Node.js](http://nodejs.org/) 10+
|
||||||
|
|
||||||
|
|
||||||
|
Install
|
||||||
|
=======
|
||||||
|
|
||||||
|
npm i @fastify/busboy
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
========
|
||||||
|
|
||||||
|
* Parsing (multipart) with default options:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const http = require('node:http');
|
||||||
|
const { inspect } = require('node:util');
|
||||||
|
const Busboy = require('@fastify/busboy');
|
||||||
|
|
||||||
|
http.createServer((req, res) => {
|
||||||
|
if (req.method === 'POST') {
|
||||||
|
const busboy = new Busboy({ headers: req.headers });
|
||||||
|
busboy.on('file', (fieldname, file, filename, encoding, mimetype) => {
|
||||||
|
console.log(`File [${fieldname}]: filename: ${filename}, encoding: ${encoding}, mimetype: ${mimetype}`);
|
||||||
|
file.on('data', data => {
|
||||||
|
console.log(`File [${fieldname}] got ${data.length} bytes`);
|
||||||
|
});
|
||||||
|
file.on('end', () => {
|
||||||
|
console.log(`File [${fieldname}] Finished`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
busboy.on('field', (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) => {
|
||||||
|
console.log(`Field [${fieldname}]: value: ${inspect(val)}`);
|
||||||
|
});
|
||||||
|
busboy.on('finish', () => {
|
||||||
|
console.log('Done parsing form!');
|
||||||
|
res.writeHead(303, { Connection: 'close', Location: '/' });
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
|
req.pipe(busboy);
|
||||||
|
} else if (req.method === 'GET') {
|
||||||
|
res.writeHead(200, { Connection: 'close' });
|
||||||
|
res.end(`<html><head></head><body>
|
||||||
|
<form method="POST" enctype="multipart/form-data">
|
||||||
|
<input type="text" name="textfield"><br>
|
||||||
|
<input type="file" name="filefield"><br>
|
||||||
|
<input type="submit">
|
||||||
|
</form>
|
||||||
|
</body></html>`);
|
||||||
|
}
|
||||||
|
}).listen(8000, () => {
|
||||||
|
console.log('Listening for requests');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Example output, using http://nodejs.org/images/ryan-speaker.jpg as the file:
|
||||||
|
//
|
||||||
|
// Listening for requests
|
||||||
|
// File [filefield]: filename: ryan-speaker.jpg, encoding: binary
|
||||||
|
// File [filefield] got 11971 bytes
|
||||||
|
// Field [textfield]: value: 'testing! :-)'
|
||||||
|
// File [filefield] Finished
|
||||||
|
// Done parsing form!
|
||||||
|
```
|
||||||
|
|
||||||
|
* Save all incoming files to disk:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const http = require('node:http');
|
||||||
|
const path = require('node:path');
|
||||||
|
const os = require('node:os');
|
||||||
|
const fs = require('node:fs');
|
||||||
|
|
||||||
|
const Busboy = require('@fastify/busboy');
|
||||||
|
|
||||||
|
http.createServer(function(req, res) {
|
||||||
|
if (req.method === 'POST') {
|
||||||
|
const busboy = new Busboy({ headers: req.headers });
|
||||||
|
busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
|
||||||
|
var saveTo = path.join(os.tmpdir(), path.basename(fieldname));
|
||||||
|
file.pipe(fs.createWriteStream(saveTo));
|
||||||
|
});
|
||||||
|
busboy.on('finish', function() {
|
||||||
|
res.writeHead(200, { 'Connection': 'close' });
|
||||||
|
res.end("That's all folks!");
|
||||||
|
});
|
||||||
|
return req.pipe(busboy);
|
||||||
|
}
|
||||||
|
res.writeHead(404);
|
||||||
|
res.end();
|
||||||
|
}).listen(8000, function() {
|
||||||
|
console.log('Listening for requests');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
* Parsing (urlencoded) with default options:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const http = require('node:http');
|
||||||
|
const { inspect } = require('node:util');
|
||||||
|
|
||||||
|
const Busboy = require('@fastify/busboy');
|
||||||
|
|
||||||
|
http.createServer(function(req, res) {
|
||||||
|
if (req.method === 'POST') {
|
||||||
|
const busboy = new Busboy({ headers: req.headers });
|
||||||
|
busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
|
||||||
|
console.log('File [' + fieldname + ']: filename: ' + filename);
|
||||||
|
file.on('data', function(data) {
|
||||||
|
console.log('File [' + fieldname + '] got ' + data.length + ' bytes');
|
||||||
|
});
|
||||||
|
file.on('end', function() {
|
||||||
|
console.log('File [' + fieldname + '] Finished');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated) {
|
||||||
|
console.log('Field [' + fieldname + ']: value: ' + inspect(val));
|
||||||
|
});
|
||||||
|
busboy.on('finish', function() {
|
||||||
|
console.log('Done parsing form!');
|
||||||
|
res.writeHead(303, { Connection: 'close', Location: '/' });
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
|
req.pipe(busboy);
|
||||||
|
} else if (req.method === 'GET') {
|
||||||
|
res.writeHead(200, { Connection: 'close' });
|
||||||
|
res.end('<html><head></head><body>\
|
||||||
|
<form method="POST">\
|
||||||
|
<input type="text" name="textfield"><br />\
|
||||||
|
<select name="selectfield">\
|
||||||
|
<option value="1">1</option>\
|
||||||
|
<option value="10">10</option>\
|
||||||
|
<option value="100">100</option>\
|
||||||
|
<option value="9001">9001</option>\
|
||||||
|
</select><br />\
|
||||||
|
<input type="checkbox" name="checkfield">Node.js rules!<br />\
|
||||||
|
<input type="submit">\
|
||||||
|
</form>\
|
||||||
|
</body></html>');
|
||||||
|
}
|
||||||
|
}).listen(8000, function() {
|
||||||
|
console.log('Listening for requests');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Example output:
|
||||||
|
//
|
||||||
|
// Listening for requests
|
||||||
|
// Field [textfield]: value: 'testing! :-)'
|
||||||
|
// Field [selectfield]: value: '9001'
|
||||||
|
// Field [checkfield]: value: 'on'
|
||||||
|
// Done parsing form!
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
API
|
||||||
|
===
|
||||||
|
|
||||||
|
_Busboy_ is a _Writable_ stream
|
||||||
|
|
||||||
|
Busboy (special) events
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
* **file**(< _string_ >fieldname, < _ReadableStream_ >stream, < _string_ >filename, < _string_ >transferEncoding, < _string_ >mimeType) - Emitted for each new file form field found. `transferEncoding` contains the 'Content-Transfer-Encoding' value for the file stream. `mimeType` contains the 'Content-Type' value for the file stream.
|
||||||
|
* Note: if you listen for this event, you should always handle the `stream` no matter if you care about the file contents or not (e.g. you can simply just do `stream.resume();` if you want to discard the contents), otherwise the 'finish' event will never fire on the Busboy instance. However, if you don't care about **any** incoming files, you can simply not listen for the 'file' event at all and any/all files will be automatically and safely discarded (these discarded files do still count towards `files` and `parts` limits).
|
||||||
|
* If a configured file size limit was reached, `stream` will both have a boolean property `truncated` (best checked at the end of the stream) and emit a 'limit' event to notify you when this happens.
|
||||||
|
* The property `bytesRead` informs about the number of bytes that have been read so far.
|
||||||
|
|
||||||
|
* **field**(< _string_ >fieldname, < _string_ >value, < _boolean_ >fieldnameTruncated, < _boolean_ >valueTruncated, < _string_ >transferEncoding, < _string_ >mimeType) - Emitted for each new non-file field found.
|
||||||
|
|
||||||
|
* **partsLimit**() - Emitted when specified `parts` limit has been reached. No more 'file' or 'field' events will be emitted.
|
||||||
|
|
||||||
|
* **filesLimit**() - Emitted when specified `files` limit has been reached. No more 'file' events will be emitted.
|
||||||
|
|
||||||
|
* **fieldsLimit**() - Emitted when specified `fields` limit has been reached. No more 'field' events will be emitted.
|
||||||
|
|
||||||
|
|
||||||
|
Busboy methods
|
||||||
|
--------------
|
||||||
|
|
||||||
|
* **(constructor)**(< _object_ >config) - Creates and returns a new Busboy instance.
|
||||||
|
|
||||||
|
* The constructor takes the following valid `config` settings:
|
||||||
|
|
||||||
|
* **headers** - _object_ - These are the HTTP headers of the incoming request, which are used by individual parsers.
|
||||||
|
|
||||||
|
* **autoDestroy** - _boolean_ - Whether this stream should automatically call .destroy() on itself after ending. (Default: false).
|
||||||
|
|
||||||
|
* **highWaterMark** - _integer_ - highWaterMark to use for this Busboy instance (Default: WritableStream default).
|
||||||
|
|
||||||
|
* **fileHwm** - _integer_ - highWaterMark to use for file streams (Default: ReadableStream default).
|
||||||
|
|
||||||
|
* **defCharset** - _string_ - Default character set to use when one isn't defined (Default: 'utf8').
|
||||||
|
|
||||||
|
* **preservePath** - _boolean_ - If paths in the multipart 'filename' field shall be preserved. (Default: false).
|
||||||
|
|
||||||
|
* **isPartAFile** - __function__ - Use this function to override the default file detection functionality. It has following parameters:
|
||||||
|
|
||||||
|
* fieldName - __string__ The name of the field.
|
||||||
|
|
||||||
|
* contentType - __string__ The content-type of the part, e.g. `text/plain`, `image/jpeg`, `application/octet-stream`
|
||||||
|
|
||||||
|
* fileName - __string__ The name of a file supplied by the part.
|
||||||
|
|
||||||
|
(Default: `(fieldName, contentType, fileName) => (contentType === 'application/octet-stream' || fileName !== undefined)`)
|
||||||
|
|
||||||
|
* **limits** - _object_ - Various limits on incoming data. Valid properties are:
|
||||||
|
|
||||||
|
* **fieldNameSize** - _integer_ - Max field name size (in bytes) (Default: 100 bytes).
|
||||||
|
|
||||||
|
* **fieldSize** - _integer_ - Max field value size (in bytes) (Default: 1 MiB, which is 1024 x 1024 bytes).
|
||||||
|
|
||||||
|
* **fields** - _integer_ - Max number of non-file fields (Default: Infinity).
|
||||||
|
|
||||||
|
* **fileSize** - _integer_ - For multipart forms, the max file size (in bytes) (Default: Infinity).
|
||||||
|
|
||||||
|
* **files** - _integer_ - For multipart forms, the max number of file fields (Default: Infinity).
|
||||||
|
|
||||||
|
* **parts** - _integer_ - For multipart forms, the max number of parts (fields + files) (Default: Infinity).
|
||||||
|
|
||||||
|
* **headerPairs** - _integer_ - For multipart forms, the max number of header key=>value pairs to parse **Default:** 2000
|
||||||
|
|
||||||
|
* **headerSize** - _integer_ - For multipart forms, the max size of a multipart header **Default:** 81920.
|
||||||
|
|
||||||
|
* The constructor can throw errors:
|
||||||
|
|
||||||
|
* **Busboy expected an options-Object.** - Busboy expected an Object as first parameters.
|
||||||
|
|
||||||
|
* **Busboy expected an options-Object with headers-attribute.** - The first parameter is lacking of a headers-attribute.
|
||||||
|
|
||||||
|
* **Limit $limit is not a valid number** - Busboy expected the desired limit to be of type number. Busboy throws this Error to prevent a potential security issue by falling silently back to the Busboy-defaults. Potential source for this Error can be the direct use of environment variables without transforming them to the type number.
|
||||||
|
|
||||||
|
* **Unsupported Content-Type.** - The `Content-Type` isn't one Busboy can parse.
|
||||||
|
|
||||||
|
* **Missing Content-Type-header.** - The provided headers don't include `Content-Type` at all.
|
||||||
19
functions/node_modules/@fastify/busboy/deps/dicer/LICENSE
generated
vendored
Normal file
19
functions/node_modules/@fastify/busboy/deps/dicer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright Brian White. All rights reserved.
|
||||||
|
|
||||||
|
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.
|
||||||
213
functions/node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js
generated
vendored
Normal file
213
functions/node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js
generated
vendored
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const WritableStream = require('node:stream').Writable
|
||||||
|
const inherits = require('node:util').inherits
|
||||||
|
|
||||||
|
const StreamSearch = require('../../streamsearch/sbmh')
|
||||||
|
|
||||||
|
const PartStream = require('./PartStream')
|
||||||
|
const HeaderParser = require('./HeaderParser')
|
||||||
|
|
||||||
|
const DASH = 45
|
||||||
|
const B_ONEDASH = Buffer.from('-')
|
||||||
|
const B_CRLF = Buffer.from('\r\n')
|
||||||
|
const EMPTY_FN = function () {}
|
||||||
|
|
||||||
|
function Dicer (cfg) {
|
||||||
|
if (!(this instanceof Dicer)) { return new Dicer(cfg) }
|
||||||
|
WritableStream.call(this, cfg)
|
||||||
|
|
||||||
|
if (!cfg || (!cfg.headerFirst && typeof cfg.boundary !== 'string')) { throw new TypeError('Boundary required') }
|
||||||
|
|
||||||
|
if (typeof cfg.boundary === 'string') { this.setBoundary(cfg.boundary) } else { this._bparser = undefined }
|
||||||
|
|
||||||
|
this._headerFirst = cfg.headerFirst
|
||||||
|
|
||||||
|
this._dashes = 0
|
||||||
|
this._parts = 0
|
||||||
|
this._finished = false
|
||||||
|
this._realFinish = false
|
||||||
|
this._isPreamble = true
|
||||||
|
this._justMatched = false
|
||||||
|
this._firstWrite = true
|
||||||
|
this._inHeader = true
|
||||||
|
this._part = undefined
|
||||||
|
this._cb = undefined
|
||||||
|
this._ignoreData = false
|
||||||
|
this._partOpts = { highWaterMark: cfg.partHwm }
|
||||||
|
this._pause = false
|
||||||
|
|
||||||
|
const self = this
|
||||||
|
this._hparser = new HeaderParser(cfg)
|
||||||
|
this._hparser.on('header', function (header) {
|
||||||
|
self._inHeader = false
|
||||||
|
self._part.emit('header', header)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
inherits(Dicer, WritableStream)
|
||||||
|
|
||||||
|
Dicer.prototype.emit = function (ev) {
|
||||||
|
if (ev === 'finish' && !this._realFinish) {
|
||||||
|
if (!this._finished) {
|
||||||
|
const self = this
|
||||||
|
process.nextTick(function () {
|
||||||
|
self.emit('error', new Error('Unexpected end of multipart data'))
|
||||||
|
if (self._part && !self._ignoreData) {
|
||||||
|
const type = (self._isPreamble ? 'Preamble' : 'Part')
|
||||||
|
self._part.emit('error', new Error(type + ' terminated early due to unexpected end of multipart data'))
|
||||||
|
self._part.push(null)
|
||||||
|
process.nextTick(function () {
|
||||||
|
self._realFinish = true
|
||||||
|
self.emit('finish')
|
||||||
|
self._realFinish = false
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self._realFinish = true
|
||||||
|
self.emit('finish')
|
||||||
|
self._realFinish = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else { WritableStream.prototype.emit.apply(this, arguments) }
|
||||||
|
}
|
||||||
|
|
||||||
|
Dicer.prototype._write = function (data, encoding, cb) {
|
||||||
|
// ignore unexpected data (e.g. extra trailer data after finished)
|
||||||
|
if (!this._hparser && !this._bparser) { return cb() }
|
||||||
|
|
||||||
|
if (this._headerFirst && this._isPreamble) {
|
||||||
|
if (!this._part) {
|
||||||
|
this._part = new PartStream(this._partOpts)
|
||||||
|
if (this.listenerCount('preamble') !== 0) { this.emit('preamble', this._part) } else { this._ignore() }
|
||||||
|
}
|
||||||
|
const r = this._hparser.push(data)
|
||||||
|
if (!this._inHeader && r !== undefined && r < data.length) { data = data.slice(r) } else { return cb() }
|
||||||
|
}
|
||||||
|
|
||||||
|
// allows for "easier" testing
|
||||||
|
if (this._firstWrite) {
|
||||||
|
this._bparser.push(B_CRLF)
|
||||||
|
this._firstWrite = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this._bparser.push(data)
|
||||||
|
|
||||||
|
if (this._pause) { this._cb = cb } else { cb() }
|
||||||
|
}
|
||||||
|
|
||||||
|
Dicer.prototype.reset = function () {
|
||||||
|
this._part = undefined
|
||||||
|
this._bparser = undefined
|
||||||
|
this._hparser = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
Dicer.prototype.setBoundary = function (boundary) {
|
||||||
|
const self = this
|
||||||
|
this._bparser = new StreamSearch('\r\n--' + boundary)
|
||||||
|
this._bparser.on('info', function (isMatch, data, start, end) {
|
||||||
|
self._oninfo(isMatch, data, start, end)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Dicer.prototype._ignore = function () {
|
||||||
|
if (this._part && !this._ignoreData) {
|
||||||
|
this._ignoreData = true
|
||||||
|
this._part.on('error', EMPTY_FN)
|
||||||
|
// we must perform some kind of read on the stream even though we are
|
||||||
|
// ignoring the data, otherwise node's Readable stream will not emit 'end'
|
||||||
|
// after pushing null to the stream
|
||||||
|
this._part.resume()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dicer.prototype._oninfo = function (isMatch, data, start, end) {
|
||||||
|
let buf; const self = this; let i = 0; let r; let shouldWriteMore = true
|
||||||
|
|
||||||
|
if (!this._part && this._justMatched && data) {
|
||||||
|
while (this._dashes < 2 && (start + i) < end) {
|
||||||
|
if (data[start + i] === DASH) {
|
||||||
|
++i
|
||||||
|
++this._dashes
|
||||||
|
} else {
|
||||||
|
if (this._dashes) { buf = B_ONEDASH }
|
||||||
|
this._dashes = 0
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this._dashes === 2) {
|
||||||
|
if ((start + i) < end && this.listenerCount('trailer') !== 0) { this.emit('trailer', data.slice(start + i, end)) }
|
||||||
|
this.reset()
|
||||||
|
this._finished = true
|
||||||
|
// no more parts will be added
|
||||||
|
if (self._parts === 0) {
|
||||||
|
self._realFinish = true
|
||||||
|
self.emit('finish')
|
||||||
|
self._realFinish = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this._dashes) { return }
|
||||||
|
}
|
||||||
|
if (this._justMatched) { this._justMatched = false }
|
||||||
|
if (!this._part) {
|
||||||
|
this._part = new PartStream(this._partOpts)
|
||||||
|
this._part._read = function (n) {
|
||||||
|
self._unpause()
|
||||||
|
}
|
||||||
|
if (this._isPreamble && this.listenerCount('preamble') !== 0) {
|
||||||
|
this.emit('preamble', this._part)
|
||||||
|
} else if (this._isPreamble !== true && this.listenerCount('part') !== 0) {
|
||||||
|
this.emit('part', this._part)
|
||||||
|
} else {
|
||||||
|
this._ignore()
|
||||||
|
}
|
||||||
|
if (!this._isPreamble) { this._inHeader = true }
|
||||||
|
}
|
||||||
|
if (data && start < end && !this._ignoreData) {
|
||||||
|
if (this._isPreamble || !this._inHeader) {
|
||||||
|
if (buf) { shouldWriteMore = this._part.push(buf) }
|
||||||
|
shouldWriteMore = this._part.push(data.slice(start, end))
|
||||||
|
if (!shouldWriteMore) { this._pause = true }
|
||||||
|
} else if (!this._isPreamble && this._inHeader) {
|
||||||
|
if (buf) { this._hparser.push(buf) }
|
||||||
|
r = this._hparser.push(data.slice(start, end))
|
||||||
|
if (!this._inHeader && r !== undefined && r < end) { this._oninfo(false, data, start + r, end) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isMatch) {
|
||||||
|
this._hparser.reset()
|
||||||
|
if (this._isPreamble) { this._isPreamble = false } else {
|
||||||
|
if (start !== end) {
|
||||||
|
++this._parts
|
||||||
|
this._part.on('end', function () {
|
||||||
|
if (--self._parts === 0) {
|
||||||
|
if (self._finished) {
|
||||||
|
self._realFinish = true
|
||||||
|
self.emit('finish')
|
||||||
|
self._realFinish = false
|
||||||
|
} else {
|
||||||
|
self._unpause()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._part.push(null)
|
||||||
|
this._part = undefined
|
||||||
|
this._ignoreData = false
|
||||||
|
this._justMatched = true
|
||||||
|
this._dashes = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dicer.prototype._unpause = function () {
|
||||||
|
if (!this._pause) { return }
|
||||||
|
|
||||||
|
this._pause = false
|
||||||
|
if (this._cb) {
|
||||||
|
const cb = this._cb
|
||||||
|
this._cb = undefined
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Dicer
|
||||||
100
functions/node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js
generated
vendored
Normal file
100
functions/node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const EventEmitter = require('node:events').EventEmitter
|
||||||
|
const inherits = require('node:util').inherits
|
||||||
|
const getLimit = require('../../../lib/utils/getLimit')
|
||||||
|
|
||||||
|
const StreamSearch = require('../../streamsearch/sbmh')
|
||||||
|
|
||||||
|
const B_DCRLF = Buffer.from('\r\n\r\n')
|
||||||
|
const RE_CRLF = /\r\n/g
|
||||||
|
const RE_HDR = /^([^:]+):[ \t]?([\x00-\xFF]+)?$/ // eslint-disable-line no-control-regex
|
||||||
|
|
||||||
|
function HeaderParser (cfg) {
|
||||||
|
EventEmitter.call(this)
|
||||||
|
|
||||||
|
cfg = cfg || {}
|
||||||
|
const self = this
|
||||||
|
this.nread = 0
|
||||||
|
this.maxed = false
|
||||||
|
this.npairs = 0
|
||||||
|
this.maxHeaderPairs = getLimit(cfg, 'maxHeaderPairs', 2000)
|
||||||
|
this.maxHeaderSize = getLimit(cfg, 'maxHeaderSize', 80 * 1024)
|
||||||
|
this.buffer = ''
|
||||||
|
this.header = {}
|
||||||
|
this.finished = false
|
||||||
|
this.ss = new StreamSearch(B_DCRLF)
|
||||||
|
this.ss.on('info', function (isMatch, data, start, end) {
|
||||||
|
if (data && !self.maxed) {
|
||||||
|
if (self.nread + end - start >= self.maxHeaderSize) {
|
||||||
|
end = self.maxHeaderSize - self.nread + start
|
||||||
|
self.nread = self.maxHeaderSize
|
||||||
|
self.maxed = true
|
||||||
|
} else { self.nread += (end - start) }
|
||||||
|
|
||||||
|
self.buffer += data.toString('binary', start, end)
|
||||||
|
}
|
||||||
|
if (isMatch) { self._finish() }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
inherits(HeaderParser, EventEmitter)
|
||||||
|
|
||||||
|
HeaderParser.prototype.push = function (data) {
|
||||||
|
const r = this.ss.push(data)
|
||||||
|
if (this.finished) { return r }
|
||||||
|
}
|
||||||
|
|
||||||
|
HeaderParser.prototype.reset = function () {
|
||||||
|
this.finished = false
|
||||||
|
this.buffer = ''
|
||||||
|
this.header = {}
|
||||||
|
this.ss.reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
HeaderParser.prototype._finish = function () {
|
||||||
|
if (this.buffer) { this._parseHeader() }
|
||||||
|
this.ss.matches = this.ss.maxMatches
|
||||||
|
const header = this.header
|
||||||
|
this.header = {}
|
||||||
|
this.buffer = ''
|
||||||
|
this.finished = true
|
||||||
|
this.nread = this.npairs = 0
|
||||||
|
this.maxed = false
|
||||||
|
this.emit('header', header)
|
||||||
|
}
|
||||||
|
|
||||||
|
HeaderParser.prototype._parseHeader = function () {
|
||||||
|
if (this.npairs === this.maxHeaderPairs) { return }
|
||||||
|
|
||||||
|
const lines = this.buffer.split(RE_CRLF)
|
||||||
|
const len = lines.length
|
||||||
|
let m, h
|
||||||
|
|
||||||
|
for (var i = 0; i < len; ++i) { // eslint-disable-line no-var
|
||||||
|
if (lines[i].length === 0) { continue }
|
||||||
|
if (lines[i][0] === '\t' || lines[i][0] === ' ') {
|
||||||
|
// folded header content
|
||||||
|
// RFC2822 says to just remove the CRLF and not the whitespace following
|
||||||
|
// it, so we follow the RFC and include the leading whitespace ...
|
||||||
|
if (h) {
|
||||||
|
this.header[h][this.header[h].length - 1] += lines[i]
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const posColon = lines[i].indexOf(':')
|
||||||
|
if (
|
||||||
|
posColon === -1 ||
|
||||||
|
posColon === 0
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m = RE_HDR.exec(lines[i])
|
||||||
|
h = m[1].toLowerCase()
|
||||||
|
this.header[h] = this.header[h] || []
|
||||||
|
this.header[h].push((m[2] || ''))
|
||||||
|
if (++this.npairs === this.maxHeaderPairs) { break }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = HeaderParser
|
||||||
13
functions/node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js
generated
vendored
Normal file
13
functions/node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const inherits = require('node:util').inherits
|
||||||
|
const ReadableStream = require('node:stream').Readable
|
||||||
|
|
||||||
|
function PartStream (opts) {
|
||||||
|
ReadableStream.call(this, opts)
|
||||||
|
}
|
||||||
|
inherits(PartStream, ReadableStream)
|
||||||
|
|
||||||
|
PartStream.prototype._read = function (n) {}
|
||||||
|
|
||||||
|
module.exports = PartStream
|
||||||
164
functions/node_modules/@fastify/busboy/deps/dicer/lib/dicer.d.ts
generated
vendored
Normal file
164
functions/node_modules/@fastify/busboy/deps/dicer/lib/dicer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
// Type definitions for dicer 0.2
|
||||||
|
// Project: https://github.com/mscdex/dicer
|
||||||
|
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.2
|
||||||
|
/// <reference types="node" />
|
||||||
|
|
||||||
|
import stream = require("stream");
|
||||||
|
|
||||||
|
// tslint:disable:unified-signatures
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A very fast streaming multipart parser for node.js.
|
||||||
|
* Dicer is a WritableStream
|
||||||
|
*
|
||||||
|
* Dicer (special) events:
|
||||||
|
* - on('finish', ()) - Emitted when all parts have been parsed and the Dicer instance has been ended.
|
||||||
|
* - on('part', (stream: PartStream)) - Emitted when a new part has been found.
|
||||||
|
* - on('preamble', (stream: PartStream)) - Emitted for preamble if you should happen to need it (can usually be ignored).
|
||||||
|
* - on('trailer', (data: Buffer)) - Emitted when trailing data was found after the terminating boundary (as with the preamble, this can usually be ignored too).
|
||||||
|
*/
|
||||||
|
export class Dicer extends stream.Writable {
|
||||||
|
/**
|
||||||
|
* Creates and returns a new Dicer instance with the following valid config settings:
|
||||||
|
*
|
||||||
|
* @param config The configuration to use
|
||||||
|
*/
|
||||||
|
constructor(config: Dicer.Config);
|
||||||
|
/**
|
||||||
|
* Sets the boundary to use for parsing and performs some initialization needed for parsing.
|
||||||
|
* You should only need to use this if you set headerFirst to true in the constructor and are parsing the boundary from the preamble header.
|
||||||
|
*
|
||||||
|
* @param boundary The boundary to use
|
||||||
|
*/
|
||||||
|
setBoundary(boundary: string): void;
|
||||||
|
addListener(event: "finish", listener: () => void): this;
|
||||||
|
addListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
addListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
addListener(event: "trailer", listener: (data: Buffer) => void): this;
|
||||||
|
addListener(event: "close", listener: () => void): this;
|
||||||
|
addListener(event: "drain", listener: () => void): this;
|
||||||
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
on(event: "finish", listener: () => void): this;
|
||||||
|
on(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
on(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
on(event: "trailer", listener: (data: Buffer) => void): this;
|
||||||
|
on(event: "close", listener: () => void): this;
|
||||||
|
on(event: "drain", listener: () => void): this;
|
||||||
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
|
on(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
on(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "finish", listener: () => void): this;
|
||||||
|
once(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
once(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
once(event: "trailer", listener: (data: Buffer) => void): this;
|
||||||
|
once(event: "close", listener: () => void): this;
|
||||||
|
once(event: "drain", listener: () => void): this;
|
||||||
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
|
once(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
once(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "finish", listener: () => void): this;
|
||||||
|
prependListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
prependListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
prependListener(event: "trailer", listener: (data: Buffer) => void): this;
|
||||||
|
prependListener(event: "close", listener: () => void): this;
|
||||||
|
prependListener(event: "drain", listener: () => void): this;
|
||||||
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "finish", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
prependOnceListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
prependOnceListener(event: "trailer", listener: (data: Buffer) => void): this;
|
||||||
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "drain", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
removeListener(event: "finish", listener: () => void): this;
|
||||||
|
removeListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
removeListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
|
||||||
|
removeListener(event: "trailer", listener: (data: Buffer) => void): this;
|
||||||
|
removeListener(event: "close", listener: () => void): this;
|
||||||
|
removeListener(event: "drain", listener: () => void): this;
|
||||||
|
removeListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
removeListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
removeListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||||
|
removeListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare namespace Dicer {
|
||||||
|
interface Config {
|
||||||
|
/**
|
||||||
|
* This is the boundary used to detect the beginning of a new part.
|
||||||
|
*/
|
||||||
|
boundary?: string | undefined;
|
||||||
|
/**
|
||||||
|
* If true, preamble header parsing will be performed first.
|
||||||
|
*/
|
||||||
|
headerFirst?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* The maximum number of header key=>value pairs to parse Default: 2000 (same as node's http).
|
||||||
|
*/
|
||||||
|
maxHeaderPairs?: number | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PartStream is a _ReadableStream_
|
||||||
|
*
|
||||||
|
* PartStream (special) events:
|
||||||
|
* - on('header', (header: object)) - An object containing the header for this particular part. Each property value is an array of one or more string values.
|
||||||
|
*/
|
||||||
|
interface PartStream extends stream.Readable {
|
||||||
|
addListener(event: "header", listener: (header: object) => void): this;
|
||||||
|
addListener(event: "close", listener: () => void): this;
|
||||||
|
addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||||
|
addListener(event: "end", listener: () => void): this;
|
||||||
|
addListener(event: "readable", listener: () => void): this;
|
||||||
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
on(event: "header", listener: (header: object) => void): this;
|
||||||
|
on(event: "close", listener: () => void): this;
|
||||||
|
on(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||||
|
on(event: "end", listener: () => void): this;
|
||||||
|
on(event: "readable", listener: () => void): this;
|
||||||
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
once(event: "header", listener: (header: object) => void): this;
|
||||||
|
once(event: "close", listener: () => void): this;
|
||||||
|
once(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||||
|
once(event: "end", listener: () => void): this;
|
||||||
|
once(event: "readable", listener: () => void): this;
|
||||||
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependListener(event: "header", listener: (header: object) => void): this;
|
||||||
|
prependListener(event: "close", listener: () => void): this;
|
||||||
|
prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||||
|
prependListener(event: "end", listener: () => void): this;
|
||||||
|
prependListener(event: "readable", listener: () => void): this;
|
||||||
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: "header", listener: (header: object) => void): this;
|
||||||
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||||
|
prependOnceListener(event: "end", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "readable", listener: () => void): this;
|
||||||
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
removeListener(event: "header", listener: (header: object) => void): this;
|
||||||
|
removeListener(event: "close", listener: () => void): this;
|
||||||
|
removeListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||||
|
removeListener(event: "end", listener: () => void): this;
|
||||||
|
removeListener(event: "readable", listener: () => void): this;
|
||||||
|
removeListener(event: "error", listener: (err: Error) => void): this;
|
||||||
|
removeListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
}
|
||||||
|
}
|
||||||
230
functions/node_modules/@fastify/busboy/deps/streamsearch/sbmh.js
generated
vendored
Normal file
230
functions/node_modules/@fastify/busboy/deps/streamsearch/sbmh.js
generated
vendored
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright Brian White. All rights reserved.
|
||||||
|
*
|
||||||
|
* @see https://github.com/mscdex/streamsearch
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Based heavily on the Streaming Boyer-Moore-Horspool C++ implementation
|
||||||
|
* by Hongli Lai at: https://github.com/FooBarWidget/boyer-moore-horspool
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { EventEmitter } = require('node:events')
|
||||||
|
const { inherits } = require('node:util')
|
||||||
|
|
||||||
|
function SBMH (needle) {
|
||||||
|
if (typeof needle === 'string') {
|
||||||
|
needle = Buffer.from(needle)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Buffer.isBuffer(needle)) {
|
||||||
|
throw new TypeError('The needle has to be a String or a Buffer.')
|
||||||
|
}
|
||||||
|
|
||||||
|
const needleLength = needle.length
|
||||||
|
const needleLastCharIndex = needleLength - 1
|
||||||
|
|
||||||
|
if (needleLength === 0) {
|
||||||
|
throw new Error('The needle cannot be an empty String/Buffer.')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needleLength > 256) {
|
||||||
|
throw new Error('The needle cannot have a length bigger than 256.')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.maxMatches = Infinity
|
||||||
|
this.matches = 0
|
||||||
|
|
||||||
|
this._occ = new Uint8Array(256)
|
||||||
|
.fill(needleLength) // Initialize occurrence table.
|
||||||
|
this._lookbehind_size = 0
|
||||||
|
this._needle = needle
|
||||||
|
this._bufpos = 0
|
||||||
|
|
||||||
|
this._lookbehind = Buffer.alloc(needleLastCharIndex)
|
||||||
|
|
||||||
|
// Populate occurrence table with analysis of the needle,
|
||||||
|
// ignoring last letter.
|
||||||
|
for (var i = 0; i < needleLastCharIndex; ++i) { // eslint-disable-line no-var
|
||||||
|
this._occ[needle[i]] = needleLastCharIndex - i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inherits(SBMH, EventEmitter)
|
||||||
|
|
||||||
|
SBMH.prototype.reset = function () {
|
||||||
|
this._lookbehind_size = 0
|
||||||
|
this.matches = 0
|
||||||
|
this._bufpos = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
SBMH.prototype.push = function (chunk, pos) {
|
||||||
|
if (!Buffer.isBuffer(chunk)) {
|
||||||
|
chunk = Buffer.from(chunk, 'binary')
|
||||||
|
}
|
||||||
|
const chlen = chunk.length
|
||||||
|
this._bufpos = pos || 0
|
||||||
|
let r
|
||||||
|
while (r !== chlen && this.matches < this.maxMatches) { r = this._sbmh_feed(chunk) }
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
SBMH.prototype._sbmh_feed = function (data) {
|
||||||
|
const len = data.length
|
||||||
|
const needle = this._needle
|
||||||
|
const needleLength = needle.length
|
||||||
|
const needleLastCharIndex = needleLength - 1
|
||||||
|
const needleLastChar = needle[needleLastCharIndex]
|
||||||
|
|
||||||
|
// Positive: points to a position in `data`
|
||||||
|
// pos == 3 points to data[3]
|
||||||
|
// Negative: points to a position in the lookbehind buffer
|
||||||
|
// pos == -2 points to lookbehind[lookbehind_size - 2]
|
||||||
|
let pos = -this._lookbehind_size
|
||||||
|
let ch
|
||||||
|
|
||||||
|
if (pos < 0) {
|
||||||
|
// Lookbehind buffer is not empty. Perform Boyer-Moore-Horspool
|
||||||
|
// search with character lookup code that considers both the
|
||||||
|
// lookbehind buffer and the current round's haystack data.
|
||||||
|
//
|
||||||
|
// Loop until
|
||||||
|
// there is a match.
|
||||||
|
// or until
|
||||||
|
// we've moved past the position that requires the
|
||||||
|
// lookbehind buffer. In this case we switch to the
|
||||||
|
// optimized loop.
|
||||||
|
// or until
|
||||||
|
// the character to look at lies outside the haystack.
|
||||||
|
while (pos < 0 && pos <= len - needleLength) {
|
||||||
|
ch = data[pos + needleLastCharIndex]
|
||||||
|
|
||||||
|
if (
|
||||||
|
ch === needleLastChar &&
|
||||||
|
this._sbmh_memcmp(data, pos, needleLastCharIndex)
|
||||||
|
) {
|
||||||
|
this._lookbehind_size = 0
|
||||||
|
++this.matches
|
||||||
|
this.emit('info', true)
|
||||||
|
return (this._bufpos = pos + needleLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
pos += this._occ[ch]
|
||||||
|
}
|
||||||
|
|
||||||
|
// No match.
|
||||||
|
|
||||||
|
while (pos < 0 && !this._sbmh_memcmp(data, pos, len - pos)) {
|
||||||
|
// There's too few data for Boyer-Moore-Horspool to run,
|
||||||
|
// so let's use a different algorithm to skip as much as
|
||||||
|
// we can.
|
||||||
|
// Forward pos until
|
||||||
|
// the trailing part of lookbehind + data
|
||||||
|
// looks like the beginning of the needle
|
||||||
|
// or until
|
||||||
|
// pos == 0
|
||||||
|
++pos
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos >= 0) {
|
||||||
|
// Discard lookbehind buffer.
|
||||||
|
this.emit('info', false, this._lookbehind, 0, this._lookbehind_size)
|
||||||
|
this._lookbehind_size = 0
|
||||||
|
} else {
|
||||||
|
// Cut off part of the lookbehind buffer that has
|
||||||
|
// been processed and append the entire haystack
|
||||||
|
// into it.
|
||||||
|
const bytesToCutOff = this._lookbehind_size + pos
|
||||||
|
if (bytesToCutOff > 0) {
|
||||||
|
// The cut off data is guaranteed not to contain the needle.
|
||||||
|
this.emit('info', false, this._lookbehind, 0, bytesToCutOff)
|
||||||
|
}
|
||||||
|
|
||||||
|
this._lookbehind_size -= bytesToCutOff
|
||||||
|
this._lookbehind.copy(this._lookbehind, 0, bytesToCutOff, this._lookbehind_size)
|
||||||
|
|
||||||
|
data.copy(this._lookbehind, this._lookbehind_size)
|
||||||
|
this._lookbehind_size += len
|
||||||
|
|
||||||
|
this._bufpos = len
|
||||||
|
return len
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lookbehind buffer is now empty. We only need to check if the
|
||||||
|
// needle is in the haystack.
|
||||||
|
pos = data.indexOf(needle, pos + this._bufpos)
|
||||||
|
|
||||||
|
if (pos !== -1) {
|
||||||
|
++this.matches
|
||||||
|
if (pos === 0) { this.emit('info', true) } else { this.emit('info', true, data, this._bufpos, pos) }
|
||||||
|
return (this._bufpos = pos + needleLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = len - needleLastCharIndex
|
||||||
|
if (pos < 0) {
|
||||||
|
pos = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// There was no match. If there's trailing haystack data that we cannot
|
||||||
|
// match yet using the Boyer-Moore-Horspool algorithm (because the trailing
|
||||||
|
// data is less than the needle size) then match using a modified
|
||||||
|
// algorithm that starts matching from the beginning instead of the end.
|
||||||
|
// Whatever trailing data is left after running this algorithm is added to
|
||||||
|
// the lookbehind buffer.
|
||||||
|
while (
|
||||||
|
pos !== len &&
|
||||||
|
(
|
||||||
|
data[pos] !== needle[0] ||
|
||||||
|
Buffer.compare(
|
||||||
|
data.subarray(pos + 1, len),
|
||||||
|
needle.subarray(1, len - pos)
|
||||||
|
) !== 0
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
++pos
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos !== len) {
|
||||||
|
data.copy(this._lookbehind, 0, pos, len)
|
||||||
|
this._lookbehind_size = len - pos
|
||||||
|
}
|
||||||
|
|
||||||
|
// Everything until pos is guaranteed not to contain needle data.
|
||||||
|
if (pos !== 0) { this.emit('info', false, data, this._bufpos, pos) }
|
||||||
|
|
||||||
|
this._bufpos = len
|
||||||
|
return len
|
||||||
|
}
|
||||||
|
|
||||||
|
SBMH.prototype._sbmh_lookup_char = function (data, pos) {
|
||||||
|
return pos < 0
|
||||||
|
? this._lookbehind[this._lookbehind_size + pos]
|
||||||
|
: data[pos]
|
||||||
|
}
|
||||||
|
|
||||||
|
SBMH.prototype._sbmh_memcmp = function (data, pos, len) {
|
||||||
|
for (var i = 0; i < len; ++i) { // eslint-disable-line no-var
|
||||||
|
if (this._sbmh_lookup_char(data, pos + i) !== this._needle[i]) { return false }
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = SBMH
|
||||||
196
functions/node_modules/@fastify/busboy/lib/main.d.ts
generated
vendored
Normal file
196
functions/node_modules/@fastify/busboy/lib/main.d.ts
generated
vendored
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
// Definitions by: Jacob Baskin <https://github.com/jacobbaskin>
|
||||||
|
// BendingBender <https://github.com/BendingBender>
|
||||||
|
// Igor Savin <https://github.com/kibertoad>
|
||||||
|
|
||||||
|
/// <reference types="node" />
|
||||||
|
|
||||||
|
import * as http from 'node:http';
|
||||||
|
import { Readable, Writable } from 'node:stream';
|
||||||
|
export { Dicer } from "../deps/dicer/lib/dicer";
|
||||||
|
|
||||||
|
export const Busboy: BusboyConstructor;
|
||||||
|
export default Busboy;
|
||||||
|
|
||||||
|
export interface BusboyConfig {
|
||||||
|
/**
|
||||||
|
* These are the HTTP headers of the incoming request, which are used by individual parsers.
|
||||||
|
*/
|
||||||
|
headers: BusboyHeaders;
|
||||||
|
/**
|
||||||
|
* `highWaterMark` to use for this Busboy instance.
|
||||||
|
* @default WritableStream default.
|
||||||
|
*/
|
||||||
|
highWaterMark?: number | undefined;
|
||||||
|
/**
|
||||||
|
* highWaterMark to use for file streams.
|
||||||
|
* @default ReadableStream default.
|
||||||
|
*/
|
||||||
|
fileHwm?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Default character set to use when one isn't defined.
|
||||||
|
* @default 'utf8'
|
||||||
|
*/
|
||||||
|
defCharset?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Detect if a Part is a file.
|
||||||
|
*
|
||||||
|
* By default a file is detected if contentType
|
||||||
|
* is application/octet-stream or fileName is not
|
||||||
|
* undefined.
|
||||||
|
*
|
||||||
|
* Modify this to handle e.g. Blobs.
|
||||||
|
*/
|
||||||
|
isPartAFile?: (fieldName: string | undefined, contentType: string | undefined, fileName: string | undefined) => boolean;
|
||||||
|
/**
|
||||||
|
* If paths in the multipart 'filename' field shall be preserved.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
preservePath?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Various limits on incoming data.
|
||||||
|
*/
|
||||||
|
limits?:
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* Max field name size (in bytes)
|
||||||
|
* @default 100 bytes
|
||||||
|
*/
|
||||||
|
fieldNameSize?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Max field value size (in bytes)
|
||||||
|
* @default 1MB
|
||||||
|
*/
|
||||||
|
fieldSize?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Max number of non-file fields
|
||||||
|
* @default Infinity
|
||||||
|
*/
|
||||||
|
fields?: number | undefined;
|
||||||
|
/**
|
||||||
|
* For multipart forms, the max file size (in bytes)
|
||||||
|
* @default Infinity
|
||||||
|
*/
|
||||||
|
fileSize?: number | undefined;
|
||||||
|
/**
|
||||||
|
* For multipart forms, the max number of file fields
|
||||||
|
* @default Infinity
|
||||||
|
*/
|
||||||
|
files?: number | undefined;
|
||||||
|
/**
|
||||||
|
* For multipart forms, the max number of parts (fields + files)
|
||||||
|
* @default Infinity
|
||||||
|
*/
|
||||||
|
parts?: number | undefined;
|
||||||
|
/**
|
||||||
|
* For multipart forms, the max number of header key=>value pairs to parse
|
||||||
|
* @default 2000
|
||||||
|
*/
|
||||||
|
headerPairs?: number | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For multipart forms, the max size of a header part
|
||||||
|
* @default 81920
|
||||||
|
*/
|
||||||
|
headerSize?: number | undefined;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BusboyHeaders = { 'content-type': string } & http.IncomingHttpHeaders;
|
||||||
|
|
||||||
|
export interface BusboyFileStream extends
|
||||||
|
Readable {
|
||||||
|
|
||||||
|
truncated: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of bytes that have been read so far.
|
||||||
|
*/
|
||||||
|
bytesRead: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Busboy extends Writable {
|
||||||
|
addListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
||||||
|
|
||||||
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
|
||||||
|
on<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
||||||
|
|
||||||
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
|
||||||
|
once<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
||||||
|
|
||||||
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
|
||||||
|
removeListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
||||||
|
|
||||||
|
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
|
||||||
|
off<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
||||||
|
|
||||||
|
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
|
||||||
|
prependListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
||||||
|
|
||||||
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
|
||||||
|
prependOnceListener<Event extends keyof BusboyEvents>(event: Event, listener: BusboyEvents[Event]): this;
|
||||||
|
|
||||||
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BusboyEvents {
|
||||||
|
/**
|
||||||
|
* Emitted for each new file form field found.
|
||||||
|
*
|
||||||
|
* * Note: if you listen for this event, you should always handle the `stream` no matter if you care about the
|
||||||
|
* file contents or not (e.g. you can simply just do `stream.resume();` if you want to discard the contents),
|
||||||
|
* otherwise the 'finish' event will never fire on the Busboy instance. However, if you don't care about **any**
|
||||||
|
* incoming files, you can simply not listen for the 'file' event at all and any/all files will be automatically
|
||||||
|
* and safely discarded (these discarded files do still count towards `files` and `parts` limits).
|
||||||
|
* * If a configured file size limit was reached, `stream` will both have a boolean property `truncated`
|
||||||
|
* (best checked at the end of the stream) and emit a 'limit' event to notify you when this happens.
|
||||||
|
*
|
||||||
|
* @param listener.transferEncoding Contains the 'Content-Transfer-Encoding' value for the file stream.
|
||||||
|
* @param listener.mimeType Contains the 'Content-Type' value for the file stream.
|
||||||
|
*/
|
||||||
|
file: (
|
||||||
|
fieldname: string,
|
||||||
|
stream: BusboyFileStream,
|
||||||
|
filename: string,
|
||||||
|
transferEncoding: string,
|
||||||
|
mimeType: string,
|
||||||
|
) => void;
|
||||||
|
/**
|
||||||
|
* Emitted for each new non-file field found.
|
||||||
|
*/
|
||||||
|
field: (
|
||||||
|
fieldname: string,
|
||||||
|
value: string,
|
||||||
|
fieldnameTruncated: boolean,
|
||||||
|
valueTruncated: boolean,
|
||||||
|
transferEncoding: string,
|
||||||
|
mimeType: string,
|
||||||
|
) => void;
|
||||||
|
finish: () => void;
|
||||||
|
/**
|
||||||
|
* Emitted when specified `parts` limit has been reached. No more 'file' or 'field' events will be emitted.
|
||||||
|
*/
|
||||||
|
partsLimit: () => void;
|
||||||
|
/**
|
||||||
|
* Emitted when specified `files` limit has been reached. No more 'file' events will be emitted.
|
||||||
|
*/
|
||||||
|
filesLimit: () => void;
|
||||||
|
/**
|
||||||
|
* Emitted when specified `fields` limit has been reached. No more 'field' events will be emitted.
|
||||||
|
*/
|
||||||
|
fieldsLimit: () => void;
|
||||||
|
error: (error: unknown) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BusboyConstructor {
|
||||||
|
(options: BusboyConfig): Busboy;
|
||||||
|
|
||||||
|
new(options: BusboyConfig): Busboy;
|
||||||
|
}
|
||||||
|
|
||||||
85
functions/node_modules/@fastify/busboy/lib/main.js
generated
vendored
Normal file
85
functions/node_modules/@fastify/busboy/lib/main.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const WritableStream = require('node:stream').Writable
|
||||||
|
const { inherits } = require('node:util')
|
||||||
|
const Dicer = require('../deps/dicer/lib/Dicer')
|
||||||
|
|
||||||
|
const MultipartParser = require('./types/multipart')
|
||||||
|
const UrlencodedParser = require('./types/urlencoded')
|
||||||
|
const parseParams = require('./utils/parseParams')
|
||||||
|
|
||||||
|
function Busboy (opts) {
|
||||||
|
if (!(this instanceof Busboy)) { return new Busboy(opts) }
|
||||||
|
|
||||||
|
if (typeof opts !== 'object') {
|
||||||
|
throw new TypeError('Busboy expected an options-Object.')
|
||||||
|
}
|
||||||
|
if (typeof opts.headers !== 'object') {
|
||||||
|
throw new TypeError('Busboy expected an options-Object with headers-attribute.')
|
||||||
|
}
|
||||||
|
if (typeof opts.headers['content-type'] !== 'string') {
|
||||||
|
throw new TypeError('Missing Content-Type-header.')
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
headers,
|
||||||
|
...streamOptions
|
||||||
|
} = opts
|
||||||
|
|
||||||
|
this.opts = {
|
||||||
|
autoDestroy: false,
|
||||||
|
...streamOptions
|
||||||
|
}
|
||||||
|
WritableStream.call(this, this.opts)
|
||||||
|
|
||||||
|
this._done = false
|
||||||
|
this._parser = this.getParserByHeaders(headers)
|
||||||
|
this._finished = false
|
||||||
|
}
|
||||||
|
inherits(Busboy, WritableStream)
|
||||||
|
|
||||||
|
Busboy.prototype.emit = function (ev) {
|
||||||
|
if (ev === 'finish') {
|
||||||
|
if (!this._done) {
|
||||||
|
this._parser?.end()
|
||||||
|
return
|
||||||
|
} else if (this._finished) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this._finished = true
|
||||||
|
}
|
||||||
|
WritableStream.prototype.emit.apply(this, arguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
Busboy.prototype.getParserByHeaders = function (headers) {
|
||||||
|
const parsed = parseParams(headers['content-type'])
|
||||||
|
|
||||||
|
const cfg = {
|
||||||
|
defCharset: this.opts.defCharset,
|
||||||
|
fileHwm: this.opts.fileHwm,
|
||||||
|
headers,
|
||||||
|
highWaterMark: this.opts.highWaterMark,
|
||||||
|
isPartAFile: this.opts.isPartAFile,
|
||||||
|
limits: this.opts.limits,
|
||||||
|
parsedConType: parsed,
|
||||||
|
preservePath: this.opts.preservePath
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MultipartParser.detect.test(parsed[0])) {
|
||||||
|
return new MultipartParser(this, cfg)
|
||||||
|
}
|
||||||
|
if (UrlencodedParser.detect.test(parsed[0])) {
|
||||||
|
return new UrlencodedParser(this, cfg)
|
||||||
|
}
|
||||||
|
throw new Error('Unsupported Content-Type.')
|
||||||
|
}
|
||||||
|
|
||||||
|
Busboy.prototype._write = function (chunk, encoding, cb) {
|
||||||
|
this._parser.write(chunk, cb)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Busboy
|
||||||
|
module.exports.default = Busboy
|
||||||
|
module.exports.Busboy = Busboy
|
||||||
|
|
||||||
|
module.exports.Dicer = Dicer
|
||||||
306
functions/node_modules/@fastify/busboy/lib/types/multipart.js
generated
vendored
Normal file
306
functions/node_modules/@fastify/busboy/lib/types/multipart.js
generated
vendored
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// * support 1 nested multipart level
|
||||||
|
// (see second multipart example here:
|
||||||
|
// http://www.w3.org/TR/html401/interact/forms.html#didx-multipartform-data)
|
||||||
|
// * support limits.fieldNameSize
|
||||||
|
// -- this will require modifications to utils.parseParams
|
||||||
|
|
||||||
|
const { Readable } = require('node:stream')
|
||||||
|
const { inherits } = require('node:util')
|
||||||
|
|
||||||
|
const Dicer = require('../../deps/dicer/lib/Dicer')
|
||||||
|
|
||||||
|
const parseParams = require('../utils/parseParams')
|
||||||
|
const decodeText = require('../utils/decodeText')
|
||||||
|
const basename = require('../utils/basename')
|
||||||
|
const getLimit = require('../utils/getLimit')
|
||||||
|
|
||||||
|
const RE_BOUNDARY = /^boundary$/i
|
||||||
|
const RE_FIELD = /^form-data$/i
|
||||||
|
const RE_CHARSET = /^charset$/i
|
||||||
|
const RE_FILENAME = /^filename$/i
|
||||||
|
const RE_NAME = /^name$/i
|
||||||
|
|
||||||
|
Multipart.detect = /^multipart\/form-data/i
|
||||||
|
function Multipart (boy, cfg) {
|
||||||
|
let i
|
||||||
|
let len
|
||||||
|
const self = this
|
||||||
|
let boundary
|
||||||
|
const limits = cfg.limits
|
||||||
|
const isPartAFile = cfg.isPartAFile || ((fieldName, contentType, fileName) => (contentType === 'application/octet-stream' || fileName !== undefined))
|
||||||
|
const parsedConType = cfg.parsedConType || []
|
||||||
|
const defCharset = cfg.defCharset || 'utf8'
|
||||||
|
const preservePath = cfg.preservePath
|
||||||
|
const fileOpts = { highWaterMark: cfg.fileHwm }
|
||||||
|
|
||||||
|
for (i = 0, len = parsedConType.length; i < len; ++i) {
|
||||||
|
if (Array.isArray(parsedConType[i]) &&
|
||||||
|
RE_BOUNDARY.test(parsedConType[i][0])) {
|
||||||
|
boundary = parsedConType[i][1]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkFinished () {
|
||||||
|
if (nends === 0 && finished && !boy._done) {
|
||||||
|
finished = false
|
||||||
|
self.end()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof boundary !== 'string') { throw new Error('Multipart: Boundary not found') }
|
||||||
|
|
||||||
|
const fieldSizeLimit = getLimit(limits, 'fieldSize', 1 * 1024 * 1024)
|
||||||
|
const fileSizeLimit = getLimit(limits, 'fileSize', Infinity)
|
||||||
|
const filesLimit = getLimit(limits, 'files', Infinity)
|
||||||
|
const fieldsLimit = getLimit(limits, 'fields', Infinity)
|
||||||
|
const partsLimit = getLimit(limits, 'parts', Infinity)
|
||||||
|
const headerPairsLimit = getLimit(limits, 'headerPairs', 2000)
|
||||||
|
const headerSizeLimit = getLimit(limits, 'headerSize', 80 * 1024)
|
||||||
|
|
||||||
|
let nfiles = 0
|
||||||
|
let nfields = 0
|
||||||
|
let nends = 0
|
||||||
|
let curFile
|
||||||
|
let curField
|
||||||
|
let finished = false
|
||||||
|
|
||||||
|
this._needDrain = false
|
||||||
|
this._pause = false
|
||||||
|
this._cb = undefined
|
||||||
|
this._nparts = 0
|
||||||
|
this._boy = boy
|
||||||
|
|
||||||
|
const parserCfg = {
|
||||||
|
boundary,
|
||||||
|
maxHeaderPairs: headerPairsLimit,
|
||||||
|
maxHeaderSize: headerSizeLimit,
|
||||||
|
partHwm: fileOpts.highWaterMark,
|
||||||
|
highWaterMark: cfg.highWaterMark
|
||||||
|
}
|
||||||
|
|
||||||
|
this.parser = new Dicer(parserCfg)
|
||||||
|
this.parser.on('drain', function () {
|
||||||
|
self._needDrain = false
|
||||||
|
if (self._cb && !self._pause) {
|
||||||
|
const cb = self._cb
|
||||||
|
self._cb = undefined
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
}).on('part', function onPart (part) {
|
||||||
|
if (++self._nparts > partsLimit) {
|
||||||
|
self.parser.removeListener('part', onPart)
|
||||||
|
self.parser.on('part', skipPart)
|
||||||
|
boy.hitPartsLimit = true
|
||||||
|
boy.emit('partsLimit')
|
||||||
|
return skipPart(part)
|
||||||
|
}
|
||||||
|
|
||||||
|
// hack because streams2 _always_ doesn't emit 'end' until nextTick, so let
|
||||||
|
// us emit 'end' early since we know the part has ended if we are already
|
||||||
|
// seeing the next part
|
||||||
|
if (curField) {
|
||||||
|
const field = curField
|
||||||
|
field.emit('end')
|
||||||
|
field.removeAllListeners('end')
|
||||||
|
}
|
||||||
|
|
||||||
|
part.on('header', function (header) {
|
||||||
|
let contype
|
||||||
|
let fieldname
|
||||||
|
let parsed
|
||||||
|
let charset
|
||||||
|
let encoding
|
||||||
|
let filename
|
||||||
|
let nsize = 0
|
||||||
|
|
||||||
|
if (header['content-type']) {
|
||||||
|
parsed = parseParams(header['content-type'][0])
|
||||||
|
if (parsed[0]) {
|
||||||
|
contype = parsed[0].toLowerCase()
|
||||||
|
for (i = 0, len = parsed.length; i < len; ++i) {
|
||||||
|
if (RE_CHARSET.test(parsed[i][0])) {
|
||||||
|
charset = parsed[i][1].toLowerCase()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contype === undefined) { contype = 'text/plain' }
|
||||||
|
if (charset === undefined) { charset = defCharset }
|
||||||
|
|
||||||
|
if (header['content-disposition']) {
|
||||||
|
parsed = parseParams(header['content-disposition'][0])
|
||||||
|
if (!RE_FIELD.test(parsed[0])) { return skipPart(part) }
|
||||||
|
for (i = 0, len = parsed.length; i < len; ++i) {
|
||||||
|
if (RE_NAME.test(parsed[i][0])) {
|
||||||
|
fieldname = parsed[i][1]
|
||||||
|
} else if (RE_FILENAME.test(parsed[i][0])) {
|
||||||
|
filename = parsed[i][1]
|
||||||
|
if (!preservePath) { filename = basename(filename) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { return skipPart(part) }
|
||||||
|
|
||||||
|
if (header['content-transfer-encoding']) { encoding = header['content-transfer-encoding'][0].toLowerCase() } else { encoding = '7bit' }
|
||||||
|
|
||||||
|
let onData,
|
||||||
|
onEnd
|
||||||
|
|
||||||
|
if (isPartAFile(fieldname, contype, filename)) {
|
||||||
|
// file/binary field
|
||||||
|
if (nfiles === filesLimit) {
|
||||||
|
if (!boy.hitFilesLimit) {
|
||||||
|
boy.hitFilesLimit = true
|
||||||
|
boy.emit('filesLimit')
|
||||||
|
}
|
||||||
|
return skipPart(part)
|
||||||
|
}
|
||||||
|
|
||||||
|
++nfiles
|
||||||
|
|
||||||
|
if (boy.listenerCount('file') === 0) {
|
||||||
|
self.parser._ignore()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
++nends
|
||||||
|
const file = new FileStream(fileOpts)
|
||||||
|
curFile = file
|
||||||
|
file.on('end', function () {
|
||||||
|
--nends
|
||||||
|
self._pause = false
|
||||||
|
checkFinished()
|
||||||
|
if (self._cb && !self._needDrain) {
|
||||||
|
const cb = self._cb
|
||||||
|
self._cb = undefined
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
file._read = function (n) {
|
||||||
|
if (!self._pause) { return }
|
||||||
|
self._pause = false
|
||||||
|
if (self._cb && !self._needDrain) {
|
||||||
|
const cb = self._cb
|
||||||
|
self._cb = undefined
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boy.emit('file', fieldname, file, filename, encoding, contype)
|
||||||
|
|
||||||
|
onData = function (data) {
|
||||||
|
if ((nsize += data.length) > fileSizeLimit) {
|
||||||
|
const extralen = fileSizeLimit - nsize + data.length
|
||||||
|
if (extralen > 0) { file.push(data.slice(0, extralen)) }
|
||||||
|
file.truncated = true
|
||||||
|
file.bytesRead = fileSizeLimit
|
||||||
|
part.removeAllListeners('data')
|
||||||
|
file.emit('limit')
|
||||||
|
return
|
||||||
|
} else if (!file.push(data)) { self._pause = true }
|
||||||
|
|
||||||
|
file.bytesRead = nsize
|
||||||
|
}
|
||||||
|
|
||||||
|
onEnd = function () {
|
||||||
|
curFile = undefined
|
||||||
|
file.push(null)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// non-file field
|
||||||
|
if (nfields === fieldsLimit) {
|
||||||
|
if (!boy.hitFieldsLimit) {
|
||||||
|
boy.hitFieldsLimit = true
|
||||||
|
boy.emit('fieldsLimit')
|
||||||
|
}
|
||||||
|
return skipPart(part)
|
||||||
|
}
|
||||||
|
|
||||||
|
++nfields
|
||||||
|
++nends
|
||||||
|
let buffer = ''
|
||||||
|
let truncated = false
|
||||||
|
curField = part
|
||||||
|
|
||||||
|
onData = function (data) {
|
||||||
|
if ((nsize += data.length) > fieldSizeLimit) {
|
||||||
|
const extralen = (fieldSizeLimit - (nsize - data.length))
|
||||||
|
buffer += data.toString('binary', 0, extralen)
|
||||||
|
truncated = true
|
||||||
|
part.removeAllListeners('data')
|
||||||
|
} else { buffer += data.toString('binary') }
|
||||||
|
}
|
||||||
|
|
||||||
|
onEnd = function () {
|
||||||
|
curField = undefined
|
||||||
|
if (buffer.length) { buffer = decodeText(buffer, 'binary', charset) }
|
||||||
|
boy.emit('field', fieldname, buffer, false, truncated, encoding, contype)
|
||||||
|
--nends
|
||||||
|
checkFinished()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* As of node@2efe4ab761666 (v0.10.29+/v0.11.14+), busboy had become
|
||||||
|
broken. Streams2/streams3 is a huge black box of confusion, but
|
||||||
|
somehow overriding the sync state seems to fix things again (and still
|
||||||
|
seems to work for previous node versions).
|
||||||
|
*/
|
||||||
|
part._readableState.sync = false
|
||||||
|
|
||||||
|
part.on('data', onData)
|
||||||
|
part.on('end', onEnd)
|
||||||
|
}).on('error', function (err) {
|
||||||
|
if (curFile) { curFile.emit('error', err) }
|
||||||
|
})
|
||||||
|
}).on('error', function (err) {
|
||||||
|
boy.emit('error', err)
|
||||||
|
}).on('finish', function () {
|
||||||
|
finished = true
|
||||||
|
checkFinished()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Multipart.prototype.write = function (chunk, cb) {
|
||||||
|
const r = this.parser.write(chunk)
|
||||||
|
if (r && !this._pause) {
|
||||||
|
cb()
|
||||||
|
} else {
|
||||||
|
this._needDrain = !r
|
||||||
|
this._cb = cb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Multipart.prototype.end = function () {
|
||||||
|
const self = this
|
||||||
|
|
||||||
|
if (self.parser.writable) {
|
||||||
|
self.parser.end()
|
||||||
|
} else if (!self._boy._done) {
|
||||||
|
process.nextTick(function () {
|
||||||
|
self._boy._done = true
|
||||||
|
self._boy.emit('finish')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function skipPart (part) {
|
||||||
|
part.resume()
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileStream (opts) {
|
||||||
|
Readable.call(this, opts)
|
||||||
|
|
||||||
|
this.bytesRead = 0
|
||||||
|
|
||||||
|
this.truncated = false
|
||||||
|
}
|
||||||
|
|
||||||
|
inherits(FileStream, Readable)
|
||||||
|
|
||||||
|
FileStream.prototype._read = function (n) {}
|
||||||
|
|
||||||
|
module.exports = Multipart
|
||||||
190
functions/node_modules/@fastify/busboy/lib/types/urlencoded.js
generated
vendored
Normal file
190
functions/node_modules/@fastify/busboy/lib/types/urlencoded.js
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const Decoder = require('../utils/Decoder')
|
||||||
|
const decodeText = require('../utils/decodeText')
|
||||||
|
const getLimit = require('../utils/getLimit')
|
||||||
|
|
||||||
|
const RE_CHARSET = /^charset$/i
|
||||||
|
|
||||||
|
UrlEncoded.detect = /^application\/x-www-form-urlencoded/i
|
||||||
|
function UrlEncoded (boy, cfg) {
|
||||||
|
const limits = cfg.limits
|
||||||
|
const parsedConType = cfg.parsedConType
|
||||||
|
this.boy = boy
|
||||||
|
|
||||||
|
this.fieldSizeLimit = getLimit(limits, 'fieldSize', 1 * 1024 * 1024)
|
||||||
|
this.fieldNameSizeLimit = getLimit(limits, 'fieldNameSize', 100)
|
||||||
|
this.fieldsLimit = getLimit(limits, 'fields', Infinity)
|
||||||
|
|
||||||
|
let charset
|
||||||
|
for (var i = 0, len = parsedConType.length; i < len; ++i) { // eslint-disable-line no-var
|
||||||
|
if (Array.isArray(parsedConType[i]) &&
|
||||||
|
RE_CHARSET.test(parsedConType[i][0])) {
|
||||||
|
charset = parsedConType[i][1].toLowerCase()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (charset === undefined) { charset = cfg.defCharset || 'utf8' }
|
||||||
|
|
||||||
|
this.decoder = new Decoder()
|
||||||
|
this.charset = charset
|
||||||
|
this._fields = 0
|
||||||
|
this._state = 'key'
|
||||||
|
this._checkingBytes = true
|
||||||
|
this._bytesKey = 0
|
||||||
|
this._bytesVal = 0
|
||||||
|
this._key = ''
|
||||||
|
this._val = ''
|
||||||
|
this._keyTrunc = false
|
||||||
|
this._valTrunc = false
|
||||||
|
this._hitLimit = false
|
||||||
|
}
|
||||||
|
|
||||||
|
UrlEncoded.prototype.write = function (data, cb) {
|
||||||
|
if (this._fields === this.fieldsLimit) {
|
||||||
|
if (!this.boy.hitFieldsLimit) {
|
||||||
|
this.boy.hitFieldsLimit = true
|
||||||
|
this.boy.emit('fieldsLimit')
|
||||||
|
}
|
||||||
|
return cb()
|
||||||
|
}
|
||||||
|
|
||||||
|
let idxeq; let idxamp; let i; let p = 0; const len = data.length
|
||||||
|
|
||||||
|
while (p < len) {
|
||||||
|
if (this._state === 'key') {
|
||||||
|
idxeq = idxamp = undefined
|
||||||
|
for (i = p; i < len; ++i) {
|
||||||
|
if (!this._checkingBytes) { ++p }
|
||||||
|
if (data[i] === 0x3D/* = */) {
|
||||||
|
idxeq = i
|
||||||
|
break
|
||||||
|
} else if (data[i] === 0x26/* & */) {
|
||||||
|
idxamp = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (this._checkingBytes && this._bytesKey === this.fieldNameSizeLimit) {
|
||||||
|
this._hitLimit = true
|
||||||
|
break
|
||||||
|
} else if (this._checkingBytes) { ++this._bytesKey }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idxeq !== undefined) {
|
||||||
|
// key with assignment
|
||||||
|
if (idxeq > p) { this._key += this.decoder.write(data.toString('binary', p, idxeq)) }
|
||||||
|
this._state = 'val'
|
||||||
|
|
||||||
|
this._hitLimit = false
|
||||||
|
this._checkingBytes = true
|
||||||
|
this._val = ''
|
||||||
|
this._bytesVal = 0
|
||||||
|
this._valTrunc = false
|
||||||
|
this.decoder.reset()
|
||||||
|
|
||||||
|
p = idxeq + 1
|
||||||
|
} else if (idxamp !== undefined) {
|
||||||
|
// key with no assignment
|
||||||
|
++this._fields
|
||||||
|
let key; const keyTrunc = this._keyTrunc
|
||||||
|
if (idxamp > p) { key = (this._key += this.decoder.write(data.toString('binary', p, idxamp))) } else { key = this._key }
|
||||||
|
|
||||||
|
this._hitLimit = false
|
||||||
|
this._checkingBytes = true
|
||||||
|
this._key = ''
|
||||||
|
this._bytesKey = 0
|
||||||
|
this._keyTrunc = false
|
||||||
|
this.decoder.reset()
|
||||||
|
|
||||||
|
if (key.length) {
|
||||||
|
this.boy.emit('field', decodeText(key, 'binary', this.charset),
|
||||||
|
'',
|
||||||
|
keyTrunc,
|
||||||
|
false)
|
||||||
|
}
|
||||||
|
|
||||||
|
p = idxamp + 1
|
||||||
|
if (this._fields === this.fieldsLimit) { return cb() }
|
||||||
|
} else if (this._hitLimit) {
|
||||||
|
// we may not have hit the actual limit if there are encoded bytes...
|
||||||
|
if (i > p) { this._key += this.decoder.write(data.toString('binary', p, i)) }
|
||||||
|
p = i
|
||||||
|
if ((this._bytesKey = this._key.length) === this.fieldNameSizeLimit) {
|
||||||
|
// yep, we actually did hit the limit
|
||||||
|
this._checkingBytes = false
|
||||||
|
this._keyTrunc = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (p < len) { this._key += this.decoder.write(data.toString('binary', p)) }
|
||||||
|
p = len
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
idxamp = undefined
|
||||||
|
for (i = p; i < len; ++i) {
|
||||||
|
if (!this._checkingBytes) { ++p }
|
||||||
|
if (data[i] === 0x26/* & */) {
|
||||||
|
idxamp = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (this._checkingBytes && this._bytesVal === this.fieldSizeLimit) {
|
||||||
|
this._hitLimit = true
|
||||||
|
break
|
||||||
|
} else if (this._checkingBytes) { ++this._bytesVal }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idxamp !== undefined) {
|
||||||
|
++this._fields
|
||||||
|
if (idxamp > p) { this._val += this.decoder.write(data.toString('binary', p, idxamp)) }
|
||||||
|
this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
|
||||||
|
decodeText(this._val, 'binary', this.charset),
|
||||||
|
this._keyTrunc,
|
||||||
|
this._valTrunc)
|
||||||
|
this._state = 'key'
|
||||||
|
|
||||||
|
this._hitLimit = false
|
||||||
|
this._checkingBytes = true
|
||||||
|
this._key = ''
|
||||||
|
this._bytesKey = 0
|
||||||
|
this._keyTrunc = false
|
||||||
|
this.decoder.reset()
|
||||||
|
|
||||||
|
p = idxamp + 1
|
||||||
|
if (this._fields === this.fieldsLimit) { return cb() }
|
||||||
|
} else if (this._hitLimit) {
|
||||||
|
// we may not have hit the actual limit if there are encoded bytes...
|
||||||
|
if (i > p) { this._val += this.decoder.write(data.toString('binary', p, i)) }
|
||||||
|
p = i
|
||||||
|
if ((this._val === '' && this.fieldSizeLimit === 0) ||
|
||||||
|
(this._bytesVal = this._val.length) === this.fieldSizeLimit) {
|
||||||
|
// yep, we actually did hit the limit
|
||||||
|
this._checkingBytes = false
|
||||||
|
this._valTrunc = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (p < len) { this._val += this.decoder.write(data.toString('binary', p)) }
|
||||||
|
p = len
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
|
||||||
|
UrlEncoded.prototype.end = function () {
|
||||||
|
if (this.boy._done) { return }
|
||||||
|
|
||||||
|
if (this._state === 'key' && this._key.length > 0) {
|
||||||
|
this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
|
||||||
|
'',
|
||||||
|
this._keyTrunc,
|
||||||
|
false)
|
||||||
|
} else if (this._state === 'val') {
|
||||||
|
this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
|
||||||
|
decodeText(this._val, 'binary', this.charset),
|
||||||
|
this._keyTrunc,
|
||||||
|
this._valTrunc)
|
||||||
|
}
|
||||||
|
this.boy._done = true
|
||||||
|
this.boy.emit('finish')
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = UrlEncoded
|
||||||
54
functions/node_modules/@fastify/busboy/lib/utils/Decoder.js
generated
vendored
Normal file
54
functions/node_modules/@fastify/busboy/lib/utils/Decoder.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const RE_PLUS = /\+/g
|
||||||
|
|
||||||
|
const HEX = [
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
|
]
|
||||||
|
|
||||||
|
function Decoder () {
|
||||||
|
this.buffer = undefined
|
||||||
|
}
|
||||||
|
Decoder.prototype.write = function (str) {
|
||||||
|
// Replace '+' with ' ' before decoding
|
||||||
|
str = str.replace(RE_PLUS, ' ')
|
||||||
|
let res = ''
|
||||||
|
let i = 0; let p = 0; const len = str.length
|
||||||
|
for (; i < len; ++i) {
|
||||||
|
if (this.buffer !== undefined) {
|
||||||
|
if (!HEX[str.charCodeAt(i)]) {
|
||||||
|
res += '%' + this.buffer
|
||||||
|
this.buffer = undefined
|
||||||
|
--i // retry character
|
||||||
|
} else {
|
||||||
|
this.buffer += str[i]
|
||||||
|
++p
|
||||||
|
if (this.buffer.length === 2) {
|
||||||
|
res += String.fromCharCode(parseInt(this.buffer, 16))
|
||||||
|
this.buffer = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (str[i] === '%') {
|
||||||
|
if (i > p) {
|
||||||
|
res += str.substring(p, i)
|
||||||
|
p = i
|
||||||
|
}
|
||||||
|
this.buffer = ''
|
||||||
|
++p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (p < len && this.buffer === undefined) { res += str.substring(p) }
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
Decoder.prototype.reset = function () {
|
||||||
|
this.buffer = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Decoder
|
||||||
14
functions/node_modules/@fastify/busboy/lib/utils/basename.js
generated
vendored
Normal file
14
functions/node_modules/@fastify/busboy/lib/utils/basename.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
module.exports = function basename (path) {
|
||||||
|
if (typeof path !== 'string') { return '' }
|
||||||
|
for (var i = path.length - 1; i >= 0; --i) { // eslint-disable-line no-var
|
||||||
|
switch (path.charCodeAt(i)) {
|
||||||
|
case 0x2F: // '/'
|
||||||
|
case 0x5C: // '\'
|
||||||
|
path = path.slice(i + 1)
|
||||||
|
return (path === '..' || path === '.' ? '' : path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (path === '..' || path === '.' ? '' : path)
|
||||||
|
}
|
||||||
114
functions/node_modules/@fastify/busboy/lib/utils/decodeText.js
generated
vendored
Normal file
114
functions/node_modules/@fastify/busboy/lib/utils/decodeText.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
// Node has always utf-8
|
||||||
|
const utf8Decoder = new TextDecoder('utf-8')
|
||||||
|
const textDecoders = new Map([
|
||||||
|
['utf-8', utf8Decoder],
|
||||||
|
['utf8', utf8Decoder]
|
||||||
|
])
|
||||||
|
|
||||||
|
function getDecoder (charset) {
|
||||||
|
let lc
|
||||||
|
while (true) {
|
||||||
|
switch (charset) {
|
||||||
|
case 'utf-8':
|
||||||
|
case 'utf8':
|
||||||
|
return decoders.utf8
|
||||||
|
case 'latin1':
|
||||||
|
case 'ascii': // TODO: Make these a separate, strict decoder?
|
||||||
|
case 'us-ascii':
|
||||||
|
case 'iso-8859-1':
|
||||||
|
case 'iso8859-1':
|
||||||
|
case 'iso88591':
|
||||||
|
case 'iso_8859-1':
|
||||||
|
case 'windows-1252':
|
||||||
|
case 'iso_8859-1:1987':
|
||||||
|
case 'cp1252':
|
||||||
|
case 'x-cp1252':
|
||||||
|
return decoders.latin1
|
||||||
|
case 'utf16le':
|
||||||
|
case 'utf-16le':
|
||||||
|
case 'ucs2':
|
||||||
|
case 'ucs-2':
|
||||||
|
return decoders.utf16le
|
||||||
|
case 'base64':
|
||||||
|
return decoders.base64
|
||||||
|
default:
|
||||||
|
if (lc === undefined) {
|
||||||
|
lc = true
|
||||||
|
charset = charset.toLowerCase()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return decoders.other.bind(charset)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const decoders = {
|
||||||
|
utf8: (data, sourceEncoding) => {
|
||||||
|
if (data.length === 0) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
data = Buffer.from(data, sourceEncoding)
|
||||||
|
}
|
||||||
|
return data.utf8Slice(0, data.length)
|
||||||
|
},
|
||||||
|
|
||||||
|
latin1: (data, sourceEncoding) => {
|
||||||
|
if (data.length === 0) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
return data.latin1Slice(0, data.length)
|
||||||
|
},
|
||||||
|
|
||||||
|
utf16le: (data, sourceEncoding) => {
|
||||||
|
if (data.length === 0) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
data = Buffer.from(data, sourceEncoding)
|
||||||
|
}
|
||||||
|
return data.ucs2Slice(0, data.length)
|
||||||
|
},
|
||||||
|
|
||||||
|
base64: (data, sourceEncoding) => {
|
||||||
|
if (data.length === 0) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
data = Buffer.from(data, sourceEncoding)
|
||||||
|
}
|
||||||
|
return data.base64Slice(0, data.length)
|
||||||
|
},
|
||||||
|
|
||||||
|
other: (data, sourceEncoding) => {
|
||||||
|
if (data.length === 0) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
data = Buffer.from(data, sourceEncoding)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textDecoders.has(this.toString())) {
|
||||||
|
try {
|
||||||
|
return textDecoders.get(this).decode(data)
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
return typeof data === 'string'
|
||||||
|
? data
|
||||||
|
: data.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function decodeText (text, sourceEncoding, destEncoding) {
|
||||||
|
if (text) {
|
||||||
|
return getDecoder(destEncoding)(text, sourceEncoding)
|
||||||
|
}
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = decodeText
|
||||||
16
functions/node_modules/@fastify/busboy/lib/utils/getLimit.js
generated
vendored
Normal file
16
functions/node_modules/@fastify/busboy/lib/utils/getLimit.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
module.exports = function getLimit (limits, name, defaultLimit) {
|
||||||
|
if (
|
||||||
|
!limits ||
|
||||||
|
limits[name] === undefined ||
|
||||||
|
limits[name] === null
|
||||||
|
) { return defaultLimit }
|
||||||
|
|
||||||
|
if (
|
||||||
|
typeof limits[name] !== 'number' ||
|
||||||
|
isNaN(limits[name])
|
||||||
|
) { throw new TypeError('Limit ' + name + ' is not a valid number') }
|
||||||
|
|
||||||
|
return limits[name]
|
||||||
|
}
|
||||||
201
functions/node_modules/@fastify/busboy/lib/utils/parseParams.js
generated
vendored
Normal file
201
functions/node_modules/@fastify/busboy/lib/utils/parseParams.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
/* eslint-disable object-property-newline */
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const decodeText = require('./decodeText')
|
||||||
|
|
||||||
|
const RE_ENCODED = /%[a-fA-F0-9][a-fA-F0-9]/g
|
||||||
|
|
||||||
|
const EncodedLookup = {
|
||||||
|
'%00': '\x00', '%01': '\x01', '%02': '\x02', '%03': '\x03', '%04': '\x04',
|
||||||
|
'%05': '\x05', '%06': '\x06', '%07': '\x07', '%08': '\x08', '%09': '\x09',
|
||||||
|
'%0a': '\x0a', '%0A': '\x0a', '%0b': '\x0b', '%0B': '\x0b', '%0c': '\x0c',
|
||||||
|
'%0C': '\x0c', '%0d': '\x0d', '%0D': '\x0d', '%0e': '\x0e', '%0E': '\x0e',
|
||||||
|
'%0f': '\x0f', '%0F': '\x0f', '%10': '\x10', '%11': '\x11', '%12': '\x12',
|
||||||
|
'%13': '\x13', '%14': '\x14', '%15': '\x15', '%16': '\x16', '%17': '\x17',
|
||||||
|
'%18': '\x18', '%19': '\x19', '%1a': '\x1a', '%1A': '\x1a', '%1b': '\x1b',
|
||||||
|
'%1B': '\x1b', '%1c': '\x1c', '%1C': '\x1c', '%1d': '\x1d', '%1D': '\x1d',
|
||||||
|
'%1e': '\x1e', '%1E': '\x1e', '%1f': '\x1f', '%1F': '\x1f', '%20': '\x20',
|
||||||
|
'%21': '\x21', '%22': '\x22', '%23': '\x23', '%24': '\x24', '%25': '\x25',
|
||||||
|
'%26': '\x26', '%27': '\x27', '%28': '\x28', '%29': '\x29', '%2a': '\x2a',
|
||||||
|
'%2A': '\x2a', '%2b': '\x2b', '%2B': '\x2b', '%2c': '\x2c', '%2C': '\x2c',
|
||||||
|
'%2d': '\x2d', '%2D': '\x2d', '%2e': '\x2e', '%2E': '\x2e', '%2f': '\x2f',
|
||||||
|
'%2F': '\x2f', '%30': '\x30', '%31': '\x31', '%32': '\x32', '%33': '\x33',
|
||||||
|
'%34': '\x34', '%35': '\x35', '%36': '\x36', '%37': '\x37', '%38': '\x38',
|
||||||
|
'%39': '\x39', '%3a': '\x3a', '%3A': '\x3a', '%3b': '\x3b', '%3B': '\x3b',
|
||||||
|
'%3c': '\x3c', '%3C': '\x3c', '%3d': '\x3d', '%3D': '\x3d', '%3e': '\x3e',
|
||||||
|
'%3E': '\x3e', '%3f': '\x3f', '%3F': '\x3f', '%40': '\x40', '%41': '\x41',
|
||||||
|
'%42': '\x42', '%43': '\x43', '%44': '\x44', '%45': '\x45', '%46': '\x46',
|
||||||
|
'%47': '\x47', '%48': '\x48', '%49': '\x49', '%4a': '\x4a', '%4A': '\x4a',
|
||||||
|
'%4b': '\x4b', '%4B': '\x4b', '%4c': '\x4c', '%4C': '\x4c', '%4d': '\x4d',
|
||||||
|
'%4D': '\x4d', '%4e': '\x4e', '%4E': '\x4e', '%4f': '\x4f', '%4F': '\x4f',
|
||||||
|
'%50': '\x50', '%51': '\x51', '%52': '\x52', '%53': '\x53', '%54': '\x54',
|
||||||
|
'%55': '\x55', '%56': '\x56', '%57': '\x57', '%58': '\x58', '%59': '\x59',
|
||||||
|
'%5a': '\x5a', '%5A': '\x5a', '%5b': '\x5b', '%5B': '\x5b', '%5c': '\x5c',
|
||||||
|
'%5C': '\x5c', '%5d': '\x5d', '%5D': '\x5d', '%5e': '\x5e', '%5E': '\x5e',
|
||||||
|
'%5f': '\x5f', '%5F': '\x5f', '%60': '\x60', '%61': '\x61', '%62': '\x62',
|
||||||
|
'%63': '\x63', '%64': '\x64', '%65': '\x65', '%66': '\x66', '%67': '\x67',
|
||||||
|
'%68': '\x68', '%69': '\x69', '%6a': '\x6a', '%6A': '\x6a', '%6b': '\x6b',
|
||||||
|
'%6B': '\x6b', '%6c': '\x6c', '%6C': '\x6c', '%6d': '\x6d', '%6D': '\x6d',
|
||||||
|
'%6e': '\x6e', '%6E': '\x6e', '%6f': '\x6f', '%6F': '\x6f', '%70': '\x70',
|
||||||
|
'%71': '\x71', '%72': '\x72', '%73': '\x73', '%74': '\x74', '%75': '\x75',
|
||||||
|
'%76': '\x76', '%77': '\x77', '%78': '\x78', '%79': '\x79', '%7a': '\x7a',
|
||||||
|
'%7A': '\x7a', '%7b': '\x7b', '%7B': '\x7b', '%7c': '\x7c', '%7C': '\x7c',
|
||||||
|
'%7d': '\x7d', '%7D': '\x7d', '%7e': '\x7e', '%7E': '\x7e', '%7f': '\x7f',
|
||||||
|
'%7F': '\x7f', '%80': '\x80', '%81': '\x81', '%82': '\x82', '%83': '\x83',
|
||||||
|
'%84': '\x84', '%85': '\x85', '%86': '\x86', '%87': '\x87', '%88': '\x88',
|
||||||
|
'%89': '\x89', '%8a': '\x8a', '%8A': '\x8a', '%8b': '\x8b', '%8B': '\x8b',
|
||||||
|
'%8c': '\x8c', '%8C': '\x8c', '%8d': '\x8d', '%8D': '\x8d', '%8e': '\x8e',
|
||||||
|
'%8E': '\x8e', '%8f': '\x8f', '%8F': '\x8f', '%90': '\x90', '%91': '\x91',
|
||||||
|
'%92': '\x92', '%93': '\x93', '%94': '\x94', '%95': '\x95', '%96': '\x96',
|
||||||
|
'%97': '\x97', '%98': '\x98', '%99': '\x99', '%9a': '\x9a', '%9A': '\x9a',
|
||||||
|
'%9b': '\x9b', '%9B': '\x9b', '%9c': '\x9c', '%9C': '\x9c', '%9d': '\x9d',
|
||||||
|
'%9D': '\x9d', '%9e': '\x9e', '%9E': '\x9e', '%9f': '\x9f', '%9F': '\x9f',
|
||||||
|
'%a0': '\xa0', '%A0': '\xa0', '%a1': '\xa1', '%A1': '\xa1', '%a2': '\xa2',
|
||||||
|
'%A2': '\xa2', '%a3': '\xa3', '%A3': '\xa3', '%a4': '\xa4', '%A4': '\xa4',
|
||||||
|
'%a5': '\xa5', '%A5': '\xa5', '%a6': '\xa6', '%A6': '\xa6', '%a7': '\xa7',
|
||||||
|
'%A7': '\xa7', '%a8': '\xa8', '%A8': '\xa8', '%a9': '\xa9', '%A9': '\xa9',
|
||||||
|
'%aa': '\xaa', '%Aa': '\xaa', '%aA': '\xaa', '%AA': '\xaa', '%ab': '\xab',
|
||||||
|
'%Ab': '\xab', '%aB': '\xab', '%AB': '\xab', '%ac': '\xac', '%Ac': '\xac',
|
||||||
|
'%aC': '\xac', '%AC': '\xac', '%ad': '\xad', '%Ad': '\xad', '%aD': '\xad',
|
||||||
|
'%AD': '\xad', '%ae': '\xae', '%Ae': '\xae', '%aE': '\xae', '%AE': '\xae',
|
||||||
|
'%af': '\xaf', '%Af': '\xaf', '%aF': '\xaf', '%AF': '\xaf', '%b0': '\xb0',
|
||||||
|
'%B0': '\xb0', '%b1': '\xb1', '%B1': '\xb1', '%b2': '\xb2', '%B2': '\xb2',
|
||||||
|
'%b3': '\xb3', '%B3': '\xb3', '%b4': '\xb4', '%B4': '\xb4', '%b5': '\xb5',
|
||||||
|
'%B5': '\xb5', '%b6': '\xb6', '%B6': '\xb6', '%b7': '\xb7', '%B7': '\xb7',
|
||||||
|
'%b8': '\xb8', '%B8': '\xb8', '%b9': '\xb9', '%B9': '\xb9', '%ba': '\xba',
|
||||||
|
'%Ba': '\xba', '%bA': '\xba', '%BA': '\xba', '%bb': '\xbb', '%Bb': '\xbb',
|
||||||
|
'%bB': '\xbb', '%BB': '\xbb', '%bc': '\xbc', '%Bc': '\xbc', '%bC': '\xbc',
|
||||||
|
'%BC': '\xbc', '%bd': '\xbd', '%Bd': '\xbd', '%bD': '\xbd', '%BD': '\xbd',
|
||||||
|
'%be': '\xbe', '%Be': '\xbe', '%bE': '\xbe', '%BE': '\xbe', '%bf': '\xbf',
|
||||||
|
'%Bf': '\xbf', '%bF': '\xbf', '%BF': '\xbf', '%c0': '\xc0', '%C0': '\xc0',
|
||||||
|
'%c1': '\xc1', '%C1': '\xc1', '%c2': '\xc2', '%C2': '\xc2', '%c3': '\xc3',
|
||||||
|
'%C3': '\xc3', '%c4': '\xc4', '%C4': '\xc4', '%c5': '\xc5', '%C5': '\xc5',
|
||||||
|
'%c6': '\xc6', '%C6': '\xc6', '%c7': '\xc7', '%C7': '\xc7', '%c8': '\xc8',
|
||||||
|
'%C8': '\xc8', '%c9': '\xc9', '%C9': '\xc9', '%ca': '\xca', '%Ca': '\xca',
|
||||||
|
'%cA': '\xca', '%CA': '\xca', '%cb': '\xcb', '%Cb': '\xcb', '%cB': '\xcb',
|
||||||
|
'%CB': '\xcb', '%cc': '\xcc', '%Cc': '\xcc', '%cC': '\xcc', '%CC': '\xcc',
|
||||||
|
'%cd': '\xcd', '%Cd': '\xcd', '%cD': '\xcd', '%CD': '\xcd', '%ce': '\xce',
|
||||||
|
'%Ce': '\xce', '%cE': '\xce', '%CE': '\xce', '%cf': '\xcf', '%Cf': '\xcf',
|
||||||
|
'%cF': '\xcf', '%CF': '\xcf', '%d0': '\xd0', '%D0': '\xd0', '%d1': '\xd1',
|
||||||
|
'%D1': '\xd1', '%d2': '\xd2', '%D2': '\xd2', '%d3': '\xd3', '%D3': '\xd3',
|
||||||
|
'%d4': '\xd4', '%D4': '\xd4', '%d5': '\xd5', '%D5': '\xd5', '%d6': '\xd6',
|
||||||
|
'%D6': '\xd6', '%d7': '\xd7', '%D7': '\xd7', '%d8': '\xd8', '%D8': '\xd8',
|
||||||
|
'%d9': '\xd9', '%D9': '\xd9', '%da': '\xda', '%Da': '\xda', '%dA': '\xda',
|
||||||
|
'%DA': '\xda', '%db': '\xdb', '%Db': '\xdb', '%dB': '\xdb', '%DB': '\xdb',
|
||||||
|
'%dc': '\xdc', '%Dc': '\xdc', '%dC': '\xdc', '%DC': '\xdc', '%dd': '\xdd',
|
||||||
|
'%Dd': '\xdd', '%dD': '\xdd', '%DD': '\xdd', '%de': '\xde', '%De': '\xde',
|
||||||
|
'%dE': '\xde', '%DE': '\xde', '%df': '\xdf', '%Df': '\xdf', '%dF': '\xdf',
|
||||||
|
'%DF': '\xdf', '%e0': '\xe0', '%E0': '\xe0', '%e1': '\xe1', '%E1': '\xe1',
|
||||||
|
'%e2': '\xe2', '%E2': '\xe2', '%e3': '\xe3', '%E3': '\xe3', '%e4': '\xe4',
|
||||||
|
'%E4': '\xe4', '%e5': '\xe5', '%E5': '\xe5', '%e6': '\xe6', '%E6': '\xe6',
|
||||||
|
'%e7': '\xe7', '%E7': '\xe7', '%e8': '\xe8', '%E8': '\xe8', '%e9': '\xe9',
|
||||||
|
'%E9': '\xe9', '%ea': '\xea', '%Ea': '\xea', '%eA': '\xea', '%EA': '\xea',
|
||||||
|
'%eb': '\xeb', '%Eb': '\xeb', '%eB': '\xeb', '%EB': '\xeb', '%ec': '\xec',
|
||||||
|
'%Ec': '\xec', '%eC': '\xec', '%EC': '\xec', '%ed': '\xed', '%Ed': '\xed',
|
||||||
|
'%eD': '\xed', '%ED': '\xed', '%ee': '\xee', '%Ee': '\xee', '%eE': '\xee',
|
||||||
|
'%EE': '\xee', '%ef': '\xef', '%Ef': '\xef', '%eF': '\xef', '%EF': '\xef',
|
||||||
|
'%f0': '\xf0', '%F0': '\xf0', '%f1': '\xf1', '%F1': '\xf1', '%f2': '\xf2',
|
||||||
|
'%F2': '\xf2', '%f3': '\xf3', '%F3': '\xf3', '%f4': '\xf4', '%F4': '\xf4',
|
||||||
|
'%f5': '\xf5', '%F5': '\xf5', '%f6': '\xf6', '%F6': '\xf6', '%f7': '\xf7',
|
||||||
|
'%F7': '\xf7', '%f8': '\xf8', '%F8': '\xf8', '%f9': '\xf9', '%F9': '\xf9',
|
||||||
|
'%fa': '\xfa', '%Fa': '\xfa', '%fA': '\xfa', '%FA': '\xfa', '%fb': '\xfb',
|
||||||
|
'%Fb': '\xfb', '%fB': '\xfb', '%FB': '\xfb', '%fc': '\xfc', '%Fc': '\xfc',
|
||||||
|
'%fC': '\xfc', '%FC': '\xfc', '%fd': '\xfd', '%Fd': '\xfd', '%fD': '\xfd',
|
||||||
|
'%FD': '\xfd', '%fe': '\xfe', '%Fe': '\xfe', '%fE': '\xfe', '%FE': '\xfe',
|
||||||
|
'%ff': '\xff', '%Ff': '\xff', '%fF': '\xff', '%FF': '\xff'
|
||||||
|
}
|
||||||
|
|
||||||
|
function encodedReplacer (match) {
|
||||||
|
return EncodedLookup[match]
|
||||||
|
}
|
||||||
|
|
||||||
|
const STATE_KEY = 0
|
||||||
|
const STATE_VALUE = 1
|
||||||
|
const STATE_CHARSET = 2
|
||||||
|
const STATE_LANG = 3
|
||||||
|
|
||||||
|
function parseParams (str) {
|
||||||
|
const res = []
|
||||||
|
let state = STATE_KEY
|
||||||
|
let charset = ''
|
||||||
|
let inquote = false
|
||||||
|
let escaping = false
|
||||||
|
let p = 0
|
||||||
|
let tmp = ''
|
||||||
|
const len = str.length
|
||||||
|
|
||||||
|
for (var i = 0; i < len; ++i) { // eslint-disable-line no-var
|
||||||
|
const char = str[i]
|
||||||
|
if (char === '\\' && inquote) {
|
||||||
|
if (escaping) { escaping = false } else {
|
||||||
|
escaping = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
} else if (char === '"') {
|
||||||
|
if (!escaping) {
|
||||||
|
if (inquote) {
|
||||||
|
inquote = false
|
||||||
|
state = STATE_KEY
|
||||||
|
// Skip any remaining characters until we hit a semicolon or end of string
|
||||||
|
// This ensures we don't include characters after the closing quote
|
||||||
|
while (i + 1 < len && str[i + 1] !== ';') {
|
||||||
|
++i
|
||||||
|
}
|
||||||
|
} else { inquote = true }
|
||||||
|
continue
|
||||||
|
} else { escaping = false }
|
||||||
|
} else {
|
||||||
|
if (escaping && inquote) { tmp += '\\' }
|
||||||
|
escaping = false
|
||||||
|
if ((state === STATE_CHARSET || state === STATE_LANG) && char === "'") {
|
||||||
|
if (state === STATE_CHARSET) {
|
||||||
|
state = STATE_LANG
|
||||||
|
charset = tmp.substring(1)
|
||||||
|
} else { state = STATE_VALUE }
|
||||||
|
tmp = ''
|
||||||
|
continue
|
||||||
|
} else if (state === STATE_KEY &&
|
||||||
|
(char === '*' || char === '=') &&
|
||||||
|
res.length) {
|
||||||
|
state = char === '*'
|
||||||
|
? STATE_CHARSET
|
||||||
|
: STATE_VALUE
|
||||||
|
res[p] = [tmp, undefined]
|
||||||
|
tmp = ''
|
||||||
|
continue
|
||||||
|
} else if (!inquote && char === ';') {
|
||||||
|
state = STATE_KEY
|
||||||
|
if (charset) {
|
||||||
|
if (tmp.length) {
|
||||||
|
tmp = decodeText(tmp.replace(RE_ENCODED, encodedReplacer),
|
||||||
|
'binary',
|
||||||
|
charset)
|
||||||
|
}
|
||||||
|
charset = ''
|
||||||
|
} else if (tmp.length) {
|
||||||
|
tmp = decodeText(tmp, 'binary', 'utf8')
|
||||||
|
}
|
||||||
|
if (res[p] === undefined) { res[p] = tmp } else { res[p][1] = tmp }
|
||||||
|
tmp = ''
|
||||||
|
++p
|
||||||
|
continue
|
||||||
|
} else if (!inquote && (char === ' ' || char === '\t')) { continue }
|
||||||
|
}
|
||||||
|
tmp += char
|
||||||
|
}
|
||||||
|
if (charset && tmp.length) {
|
||||||
|
tmp = decodeText(tmp.replace(RE_ENCODED, encodedReplacer),
|
||||||
|
'binary',
|
||||||
|
charset)
|
||||||
|
} else if (tmp) {
|
||||||
|
tmp = decodeText(tmp, 'binary', 'utf8')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res[p] === undefined) {
|
||||||
|
if (tmp) { res[p] = tmp }
|
||||||
|
} else { res[p][1] = tmp }
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = parseParams
|
||||||
81
functions/node_modules/@fastify/busboy/package.json
generated
vendored
Normal file
81
functions/node_modules/@fastify/busboy/package.json
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
{
|
||||||
|
"name": "@fastify/busboy",
|
||||||
|
"version": "3.2.0",
|
||||||
|
"private": false,
|
||||||
|
"author": "Brian White <mscdex@mscdex.net>",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Igor Savin",
|
||||||
|
"email": "kibertoad@gmail.com",
|
||||||
|
"url": "https://github.com/kibertoad"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Aras Abbasi",
|
||||||
|
"email": "aras.abbasi@gmail.com",
|
||||||
|
"url": "https://github.com/uzlopak"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A streaming parser for HTML form data for node.js",
|
||||||
|
"main": "lib/main",
|
||||||
|
"type": "commonjs",
|
||||||
|
"types": "lib/main.d.ts",
|
||||||
|
"scripts": {
|
||||||
|
"bench:busboy": "cd benchmarks && npm install && npm run benchmark-fastify",
|
||||||
|
"bench:dicer": "node bench/dicer/dicer-bench-multipart-parser.js",
|
||||||
|
"coveralls": "nyc report --reporter=lcov",
|
||||||
|
"lint": "npm run lint:standard",
|
||||||
|
"lint:fix": "standard --fix",
|
||||||
|
"lint:standard": "standard --verbose | snazzy",
|
||||||
|
"test:unit": "c8 --statements 98 --branches 97 --functions 96 --lines 98 node --test",
|
||||||
|
"test:types": "tsd",
|
||||||
|
"test": "npm run test:unit && npm run test:types"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^24.0.8",
|
||||||
|
"busboy": "^1.6.0",
|
||||||
|
"c8": "^10.1.2",
|
||||||
|
"photofinish": "^1.8.0",
|
||||||
|
"snazzy": "^9.0.0",
|
||||||
|
"standard": "^17.1.0",
|
||||||
|
"tinybench": "^4.0.1",
|
||||||
|
"tsd": "^0.32.0",
|
||||||
|
"tslib": "^2.8.1",
|
||||||
|
"typescript": "~5.9.2"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"uploads",
|
||||||
|
"forms",
|
||||||
|
"multipart",
|
||||||
|
"form-data"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/fastify/busboy.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/fastify/busboy/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/fastify/busboy#readme",
|
||||||
|
"tsd": {
|
||||||
|
"directory": "test-types"
|
||||||
|
},
|
||||||
|
"standard": {
|
||||||
|
"globals": [
|
||||||
|
"describe",
|
||||||
|
"it"
|
||||||
|
],
|
||||||
|
"ignore": [
|
||||||
|
"bench"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"README.md",
|
||||||
|
"LICENSE",
|
||||||
|
"lib/*",
|
||||||
|
"deps/encoding/*",
|
||||||
|
"deps/dicer/lib",
|
||||||
|
"deps/streamsearch/",
|
||||||
|
"deps/dicer/LICENSE"
|
||||||
|
]
|
||||||
|
}
|
||||||
3
functions/node_modules/@firebase/app-check-interop-types/README.md
generated
vendored
Normal file
3
functions/node_modules/@firebase/app-check-interop-types/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# @firebase/app-check-interop-types
|
||||||
|
|
||||||
|
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
|
||||||
51
functions/node_modules/@firebase/app-check-interop-types/index.d.ts
generated
vendored
Normal file
51
functions/node_modules/@firebase/app-check-interop-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2020 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface FirebaseAppCheckInternal {
|
||||||
|
// Get the current AttestationToken. Attaches to the most recent in-flight request if one
|
||||||
|
// is present. Returns null if no token is present and no token requests are in-flight.
|
||||||
|
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
||||||
|
|
||||||
|
// Always returns a fresh limited-use token suitable for Replay Protection.
|
||||||
|
// The returned token must be used and consumed as soon as possible.
|
||||||
|
getLimitedUseToken(): Promise<AppCheckTokenResult>;
|
||||||
|
|
||||||
|
// Registers a listener to changes in the token state. There can be more than one listener
|
||||||
|
// registered at the same time for one or more FirebaseAppAttestation instances. The
|
||||||
|
// listeners call back on the UI thread whenever the current token associated with this
|
||||||
|
// FirebaseAppAttestation changes.
|
||||||
|
addTokenListener(listener: AppCheckTokenListener): void;
|
||||||
|
|
||||||
|
// Unregisters a listener to changes in the token state.
|
||||||
|
removeTokenListener(listener: AppCheckTokenListener): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
type AppCheckTokenListener = (token: AppCheckTokenResult) => void;
|
||||||
|
|
||||||
|
// If the error field is defined, the token field will be populated with a dummy token
|
||||||
|
interface AppCheckTokenResult {
|
||||||
|
readonly token: string;
|
||||||
|
readonly error?: Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AppCheckInternalComponentName = 'app-check-internal';
|
||||||
|
|
||||||
|
declare module '@firebase/component' {
|
||||||
|
interface NameServiceMapping {
|
||||||
|
'app-check-internal': FirebaseAppCheckInternal;
|
||||||
|
}
|
||||||
|
}
|
||||||
25
functions/node_modules/@firebase/app-check-interop-types/package.json
generated
vendored
Normal file
25
functions/node_modules/@firebase/app-check-interop-types/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "@firebase/app-check-interop-types",
|
||||||
|
"version": "0.3.2",
|
||||||
|
"description": "@firebase/app-check-interop-types Types",
|
||||||
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"scripts": {
|
||||||
|
"test": "tsc",
|
||||||
|
"test:ci": "node ../../scripts/run_tests_in_ci.js"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"directory": "packages/app-check-interop-types",
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "4.7.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
3
functions/node_modules/@firebase/app-types/README.md
generated
vendored
Normal file
3
functions/node_modules/@firebase/app-types/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# @firebase/app-types
|
||||||
|
|
||||||
|
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
|
||||||
129
functions/node_modules/@firebase/app-types/index.d.ts
generated
vendored
Normal file
129
functions/node_modules/@firebase/app-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { LogCallback, LogLevelString, LogOptions } from '@firebase/logger';
|
||||||
|
|
||||||
|
export type FirebaseOptions = {
|
||||||
|
apiKey?: string;
|
||||||
|
authDomain?: string;
|
||||||
|
databaseURL?: string;
|
||||||
|
projectId?: string;
|
||||||
|
storageBucket?: string;
|
||||||
|
messagingSenderId?: string;
|
||||||
|
appId?: string;
|
||||||
|
measurementId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface FirebaseAppConfig {
|
||||||
|
name?: string;
|
||||||
|
automaticDataCollectionEnabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FirebaseApp {
|
||||||
|
/**
|
||||||
|
* The (read-only) name (identifier) for this App. '[DEFAULT]' is the default
|
||||||
|
* App.
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The (read-only) configuration options from the app initialization.
|
||||||
|
*/
|
||||||
|
options: FirebaseOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The settable config flag for GDPR opt-in/opt-out
|
||||||
|
*/
|
||||||
|
automaticDataCollectionEnabled: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make the given App unusable and free resources.
|
||||||
|
*/
|
||||||
|
delete(): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FirebaseNamespace {
|
||||||
|
/**
|
||||||
|
* Create (and initialize) a FirebaseApp.
|
||||||
|
*
|
||||||
|
* @param options Options to configure the services used in the App.
|
||||||
|
* @param config The optional config for your firebase app
|
||||||
|
*/
|
||||||
|
initializeApp(
|
||||||
|
options: FirebaseOptions,
|
||||||
|
config?: FirebaseAppConfig
|
||||||
|
): FirebaseApp;
|
||||||
|
/**
|
||||||
|
* Create (and initialize) a FirebaseApp.
|
||||||
|
*
|
||||||
|
* @param options Options to configure the services used in the App.
|
||||||
|
* @param name The optional name of the app to initialize ('[DEFAULT]' if
|
||||||
|
* omitted)
|
||||||
|
*/
|
||||||
|
initializeApp(options: FirebaseOptions, name?: string): FirebaseApp;
|
||||||
|
|
||||||
|
app: {
|
||||||
|
/**
|
||||||
|
* Retrieve an instance of a FirebaseApp.
|
||||||
|
*
|
||||||
|
* Usage: firebase.app()
|
||||||
|
*
|
||||||
|
* @param name The optional name of the app to return ('[DEFAULT]' if omitted)
|
||||||
|
*/
|
||||||
|
(name?: string): FirebaseApp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For testing FirebaseApp instances:
|
||||||
|
* app() instanceof firebase.app.App
|
||||||
|
*
|
||||||
|
* DO NOT call this constuctor directly (use firebase.app() instead).
|
||||||
|
*/
|
||||||
|
App: typeof FirebaseApp;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A (read-only) array of all the initialized Apps.
|
||||||
|
*/
|
||||||
|
apps: FirebaseApp[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a library's name and version for platform logging purposes.
|
||||||
|
* @param library Name of 1p or 3p library (e.g. firestore, angularfire)
|
||||||
|
* @param version Current version of that library.
|
||||||
|
*/
|
||||||
|
registerVersion(library: string, version: string, variant?: string): void;
|
||||||
|
|
||||||
|
// Sets log level for all Firebase components.
|
||||||
|
setLogLevel(logLevel: LogLevelString): void;
|
||||||
|
|
||||||
|
// Sets log handler for all Firebase components.
|
||||||
|
onLog(logCallback: LogCallback, options?: LogOptions): void;
|
||||||
|
|
||||||
|
// The current SDK version.
|
||||||
|
SDK_VERSION: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface VersionService {
|
||||||
|
library: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@firebase/component' {
|
||||||
|
interface NameServiceMapping {
|
||||||
|
'app-version': VersionService;
|
||||||
|
'platform-identifier': VersionService;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
functions/node_modules/@firebase/app-types/package.json
generated
vendored
Normal file
29
functions/node_modules/@firebase/app-types/package.json
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "@firebase/app-types",
|
||||||
|
"version": "0.9.2",
|
||||||
|
"description": "@firebase/app Types",
|
||||||
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"scripts": {
|
||||||
|
"test": "tsc",
|
||||||
|
"test:ci": "node ../../scripts/run_tests_in_ci.js"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.d.ts",
|
||||||
|
"private.d.ts"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"directory": "packages/app-types",
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||||
|
},
|
||||||
|
"dependency": {
|
||||||
|
"@firebase/logger": "0.2.6"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "4.7.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
165
functions/node_modules/@firebase/app-types/private.d.ts
generated
vendored
Normal file
165
functions/node_modules/@firebase/app-types/private.d.ts
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* THIS FILE IS FOR INTERNAL USAGE ONLY, IF YOU ARE NOT DEVELOPING THE FIREBASE
|
||||||
|
* SDKs, PLEASE DO NOT REFERENCE THIS FILE AS IT MAY CHANGE WITHOUT WARNING
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { FirebaseApp, FirebaseNamespace } from '@firebase/app-types';
|
||||||
|
import { Observer, Subscribe } from '@firebase/util';
|
||||||
|
import { FirebaseError, ErrorFactory } from '@firebase/util';
|
||||||
|
import { Component, ComponentContainer, Name } from '@firebase/component';
|
||||||
|
|
||||||
|
export interface FirebaseServiceInternals {
|
||||||
|
/**
|
||||||
|
* Delete the service and free it's resources - called from
|
||||||
|
* app.delete().
|
||||||
|
*/
|
||||||
|
delete(): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Services are exposed through instances - each of which is associated with a
|
||||||
|
// FirebaseApp.
|
||||||
|
export interface FirebaseService {
|
||||||
|
app: FirebaseApp;
|
||||||
|
INTERNAL?: FirebaseServiceInternals;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AppHook = (event: string, app: FirebaseApp) => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Firebase Services create instances given a Firebase App instance and can
|
||||||
|
* optionally add properties and methods to each FirebaseApp via the extendApp()
|
||||||
|
* function.
|
||||||
|
*/
|
||||||
|
export interface FirebaseServiceFactory {
|
||||||
|
(
|
||||||
|
app: FirebaseApp,
|
||||||
|
extendApp?: (props: { [prop: string]: any }) => void,
|
||||||
|
instanceString?: string
|
||||||
|
): FirebaseService;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlatformLoggerService {
|
||||||
|
getPlatformInfoString(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All ServiceNamespaces extend from FirebaseServiceNamespace
|
||||||
|
*/
|
||||||
|
export interface FirebaseServiceNamespace<T extends FirebaseService> {
|
||||||
|
(app?: FirebaseApp): T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FirebaseAuthTokenData {
|
||||||
|
accessToken: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FirebaseAppInternals {
|
||||||
|
getToken(refreshToken?: boolean): Promise<FirebaseAuthTokenData | null>;
|
||||||
|
getUid(): string | null;
|
||||||
|
addAuthTokenListener(fn: (token: string | null) => void): void;
|
||||||
|
removeAuthTokenListener(fn: (token: string | null) => void): void;
|
||||||
|
analytics: {
|
||||||
|
logEvent: (
|
||||||
|
eventName: string,
|
||||||
|
eventParams: { [key: string]: any },
|
||||||
|
options?: { global: boolean }
|
||||||
|
) => void;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface _FirebaseApp extends FirebaseApp {
|
||||||
|
container: ComponentContainer;
|
||||||
|
_addComponent<T extends Name>(component: Component<T>): void;
|
||||||
|
_addOrOverwriteComponent<T extends Name>(component: Component<T>): void;
|
||||||
|
_removeServiceInstance(name: string, instanceIdentifier?: string): void;
|
||||||
|
}
|
||||||
|
export interface _FirebaseNamespace extends FirebaseNamespace {
|
||||||
|
INTERNAL: {
|
||||||
|
/**
|
||||||
|
* Internal API to register a Firebase Service into the firebase namespace.
|
||||||
|
*
|
||||||
|
* Each service will create a child namespace (firebase.<name>) which acts as
|
||||||
|
* both a namespace for service specific properties, and also as a service
|
||||||
|
* accessor function (firebase.<name>() or firebase.<name>(app)).
|
||||||
|
*
|
||||||
|
* @param name The Firebase Service being registered.
|
||||||
|
* @param createService Factory function to create a service instance.
|
||||||
|
* @param serviceProperties Properties to copy to the service's namespace.
|
||||||
|
* @param appHook All appHooks called before initializeApp returns to caller.
|
||||||
|
* @param allowMultipleInstances Whether the registered service supports
|
||||||
|
* multiple instances per app. If not specified, the default is false.
|
||||||
|
*/
|
||||||
|
registerComponent<T extends Name>(
|
||||||
|
component: Component<T>
|
||||||
|
): FirebaseServiceNamespace<FirebaseService> | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just used for testing to start from a fresh namespace.
|
||||||
|
*/
|
||||||
|
createFirebaseNamespace(): FirebaseNamespace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal API to install properties on the top-level firebase namespace.
|
||||||
|
* @prop props The top level properties of this object are copied to the
|
||||||
|
* namespace.
|
||||||
|
*/
|
||||||
|
extendNamespace(props: { [prop: string]: any }): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Subscribe function. A proxy Observer is created so that
|
||||||
|
* events can be sent to single Observer to be fanned out automatically.
|
||||||
|
*/
|
||||||
|
createSubscribe<T>(
|
||||||
|
executor: (observer: Observer<T>) => void,
|
||||||
|
onNoObservers?: (observer: Observer<T>) => void
|
||||||
|
): Subscribe<T>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility exposed for internal testing.
|
||||||
|
*/
|
||||||
|
deepExtend(target: any, source: any): any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal API to remove an app from the list of registered apps.
|
||||||
|
*/
|
||||||
|
removeApp(name: string): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* registered components.
|
||||||
|
*/
|
||||||
|
components: Map<string, Component>;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert service name to factory name to use.
|
||||||
|
*/
|
||||||
|
useAsService(app: FirebaseApp, serviceName: string): string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use to construct all thrown FirebaseError's.
|
||||||
|
*/
|
||||||
|
ErrorFactory: typeof ErrorFactory;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@firebase/component' {
|
||||||
|
interface NameServiceMapping {
|
||||||
|
'platform-logger': PlatformLoggerService;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
functions/node_modules/@firebase/auth-interop-types/README.md
generated
vendored
Normal file
3
functions/node_modules/@firebase/auth-interop-types/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# @firebase/auth-interop-types
|
||||||
|
|
||||||
|
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
|
||||||
35
functions/node_modules/@firebase/auth-interop-types/index.d.ts
generated
vendored
Normal file
35
functions/node_modules/@firebase/auth-interop-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface FirebaseAuthTokenData {
|
||||||
|
accessToken: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FirebaseAuthInternal {
|
||||||
|
getToken(refreshToken?: boolean): Promise<FirebaseAuthTokenData | null>;
|
||||||
|
getUid(): string | null;
|
||||||
|
addAuthTokenListener(fn: (token: string | null) => void): void;
|
||||||
|
removeAuthTokenListener(fn: (token: string | null) => void): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FirebaseAuthInternalName = 'auth-internal';
|
||||||
|
|
||||||
|
declare module '@firebase/component' {
|
||||||
|
interface NameServiceMapping {
|
||||||
|
'auth-internal': FirebaseAuthInternal;
|
||||||
|
}
|
||||||
|
}
|
||||||
25
functions/node_modules/@firebase/auth-interop-types/package.json
generated
vendored
Normal file
25
functions/node_modules/@firebase/auth-interop-types/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "@firebase/auth-interop-types",
|
||||||
|
"version": "0.2.3",
|
||||||
|
"description": "@firebase/auth interop Types",
|
||||||
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"scripts": {
|
||||||
|
"test": "tsc",
|
||||||
|
"test:ci": "node ../../scripts/run_tests_in_ci.js"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"directory": "packages/auth-types",
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "4.7.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
12
functions/node_modules/@firebase/component/README.md
generated
vendored
Normal file
12
functions/node_modules/@firebase/component/README.md
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# @firebase/component
|
||||||
|
|
||||||
|
_NOTE: This is specifically tailored for Firebase JS SDK usage, if you are not a
|
||||||
|
member of the Firebase team, please avoid using this package_
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
**ES Modules**
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { Component } from '@firebase/component';
|
||||||
|
```
|
||||||
20
functions/node_modules/@firebase/component/dist/esm/index.d.ts
generated
vendored
Normal file
20
functions/node_modules/@firebase/component/dist/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export { Component } from './src/component';
|
||||||
|
export { ComponentContainer } from './src/component_container';
|
||||||
|
export { Provider } from './src/provider';
|
||||||
|
export { ComponentType, InstanceFactory, InstantiationMode, NameServiceMapping, Name, InstanceFactoryOptions } from './src/types';
|
||||||
409
functions/node_modules/@firebase/component/dist/esm/index.esm2017.js
generated
vendored
Normal file
409
functions/node_modules/@firebase/component/dist/esm/index.esm2017.js
generated
vendored
Normal file
@@ -0,0 +1,409 @@
|
|||||||
|
import { Deferred } from '@firebase/util';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component for service name T, e.g. `auth`, `auth-internal`
|
||||||
|
*/
|
||||||
|
class Component {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param name The public service name, e.g. app, auth, firestore, database
|
||||||
|
* @param instanceFactory Service factory responsible for creating the public interface
|
||||||
|
* @param type whether the service provided by the component is public or private
|
||||||
|
*/
|
||||||
|
constructor(name, instanceFactory, type) {
|
||||||
|
this.name = name;
|
||||||
|
this.instanceFactory = instanceFactory;
|
||||||
|
this.type = type;
|
||||||
|
this.multipleInstances = false;
|
||||||
|
/**
|
||||||
|
* Properties to be added to the service namespace
|
||||||
|
*/
|
||||||
|
this.serviceProps = {};
|
||||||
|
this.instantiationMode = "LAZY" /* InstantiationMode.LAZY */;
|
||||||
|
this.onInstanceCreated = null;
|
||||||
|
}
|
||||||
|
setInstantiationMode(mode) {
|
||||||
|
this.instantiationMode = mode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
setMultipleInstances(multipleInstances) {
|
||||||
|
this.multipleInstances = multipleInstances;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
setServiceProps(props) {
|
||||||
|
this.serviceProps = props;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
setInstanceCreatedCallback(callback) {
|
||||||
|
this.onInstanceCreated = callback;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
const DEFAULT_ENTRY_NAME = '[DEFAULT]';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
|
||||||
|
* NameServiceMapping[T] is an alias for the type of the instance
|
||||||
|
*/
|
||||||
|
class Provider {
|
||||||
|
constructor(name, container) {
|
||||||
|
this.name = name;
|
||||||
|
this.container = container;
|
||||||
|
this.component = null;
|
||||||
|
this.instances = new Map();
|
||||||
|
this.instancesDeferred = new Map();
|
||||||
|
this.instancesOptions = new Map();
|
||||||
|
this.onInitCallbacks = new Map();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param identifier A provider can provide multiple instances of a service
|
||||||
|
* if this.component.multipleInstances is true.
|
||||||
|
*/
|
||||||
|
get(identifier) {
|
||||||
|
// if multipleInstances is not supported, use the default name
|
||||||
|
const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
|
||||||
|
if (!this.instancesDeferred.has(normalizedIdentifier)) {
|
||||||
|
const deferred = new Deferred();
|
||||||
|
this.instancesDeferred.set(normalizedIdentifier, deferred);
|
||||||
|
if (this.isInitialized(normalizedIdentifier) ||
|
||||||
|
this.shouldAutoInitialize()) {
|
||||||
|
// initialize the service if it can be auto-initialized
|
||||||
|
try {
|
||||||
|
const instance = this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier
|
||||||
|
});
|
||||||
|
if (instance) {
|
||||||
|
deferred.resolve(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// when the instance factory throws an exception during get(), it should not cause
|
||||||
|
// a fatal error. We just return the unresolved promise in this case.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.instancesDeferred.get(normalizedIdentifier).promise;
|
||||||
|
}
|
||||||
|
getImmediate(options) {
|
||||||
|
var _a;
|
||||||
|
// if multipleInstances is not supported, use the default name
|
||||||
|
const normalizedIdentifier = this.normalizeInstanceIdentifier(options === null || options === void 0 ? void 0 : options.identifier);
|
||||||
|
const optional = (_a = options === null || options === void 0 ? void 0 : options.optional) !== null && _a !== void 0 ? _a : false;
|
||||||
|
if (this.isInitialized(normalizedIdentifier) ||
|
||||||
|
this.shouldAutoInitialize()) {
|
||||||
|
try {
|
||||||
|
return this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (optional) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// In case a component is not initialized and should/cannot be auto-initialized at the moment, return null if the optional flag is set, or throw
|
||||||
|
if (optional) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw Error(`Service ${this.name} is not available`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getComponent() {
|
||||||
|
return this.component;
|
||||||
|
}
|
||||||
|
setComponent(component) {
|
||||||
|
if (component.name !== this.name) {
|
||||||
|
throw Error(`Mismatching Component ${component.name} for Provider ${this.name}.`);
|
||||||
|
}
|
||||||
|
if (this.component) {
|
||||||
|
throw Error(`Component for ${this.name} has already been provided`);
|
||||||
|
}
|
||||||
|
this.component = component;
|
||||||
|
// return early without attempting to initialize the component if the component requires explicit initialization (calling `Provider.initialize()`)
|
||||||
|
if (!this.shouldAutoInitialize()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// if the service is eager, initialize the default instance
|
||||||
|
if (isComponentEager(component)) {
|
||||||
|
try {
|
||||||
|
this.getOrInitializeService({ instanceIdentifier: DEFAULT_ENTRY_NAME });
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// when the instance factory for an eager Component throws an exception during the eager
|
||||||
|
// initialization, it should not cause a fatal error.
|
||||||
|
// TODO: Investigate if we need to make it configurable, because some component may want to cause
|
||||||
|
// a fatal error in this case?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Create service instances for the pending promises and resolve them
|
||||||
|
// NOTE: if this.multipleInstances is false, only the default instance will be created
|
||||||
|
// and all promises with resolve with it regardless of the identifier.
|
||||||
|
for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()) {
|
||||||
|
const normalizedIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
|
||||||
|
try {
|
||||||
|
// `getOrInitializeService()` should always return a valid instance since a component is guaranteed. use ! to make typescript happy.
|
||||||
|
const instance = this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier
|
||||||
|
});
|
||||||
|
instanceDeferred.resolve(instance);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// when the instance factory throws an exception, it should not cause
|
||||||
|
// a fatal error. We just leave the promise unresolved.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clearInstance(identifier = DEFAULT_ENTRY_NAME) {
|
||||||
|
this.instancesDeferred.delete(identifier);
|
||||||
|
this.instancesOptions.delete(identifier);
|
||||||
|
this.instances.delete(identifier);
|
||||||
|
}
|
||||||
|
// app.delete() will call this method on every provider to delete the services
|
||||||
|
// TODO: should we mark the provider as deleted?
|
||||||
|
async delete() {
|
||||||
|
const services = Array.from(this.instances.values());
|
||||||
|
await Promise.all([
|
||||||
|
...services
|
||||||
|
.filter(service => 'INTERNAL' in service) // legacy services
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
.map(service => service.INTERNAL.delete()),
|
||||||
|
...services
|
||||||
|
.filter(service => '_delete' in service) // modularized services
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
.map(service => service._delete())
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
isComponentSet() {
|
||||||
|
return this.component != null;
|
||||||
|
}
|
||||||
|
isInitialized(identifier = DEFAULT_ENTRY_NAME) {
|
||||||
|
return this.instances.has(identifier);
|
||||||
|
}
|
||||||
|
getOptions(identifier = DEFAULT_ENTRY_NAME) {
|
||||||
|
return this.instancesOptions.get(identifier) || {};
|
||||||
|
}
|
||||||
|
initialize(opts = {}) {
|
||||||
|
const { options = {} } = opts;
|
||||||
|
const normalizedIdentifier = this.normalizeInstanceIdentifier(opts.instanceIdentifier);
|
||||||
|
if (this.isInitialized(normalizedIdentifier)) {
|
||||||
|
throw Error(`${this.name}(${normalizedIdentifier}) has already been initialized`);
|
||||||
|
}
|
||||||
|
if (!this.isComponentSet()) {
|
||||||
|
throw Error(`Component ${this.name} has not been registered yet`);
|
||||||
|
}
|
||||||
|
const instance = this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier,
|
||||||
|
options
|
||||||
|
});
|
||||||
|
// resolve any pending promise waiting for the service instance
|
||||||
|
for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()) {
|
||||||
|
const normalizedDeferredIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
|
||||||
|
if (normalizedIdentifier === normalizedDeferredIdentifier) {
|
||||||
|
instanceDeferred.resolve(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
|
||||||
|
* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
|
||||||
|
*
|
||||||
|
* @param identifier An optional instance identifier
|
||||||
|
* @returns a function to unregister the callback
|
||||||
|
*/
|
||||||
|
onInit(callback, identifier) {
|
||||||
|
var _a;
|
||||||
|
const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
|
||||||
|
const existingCallbacks = (_a = this.onInitCallbacks.get(normalizedIdentifier)) !== null && _a !== void 0 ? _a : new Set();
|
||||||
|
existingCallbacks.add(callback);
|
||||||
|
this.onInitCallbacks.set(normalizedIdentifier, existingCallbacks);
|
||||||
|
const existingInstance = this.instances.get(normalizedIdentifier);
|
||||||
|
if (existingInstance) {
|
||||||
|
callback(existingInstance, normalizedIdentifier);
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
existingCallbacks.delete(callback);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Invoke onInit callbacks synchronously
|
||||||
|
* @param instance the service instance`
|
||||||
|
*/
|
||||||
|
invokeOnInitCallbacks(instance, identifier) {
|
||||||
|
const callbacks = this.onInitCallbacks.get(identifier);
|
||||||
|
if (!callbacks) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const callback of callbacks) {
|
||||||
|
try {
|
||||||
|
callback(instance, identifier);
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
// ignore errors in the onInit callback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getOrInitializeService({ instanceIdentifier, options = {} }) {
|
||||||
|
let instance = this.instances.get(instanceIdentifier);
|
||||||
|
if (!instance && this.component) {
|
||||||
|
instance = this.component.instanceFactory(this.container, {
|
||||||
|
instanceIdentifier: normalizeIdentifierForFactory(instanceIdentifier),
|
||||||
|
options
|
||||||
|
});
|
||||||
|
this.instances.set(instanceIdentifier, instance);
|
||||||
|
this.instancesOptions.set(instanceIdentifier, options);
|
||||||
|
/**
|
||||||
|
* Invoke onInit listeners.
|
||||||
|
* Note this.component.onInstanceCreated is different, which is used by the component creator,
|
||||||
|
* while onInit listeners are registered by consumers of the provider.
|
||||||
|
*/
|
||||||
|
this.invokeOnInitCallbacks(instance, instanceIdentifier);
|
||||||
|
/**
|
||||||
|
* Order is important
|
||||||
|
* onInstanceCreated() should be called after this.instances.set(instanceIdentifier, instance); which
|
||||||
|
* makes `isInitialized()` return true.
|
||||||
|
*/
|
||||||
|
if (this.component.onInstanceCreated) {
|
||||||
|
try {
|
||||||
|
this.component.onInstanceCreated(this.container, instanceIdentifier, instance);
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
// ignore errors in the onInstanceCreatedCallback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance || null;
|
||||||
|
}
|
||||||
|
normalizeInstanceIdentifier(identifier = DEFAULT_ENTRY_NAME) {
|
||||||
|
if (this.component) {
|
||||||
|
return this.component.multipleInstances ? identifier : DEFAULT_ENTRY_NAME;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return identifier; // assume multiple instances are supported before the component is provided.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shouldAutoInitialize() {
|
||||||
|
return (!!this.component &&
|
||||||
|
this.component.instantiationMode !== "EXPLICIT" /* InstantiationMode.EXPLICIT */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// undefined should be passed to the service factory for the default instance
|
||||||
|
function normalizeIdentifierForFactory(identifier) {
|
||||||
|
return identifier === DEFAULT_ENTRY_NAME ? undefined : identifier;
|
||||||
|
}
|
||||||
|
function isComponentEager(component) {
|
||||||
|
return component.instantiationMode === "EAGER" /* InstantiationMode.EAGER */;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
|
||||||
|
*/
|
||||||
|
class ComponentContainer {
|
||||||
|
constructor(name) {
|
||||||
|
this.name = name;
|
||||||
|
this.providers = new Map();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param component Component being added
|
||||||
|
* @param overwrite When a component with the same name has already been registered,
|
||||||
|
* if overwrite is true: overwrite the existing component with the new component and create a new
|
||||||
|
* provider with the new component. It can be useful in tests where you want to use different mocks
|
||||||
|
* for different tests.
|
||||||
|
* if overwrite is false: throw an exception
|
||||||
|
*/
|
||||||
|
addComponent(component) {
|
||||||
|
const provider = this.getProvider(component.name);
|
||||||
|
if (provider.isComponentSet()) {
|
||||||
|
throw new Error(`Component ${component.name} has already been registered with ${this.name}`);
|
||||||
|
}
|
||||||
|
provider.setComponent(component);
|
||||||
|
}
|
||||||
|
addOrOverwriteComponent(component) {
|
||||||
|
const provider = this.getProvider(component.name);
|
||||||
|
if (provider.isComponentSet()) {
|
||||||
|
// delete the existing provider from the container, so we can register the new component
|
||||||
|
this.providers.delete(component.name);
|
||||||
|
}
|
||||||
|
this.addComponent(component);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* getProvider provides a type safe interface where it can only be called with a field name
|
||||||
|
* present in NameServiceMapping interface.
|
||||||
|
*
|
||||||
|
* Firebase SDKs providing services should extend NameServiceMapping interface to register
|
||||||
|
* themselves.
|
||||||
|
*/
|
||||||
|
getProvider(name) {
|
||||||
|
if (this.providers.has(name)) {
|
||||||
|
return this.providers.get(name);
|
||||||
|
}
|
||||||
|
// create a Provider for a service that hasn't registered with Firebase
|
||||||
|
const provider = new Provider(name, this);
|
||||||
|
this.providers.set(name, provider);
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
getProviders() {
|
||||||
|
return Array.from(this.providers.values());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Component, ComponentContainer, Provider };
|
||||||
|
//# sourceMappingURL=index.esm2017.js.map
|
||||||
1
functions/node_modules/@firebase/component/dist/esm/index.esm2017.js.map
generated
vendored
Normal file
1
functions/node_modules/@firebase/component/dist/esm/index.esm2017.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
460
functions/node_modules/@firebase/component/dist/esm/index.esm5.js
generated
vendored
Normal file
460
functions/node_modules/@firebase/component/dist/esm/index.esm5.js
generated
vendored
Normal file
@@ -0,0 +1,460 @@
|
|||||||
|
import { __values, __read, __awaiter, __generator, __spreadArray } from 'tslib';
|
||||||
|
import { Deferred } from '@firebase/util';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component for service name T, e.g. `auth`, `auth-internal`
|
||||||
|
*/
|
||||||
|
var Component = /** @class */ (function () {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param name The public service name, e.g. app, auth, firestore, database
|
||||||
|
* @param instanceFactory Service factory responsible for creating the public interface
|
||||||
|
* @param type whether the service provided by the component is public or private
|
||||||
|
*/
|
||||||
|
function Component(name, instanceFactory, type) {
|
||||||
|
this.name = name;
|
||||||
|
this.instanceFactory = instanceFactory;
|
||||||
|
this.type = type;
|
||||||
|
this.multipleInstances = false;
|
||||||
|
/**
|
||||||
|
* Properties to be added to the service namespace
|
||||||
|
*/
|
||||||
|
this.serviceProps = {};
|
||||||
|
this.instantiationMode = "LAZY" /* InstantiationMode.LAZY */;
|
||||||
|
this.onInstanceCreated = null;
|
||||||
|
}
|
||||||
|
Component.prototype.setInstantiationMode = function (mode) {
|
||||||
|
this.instantiationMode = mode;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
Component.prototype.setMultipleInstances = function (multipleInstances) {
|
||||||
|
this.multipleInstances = multipleInstances;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
Component.prototype.setServiceProps = function (props) {
|
||||||
|
this.serviceProps = props;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
Component.prototype.setInstanceCreatedCallback = function (callback) {
|
||||||
|
this.onInstanceCreated = callback;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
return Component;
|
||||||
|
}());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
var DEFAULT_ENTRY_NAME = '[DEFAULT]';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
|
||||||
|
* NameServiceMapping[T] is an alias for the type of the instance
|
||||||
|
*/
|
||||||
|
var Provider = /** @class */ (function () {
|
||||||
|
function Provider(name, container) {
|
||||||
|
this.name = name;
|
||||||
|
this.container = container;
|
||||||
|
this.component = null;
|
||||||
|
this.instances = new Map();
|
||||||
|
this.instancesDeferred = new Map();
|
||||||
|
this.instancesOptions = new Map();
|
||||||
|
this.onInitCallbacks = new Map();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param identifier A provider can provide multiple instances of a service
|
||||||
|
* if this.component.multipleInstances is true.
|
||||||
|
*/
|
||||||
|
Provider.prototype.get = function (identifier) {
|
||||||
|
// if multipleInstances is not supported, use the default name
|
||||||
|
var normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
|
||||||
|
if (!this.instancesDeferred.has(normalizedIdentifier)) {
|
||||||
|
var deferred = new Deferred();
|
||||||
|
this.instancesDeferred.set(normalizedIdentifier, deferred);
|
||||||
|
if (this.isInitialized(normalizedIdentifier) ||
|
||||||
|
this.shouldAutoInitialize()) {
|
||||||
|
// initialize the service if it can be auto-initialized
|
||||||
|
try {
|
||||||
|
var instance = this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier
|
||||||
|
});
|
||||||
|
if (instance) {
|
||||||
|
deferred.resolve(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// when the instance factory throws an exception during get(), it should not cause
|
||||||
|
// a fatal error. We just return the unresolved promise in this case.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.instancesDeferred.get(normalizedIdentifier).promise;
|
||||||
|
};
|
||||||
|
Provider.prototype.getImmediate = function (options) {
|
||||||
|
var _a;
|
||||||
|
// if multipleInstances is not supported, use the default name
|
||||||
|
var normalizedIdentifier = this.normalizeInstanceIdentifier(options === null || options === void 0 ? void 0 : options.identifier);
|
||||||
|
var optional = (_a = options === null || options === void 0 ? void 0 : options.optional) !== null && _a !== void 0 ? _a : false;
|
||||||
|
if (this.isInitialized(normalizedIdentifier) ||
|
||||||
|
this.shouldAutoInitialize()) {
|
||||||
|
try {
|
||||||
|
return this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (optional) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// In case a component is not initialized and should/cannot be auto-initialized at the moment, return null if the optional flag is set, or throw
|
||||||
|
if (optional) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw Error("Service ".concat(this.name, " is not available"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Provider.prototype.getComponent = function () {
|
||||||
|
return this.component;
|
||||||
|
};
|
||||||
|
Provider.prototype.setComponent = function (component) {
|
||||||
|
var e_1, _a;
|
||||||
|
if (component.name !== this.name) {
|
||||||
|
throw Error("Mismatching Component ".concat(component.name, " for Provider ").concat(this.name, "."));
|
||||||
|
}
|
||||||
|
if (this.component) {
|
||||||
|
throw Error("Component for ".concat(this.name, " has already been provided"));
|
||||||
|
}
|
||||||
|
this.component = component;
|
||||||
|
// return early without attempting to initialize the component if the component requires explicit initialization (calling `Provider.initialize()`)
|
||||||
|
if (!this.shouldAutoInitialize()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// if the service is eager, initialize the default instance
|
||||||
|
if (isComponentEager(component)) {
|
||||||
|
try {
|
||||||
|
this.getOrInitializeService({ instanceIdentifier: DEFAULT_ENTRY_NAME });
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// when the instance factory for an eager Component throws an exception during the eager
|
||||||
|
// initialization, it should not cause a fatal error.
|
||||||
|
// TODO: Investigate if we need to make it configurable, because some component may want to cause
|
||||||
|
// a fatal error in this case?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// Create service instances for the pending promises and resolve them
|
||||||
|
// NOTE: if this.multipleInstances is false, only the default instance will be created
|
||||||
|
// and all promises with resolve with it regardless of the identifier.
|
||||||
|
for (var _b = __values(this.instancesDeferred.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||||
|
var _d = __read(_c.value, 2), instanceIdentifier = _d[0], instanceDeferred = _d[1];
|
||||||
|
var normalizedIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
|
||||||
|
try {
|
||||||
|
// `getOrInitializeService()` should always return a valid instance since a component is guaranteed. use ! to make typescript happy.
|
||||||
|
var instance = this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier
|
||||||
|
});
|
||||||
|
instanceDeferred.resolve(instance);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// when the instance factory throws an exception, it should not cause
|
||||||
|
// a fatal error. We just leave the promise unresolved.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||||
|
}
|
||||||
|
finally { if (e_1) throw e_1.error; }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Provider.prototype.clearInstance = function (identifier) {
|
||||||
|
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
|
||||||
|
this.instancesDeferred.delete(identifier);
|
||||||
|
this.instancesOptions.delete(identifier);
|
||||||
|
this.instances.delete(identifier);
|
||||||
|
};
|
||||||
|
// app.delete() will call this method on every provider to delete the services
|
||||||
|
// TODO: should we mark the provider as deleted?
|
||||||
|
Provider.prototype.delete = function () {
|
||||||
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
|
var services;
|
||||||
|
return __generator(this, function (_a) {
|
||||||
|
switch (_a.label) {
|
||||||
|
case 0:
|
||||||
|
services = Array.from(this.instances.values());
|
||||||
|
return [4 /*yield*/, Promise.all(__spreadArray(__spreadArray([], __read(services
|
||||||
|
.filter(function (service) { return 'INTERNAL' in service; }) // legacy services
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
.map(function (service) { return service.INTERNAL.delete(); })), false), __read(services
|
||||||
|
.filter(function (service) { return '_delete' in service; }) // modularized services
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
.map(function (service) { return service._delete(); })), false))];
|
||||||
|
case 1:
|
||||||
|
_a.sent();
|
||||||
|
return [2 /*return*/];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Provider.prototype.isComponentSet = function () {
|
||||||
|
return this.component != null;
|
||||||
|
};
|
||||||
|
Provider.prototype.isInitialized = function (identifier) {
|
||||||
|
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
|
||||||
|
return this.instances.has(identifier);
|
||||||
|
};
|
||||||
|
Provider.prototype.getOptions = function (identifier) {
|
||||||
|
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
|
||||||
|
return this.instancesOptions.get(identifier) || {};
|
||||||
|
};
|
||||||
|
Provider.prototype.initialize = function (opts) {
|
||||||
|
var e_2, _a;
|
||||||
|
if (opts === void 0) { opts = {}; }
|
||||||
|
var _b = opts.options, options = _b === void 0 ? {} : _b;
|
||||||
|
var normalizedIdentifier = this.normalizeInstanceIdentifier(opts.instanceIdentifier);
|
||||||
|
if (this.isInitialized(normalizedIdentifier)) {
|
||||||
|
throw Error("".concat(this.name, "(").concat(normalizedIdentifier, ") has already been initialized"));
|
||||||
|
}
|
||||||
|
if (!this.isComponentSet()) {
|
||||||
|
throw Error("Component ".concat(this.name, " has not been registered yet"));
|
||||||
|
}
|
||||||
|
var instance = this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier,
|
||||||
|
options: options
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
// resolve any pending promise waiting for the service instance
|
||||||
|
for (var _c = __values(this.instancesDeferred.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
||||||
|
var _e = __read(_d.value, 2), instanceIdentifier = _e[0], instanceDeferred = _e[1];
|
||||||
|
var normalizedDeferredIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
|
||||||
|
if (normalizedIdentifier === normalizedDeferredIdentifier) {
|
||||||
|
instanceDeferred.resolve(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
||||||
|
}
|
||||||
|
finally { if (e_2) throw e_2.error; }
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
|
||||||
|
* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
|
||||||
|
*
|
||||||
|
* @param identifier An optional instance identifier
|
||||||
|
* @returns a function to unregister the callback
|
||||||
|
*/
|
||||||
|
Provider.prototype.onInit = function (callback, identifier) {
|
||||||
|
var _a;
|
||||||
|
var normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
|
||||||
|
var existingCallbacks = (_a = this.onInitCallbacks.get(normalizedIdentifier)) !== null && _a !== void 0 ? _a : new Set();
|
||||||
|
existingCallbacks.add(callback);
|
||||||
|
this.onInitCallbacks.set(normalizedIdentifier, existingCallbacks);
|
||||||
|
var existingInstance = this.instances.get(normalizedIdentifier);
|
||||||
|
if (existingInstance) {
|
||||||
|
callback(existingInstance, normalizedIdentifier);
|
||||||
|
}
|
||||||
|
return function () {
|
||||||
|
existingCallbacks.delete(callback);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Invoke onInit callbacks synchronously
|
||||||
|
* @param instance the service instance`
|
||||||
|
*/
|
||||||
|
Provider.prototype.invokeOnInitCallbacks = function (instance, identifier) {
|
||||||
|
var e_3, _a;
|
||||||
|
var callbacks = this.onInitCallbacks.get(identifier);
|
||||||
|
if (!callbacks) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
for (var callbacks_1 = __values(callbacks), callbacks_1_1 = callbacks_1.next(); !callbacks_1_1.done; callbacks_1_1 = callbacks_1.next()) {
|
||||||
|
var callback = callbacks_1_1.value;
|
||||||
|
try {
|
||||||
|
callback(instance, identifier);
|
||||||
|
}
|
||||||
|
catch (_b) {
|
||||||
|
// ignore errors in the onInit callback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (callbacks_1_1 && !callbacks_1_1.done && (_a = callbacks_1.return)) _a.call(callbacks_1);
|
||||||
|
}
|
||||||
|
finally { if (e_3) throw e_3.error; }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Provider.prototype.getOrInitializeService = function (_a) {
|
||||||
|
var instanceIdentifier = _a.instanceIdentifier, _b = _a.options, options = _b === void 0 ? {} : _b;
|
||||||
|
var instance = this.instances.get(instanceIdentifier);
|
||||||
|
if (!instance && this.component) {
|
||||||
|
instance = this.component.instanceFactory(this.container, {
|
||||||
|
instanceIdentifier: normalizeIdentifierForFactory(instanceIdentifier),
|
||||||
|
options: options
|
||||||
|
});
|
||||||
|
this.instances.set(instanceIdentifier, instance);
|
||||||
|
this.instancesOptions.set(instanceIdentifier, options);
|
||||||
|
/**
|
||||||
|
* Invoke onInit listeners.
|
||||||
|
* Note this.component.onInstanceCreated is different, which is used by the component creator,
|
||||||
|
* while onInit listeners are registered by consumers of the provider.
|
||||||
|
*/
|
||||||
|
this.invokeOnInitCallbacks(instance, instanceIdentifier);
|
||||||
|
/**
|
||||||
|
* Order is important
|
||||||
|
* onInstanceCreated() should be called after this.instances.set(instanceIdentifier, instance); which
|
||||||
|
* makes `isInitialized()` return true.
|
||||||
|
*/
|
||||||
|
if (this.component.onInstanceCreated) {
|
||||||
|
try {
|
||||||
|
this.component.onInstanceCreated(this.container, instanceIdentifier, instance);
|
||||||
|
}
|
||||||
|
catch (_c) {
|
||||||
|
// ignore errors in the onInstanceCreatedCallback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance || null;
|
||||||
|
};
|
||||||
|
Provider.prototype.normalizeInstanceIdentifier = function (identifier) {
|
||||||
|
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
|
||||||
|
if (this.component) {
|
||||||
|
return this.component.multipleInstances ? identifier : DEFAULT_ENTRY_NAME;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return identifier; // assume multiple instances are supported before the component is provided.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Provider.prototype.shouldAutoInitialize = function () {
|
||||||
|
return (!!this.component &&
|
||||||
|
this.component.instantiationMode !== "EXPLICIT" /* InstantiationMode.EXPLICIT */);
|
||||||
|
};
|
||||||
|
return Provider;
|
||||||
|
}());
|
||||||
|
// undefined should be passed to the service factory for the default instance
|
||||||
|
function normalizeIdentifierForFactory(identifier) {
|
||||||
|
return identifier === DEFAULT_ENTRY_NAME ? undefined : identifier;
|
||||||
|
}
|
||||||
|
function isComponentEager(component) {
|
||||||
|
return component.instantiationMode === "EAGER" /* InstantiationMode.EAGER */;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
|
||||||
|
*/
|
||||||
|
var ComponentContainer = /** @class */ (function () {
|
||||||
|
function ComponentContainer(name) {
|
||||||
|
this.name = name;
|
||||||
|
this.providers = new Map();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param component Component being added
|
||||||
|
* @param overwrite When a component with the same name has already been registered,
|
||||||
|
* if overwrite is true: overwrite the existing component with the new component and create a new
|
||||||
|
* provider with the new component. It can be useful in tests where you want to use different mocks
|
||||||
|
* for different tests.
|
||||||
|
* if overwrite is false: throw an exception
|
||||||
|
*/
|
||||||
|
ComponentContainer.prototype.addComponent = function (component) {
|
||||||
|
var provider = this.getProvider(component.name);
|
||||||
|
if (provider.isComponentSet()) {
|
||||||
|
throw new Error("Component ".concat(component.name, " has already been registered with ").concat(this.name));
|
||||||
|
}
|
||||||
|
provider.setComponent(component);
|
||||||
|
};
|
||||||
|
ComponentContainer.prototype.addOrOverwriteComponent = function (component) {
|
||||||
|
var provider = this.getProvider(component.name);
|
||||||
|
if (provider.isComponentSet()) {
|
||||||
|
// delete the existing provider from the container, so we can register the new component
|
||||||
|
this.providers.delete(component.name);
|
||||||
|
}
|
||||||
|
this.addComponent(component);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* getProvider provides a type safe interface where it can only be called with a field name
|
||||||
|
* present in NameServiceMapping interface.
|
||||||
|
*
|
||||||
|
* Firebase SDKs providing services should extend NameServiceMapping interface to register
|
||||||
|
* themselves.
|
||||||
|
*/
|
||||||
|
ComponentContainer.prototype.getProvider = function (name) {
|
||||||
|
if (this.providers.has(name)) {
|
||||||
|
return this.providers.get(name);
|
||||||
|
}
|
||||||
|
// create a Provider for a service that hasn't registered with Firebase
|
||||||
|
var provider = new Provider(name, this);
|
||||||
|
this.providers.set(name, provider);
|
||||||
|
return provider;
|
||||||
|
};
|
||||||
|
ComponentContainer.prototype.getProviders = function () {
|
||||||
|
return Array.from(this.providers.values());
|
||||||
|
};
|
||||||
|
return ComponentContainer;
|
||||||
|
}());
|
||||||
|
|
||||||
|
export { Component, ComponentContainer, Provider };
|
||||||
|
//# sourceMappingURL=index.esm5.js.map
|
||||||
1
functions/node_modules/@firebase/component/dist/esm/index.esm5.js.map
generated
vendored
Normal file
1
functions/node_modules/@firebase/component/dist/esm/index.esm5.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
functions/node_modules/@firebase/component/dist/esm/package.json
generated
vendored
Normal file
1
functions/node_modules/@firebase/component/dist/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"type":"module"}
|
||||||
43
functions/node_modules/@firebase/component/dist/esm/src/component.d.ts
generated
vendored
Normal file
43
functions/node_modules/@firebase/component/dist/esm/src/component.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { InstantiationMode, InstanceFactory, ComponentType, Dictionary, Name, onInstanceCreatedCallback } from './types';
|
||||||
|
/**
|
||||||
|
* Component for service name T, e.g. `auth`, `auth-internal`
|
||||||
|
*/
|
||||||
|
export declare class Component<T extends Name = Name> {
|
||||||
|
readonly name: T;
|
||||||
|
readonly instanceFactory: InstanceFactory<T>;
|
||||||
|
readonly type: ComponentType;
|
||||||
|
multipleInstances: boolean;
|
||||||
|
/**
|
||||||
|
* Properties to be added to the service namespace
|
||||||
|
*/
|
||||||
|
serviceProps: Dictionary;
|
||||||
|
instantiationMode: InstantiationMode;
|
||||||
|
onInstanceCreated: onInstanceCreatedCallback<T> | null;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param name The public service name, e.g. app, auth, firestore, database
|
||||||
|
* @param instanceFactory Service factory responsible for creating the public interface
|
||||||
|
* @param type whether the service provided by the component is public or private
|
||||||
|
*/
|
||||||
|
constructor(name: T, instanceFactory: InstanceFactory<T>, type: ComponentType);
|
||||||
|
setInstantiationMode(mode: InstantiationMode): this;
|
||||||
|
setMultipleInstances(multipleInstances: boolean): this;
|
||||||
|
setServiceProps(props: Dictionary): this;
|
||||||
|
setInstanceCreatedCallback(callback: onInstanceCreatedCallback<T>): this;
|
||||||
|
}
|
||||||
47
functions/node_modules/@firebase/component/dist/esm/src/component_container.d.ts
generated
vendored
Normal file
47
functions/node_modules/@firebase/component/dist/esm/src/component_container.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { Provider } from './provider';
|
||||||
|
import { Component } from './component';
|
||||||
|
import { Name } from './types';
|
||||||
|
/**
|
||||||
|
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
|
||||||
|
*/
|
||||||
|
export declare class ComponentContainer {
|
||||||
|
private readonly name;
|
||||||
|
private readonly providers;
|
||||||
|
constructor(name: string);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param component Component being added
|
||||||
|
* @param overwrite When a component with the same name has already been registered,
|
||||||
|
* if overwrite is true: overwrite the existing component with the new component and create a new
|
||||||
|
* provider with the new component. It can be useful in tests where you want to use different mocks
|
||||||
|
* for different tests.
|
||||||
|
* if overwrite is false: throw an exception
|
||||||
|
*/
|
||||||
|
addComponent<T extends Name>(component: Component<T>): void;
|
||||||
|
addOrOverwriteComponent<T extends Name>(component: Component<T>): void;
|
||||||
|
/**
|
||||||
|
* getProvider provides a type safe interface where it can only be called with a field name
|
||||||
|
* present in NameServiceMapping interface.
|
||||||
|
*
|
||||||
|
* Firebase SDKs providing services should extend NameServiceMapping interface to register
|
||||||
|
* themselves.
|
||||||
|
*/
|
||||||
|
getProvider<T extends Name>(name: T): Provider<T>;
|
||||||
|
getProviders(): Array<Provider<Name>>;
|
||||||
|
}
|
||||||
24
functions/node_modules/@firebase/component/dist/esm/src/component_container.test.d.ts
generated
vendored
Normal file
24
functions/node_modules/@firebase/component/dist/esm/src/component_container.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import '../test/setup';
|
||||||
|
declare module './types' {
|
||||||
|
interface NameServiceMapping {
|
||||||
|
rocket: {};
|
||||||
|
ship: {};
|
||||||
|
fireball: {};
|
||||||
|
}
|
||||||
|
}
|
||||||
17
functions/node_modules/@firebase/component/dist/esm/src/constants.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/component/dist/esm/src/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export declare const DEFAULT_ENTRY_NAME = "[DEFAULT]";
|
||||||
79
functions/node_modules/@firebase/component/dist/esm/src/provider.d.ts
generated
vendored
Normal file
79
functions/node_modules/@firebase/component/dist/esm/src/provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { ComponentContainer } from './component_container';
|
||||||
|
import { InitializeOptions, Name, NameServiceMapping, OnInitCallBack } from './types';
|
||||||
|
import { Component } from './component';
|
||||||
|
/**
|
||||||
|
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
|
||||||
|
* NameServiceMapping[T] is an alias for the type of the instance
|
||||||
|
*/
|
||||||
|
export declare class Provider<T extends Name> {
|
||||||
|
private readonly name;
|
||||||
|
private readonly container;
|
||||||
|
private component;
|
||||||
|
private readonly instances;
|
||||||
|
private readonly instancesDeferred;
|
||||||
|
private readonly instancesOptions;
|
||||||
|
private onInitCallbacks;
|
||||||
|
constructor(name: T, container: ComponentContainer);
|
||||||
|
/**
|
||||||
|
* @param identifier A provider can provide multiple instances of a service
|
||||||
|
* if this.component.multipleInstances is true.
|
||||||
|
*/
|
||||||
|
get(identifier?: string): Promise<NameServiceMapping[T]>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param options.identifier A provider can provide multiple instances of a service
|
||||||
|
* if this.component.multipleInstances is true.
|
||||||
|
* @param options.optional If optional is false or not provided, the method throws an error when
|
||||||
|
* the service is not immediately available.
|
||||||
|
* If optional is true, the method returns null if the service is not immediately available.
|
||||||
|
*/
|
||||||
|
getImmediate(options: {
|
||||||
|
identifier?: string;
|
||||||
|
optional: true;
|
||||||
|
}): NameServiceMapping[T] | null;
|
||||||
|
getImmediate(options?: {
|
||||||
|
identifier?: string;
|
||||||
|
optional?: false;
|
||||||
|
}): NameServiceMapping[T];
|
||||||
|
getComponent(): Component<T> | null;
|
||||||
|
setComponent(component: Component<T>): void;
|
||||||
|
clearInstance(identifier?: string): void;
|
||||||
|
delete(): Promise<void>;
|
||||||
|
isComponentSet(): boolean;
|
||||||
|
isInitialized(identifier?: string): boolean;
|
||||||
|
getOptions(identifier?: string): Record<string, unknown>;
|
||||||
|
initialize(opts?: InitializeOptions): NameServiceMapping[T];
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
|
||||||
|
* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
|
||||||
|
*
|
||||||
|
* @param identifier An optional instance identifier
|
||||||
|
* @returns a function to unregister the callback
|
||||||
|
*/
|
||||||
|
onInit(callback: OnInitCallBack<T>, identifier?: string): () => void;
|
||||||
|
/**
|
||||||
|
* Invoke onInit callbacks synchronously
|
||||||
|
* @param instance the service instance`
|
||||||
|
*/
|
||||||
|
private invokeOnInitCallbacks;
|
||||||
|
private getOrInitializeService;
|
||||||
|
private normalizeInstanceIdentifier;
|
||||||
|
private shouldAutoInitialize;
|
||||||
|
}
|
||||||
23
functions/node_modules/@firebase/component/dist/esm/src/provider.test.d.ts
generated
vendored
Normal file
23
functions/node_modules/@firebase/component/dist/esm/src/provider.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import '../test/setup';
|
||||||
|
declare module './types' {
|
||||||
|
interface NameServiceMapping {
|
||||||
|
test: {};
|
||||||
|
badtest: {};
|
||||||
|
}
|
||||||
|
}
|
||||||
62
functions/node_modules/@firebase/component/dist/esm/src/types.d.ts
generated
vendored
Normal file
62
functions/node_modules/@firebase/component/dist/esm/src/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { ComponentContainer } from './component_container';
|
||||||
|
export declare const enum InstantiationMode {
|
||||||
|
LAZY = "LAZY",
|
||||||
|
EAGER = "EAGER",
|
||||||
|
EXPLICIT = "EXPLICIT"
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* PUBLIC: A public component provides a set of public APIs to customers. A service namespace will be patched
|
||||||
|
* onto `firebase` namespace. Assume the component name is `test`, customers will be able
|
||||||
|
* to get the service by calling `firebase.test()` or `app.test()` where `app` is a `FirebaseApp` instance.
|
||||||
|
*
|
||||||
|
* PRIVATE: A private component provides a set of private APIs that are used internally by other
|
||||||
|
* Firebase SDKs. No service namespace is created in `firebase` namespace and customers have no way to get them.
|
||||||
|
*/
|
||||||
|
export declare const enum ComponentType {
|
||||||
|
PUBLIC = "PUBLIC",
|
||||||
|
PRIVATE = "PRIVATE",
|
||||||
|
VERSION = "VERSION"
|
||||||
|
}
|
||||||
|
export interface InstanceFactoryOptions {
|
||||||
|
instanceIdentifier?: string;
|
||||||
|
options?: {};
|
||||||
|
}
|
||||||
|
export declare type InitializeOptions = InstanceFactoryOptions;
|
||||||
|
/**
|
||||||
|
* Factory to create an instance of type T, given a ComponentContainer.
|
||||||
|
* ComponentContainer is the IOC container that provides {@link Provider}
|
||||||
|
* for dependencies.
|
||||||
|
*
|
||||||
|
* NOTE: The container only provides {@link Provider} rather than the actual instances of dependencies.
|
||||||
|
* It is useful for lazily loaded dependencies and optional dependencies.
|
||||||
|
*/
|
||||||
|
export declare type InstanceFactory<T extends Name> = (container: ComponentContainer, options: InstanceFactoryOptions) => NameServiceMapping[T];
|
||||||
|
export declare type onInstanceCreatedCallback<T extends Name> = (container: ComponentContainer, instanceIdentifier: string, instance: NameServiceMapping[T]) => void;
|
||||||
|
export interface Dictionary {
|
||||||
|
[key: string]: unknown;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This interface will be extended by Firebase SDKs to provide service name and service type mapping.
|
||||||
|
* It is used as a generic constraint to ensure type safety.
|
||||||
|
*/
|
||||||
|
export interface NameServiceMapping {
|
||||||
|
}
|
||||||
|
export declare type Name = keyof NameServiceMapping;
|
||||||
|
export declare type Service = NameServiceMapping[Name];
|
||||||
|
export declare type OnInitCallBack<T extends Name> = (instance: NameServiceMapping[T], identifier: string) => void;
|
||||||
17
functions/node_modules/@firebase/component/dist/esm/test/setup.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/component/dist/esm/test/setup.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export {};
|
||||||
5
functions/node_modules/@firebase/component/dist/esm/test/util.d.ts
generated
vendored
Normal file
5
functions/node_modules/@firebase/component/dist/esm/test/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { FirebaseApp } from '@firebase/app-types';
|
||||||
|
import { InstanceFactory, InstantiationMode, Name } from '../src/types';
|
||||||
|
import { Component } from '../src/component';
|
||||||
|
export declare function getFakeApp(appName?: string): FirebaseApp;
|
||||||
|
export declare function getFakeComponent<T extends Name>(name: T, factory: InstanceFactory<T>, multipleInstance?: boolean, instantiationMode?: InstantiationMode): Component<T>;
|
||||||
466
functions/node_modules/@firebase/component/dist/index.cjs.js
generated
vendored
Normal file
466
functions/node_modules/@firebase/component/dist/index.cjs.js
generated
vendored
Normal file
@@ -0,0 +1,466 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
var tslib = require('tslib');
|
||||||
|
var util = require('@firebase/util');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component for service name T, e.g. `auth`, `auth-internal`
|
||||||
|
*/
|
||||||
|
var Component = /** @class */ (function () {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param name The public service name, e.g. app, auth, firestore, database
|
||||||
|
* @param instanceFactory Service factory responsible for creating the public interface
|
||||||
|
* @param type whether the service provided by the component is public or private
|
||||||
|
*/
|
||||||
|
function Component(name, instanceFactory, type) {
|
||||||
|
this.name = name;
|
||||||
|
this.instanceFactory = instanceFactory;
|
||||||
|
this.type = type;
|
||||||
|
this.multipleInstances = false;
|
||||||
|
/**
|
||||||
|
* Properties to be added to the service namespace
|
||||||
|
*/
|
||||||
|
this.serviceProps = {};
|
||||||
|
this.instantiationMode = "LAZY" /* InstantiationMode.LAZY */;
|
||||||
|
this.onInstanceCreated = null;
|
||||||
|
}
|
||||||
|
Component.prototype.setInstantiationMode = function (mode) {
|
||||||
|
this.instantiationMode = mode;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
Component.prototype.setMultipleInstances = function (multipleInstances) {
|
||||||
|
this.multipleInstances = multipleInstances;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
Component.prototype.setServiceProps = function (props) {
|
||||||
|
this.serviceProps = props;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
Component.prototype.setInstanceCreatedCallback = function (callback) {
|
||||||
|
this.onInstanceCreated = callback;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
return Component;
|
||||||
|
}());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
var DEFAULT_ENTRY_NAME = '[DEFAULT]';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
|
||||||
|
* NameServiceMapping[T] is an alias for the type of the instance
|
||||||
|
*/
|
||||||
|
var Provider = /** @class */ (function () {
|
||||||
|
function Provider(name, container) {
|
||||||
|
this.name = name;
|
||||||
|
this.container = container;
|
||||||
|
this.component = null;
|
||||||
|
this.instances = new Map();
|
||||||
|
this.instancesDeferred = new Map();
|
||||||
|
this.instancesOptions = new Map();
|
||||||
|
this.onInitCallbacks = new Map();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param identifier A provider can provide multiple instances of a service
|
||||||
|
* if this.component.multipleInstances is true.
|
||||||
|
*/
|
||||||
|
Provider.prototype.get = function (identifier) {
|
||||||
|
// if multipleInstances is not supported, use the default name
|
||||||
|
var normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
|
||||||
|
if (!this.instancesDeferred.has(normalizedIdentifier)) {
|
||||||
|
var deferred = new util.Deferred();
|
||||||
|
this.instancesDeferred.set(normalizedIdentifier, deferred);
|
||||||
|
if (this.isInitialized(normalizedIdentifier) ||
|
||||||
|
this.shouldAutoInitialize()) {
|
||||||
|
// initialize the service if it can be auto-initialized
|
||||||
|
try {
|
||||||
|
var instance = this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier
|
||||||
|
});
|
||||||
|
if (instance) {
|
||||||
|
deferred.resolve(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// when the instance factory throws an exception during get(), it should not cause
|
||||||
|
// a fatal error. We just return the unresolved promise in this case.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.instancesDeferred.get(normalizedIdentifier).promise;
|
||||||
|
};
|
||||||
|
Provider.prototype.getImmediate = function (options) {
|
||||||
|
var _a;
|
||||||
|
// if multipleInstances is not supported, use the default name
|
||||||
|
var normalizedIdentifier = this.normalizeInstanceIdentifier(options === null || options === void 0 ? void 0 : options.identifier);
|
||||||
|
var optional = (_a = options === null || options === void 0 ? void 0 : options.optional) !== null && _a !== void 0 ? _a : false;
|
||||||
|
if (this.isInitialized(normalizedIdentifier) ||
|
||||||
|
this.shouldAutoInitialize()) {
|
||||||
|
try {
|
||||||
|
return this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (optional) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// In case a component is not initialized and should/cannot be auto-initialized at the moment, return null if the optional flag is set, or throw
|
||||||
|
if (optional) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw Error("Service ".concat(this.name, " is not available"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Provider.prototype.getComponent = function () {
|
||||||
|
return this.component;
|
||||||
|
};
|
||||||
|
Provider.prototype.setComponent = function (component) {
|
||||||
|
var e_1, _a;
|
||||||
|
if (component.name !== this.name) {
|
||||||
|
throw Error("Mismatching Component ".concat(component.name, " for Provider ").concat(this.name, "."));
|
||||||
|
}
|
||||||
|
if (this.component) {
|
||||||
|
throw Error("Component for ".concat(this.name, " has already been provided"));
|
||||||
|
}
|
||||||
|
this.component = component;
|
||||||
|
// return early without attempting to initialize the component if the component requires explicit initialization (calling `Provider.initialize()`)
|
||||||
|
if (!this.shouldAutoInitialize()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// if the service is eager, initialize the default instance
|
||||||
|
if (isComponentEager(component)) {
|
||||||
|
try {
|
||||||
|
this.getOrInitializeService({ instanceIdentifier: DEFAULT_ENTRY_NAME });
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// when the instance factory for an eager Component throws an exception during the eager
|
||||||
|
// initialization, it should not cause a fatal error.
|
||||||
|
// TODO: Investigate if we need to make it configurable, because some component may want to cause
|
||||||
|
// a fatal error in this case?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// Create service instances for the pending promises and resolve them
|
||||||
|
// NOTE: if this.multipleInstances is false, only the default instance will be created
|
||||||
|
// and all promises with resolve with it regardless of the identifier.
|
||||||
|
for (var _b = tslib.__values(this.instancesDeferred.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||||
|
var _d = tslib.__read(_c.value, 2), instanceIdentifier = _d[0], instanceDeferred = _d[1];
|
||||||
|
var normalizedIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
|
||||||
|
try {
|
||||||
|
// `getOrInitializeService()` should always return a valid instance since a component is guaranteed. use ! to make typescript happy.
|
||||||
|
var instance = this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier
|
||||||
|
});
|
||||||
|
instanceDeferred.resolve(instance);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// when the instance factory throws an exception, it should not cause
|
||||||
|
// a fatal error. We just leave the promise unresolved.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||||
|
}
|
||||||
|
finally { if (e_1) throw e_1.error; }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Provider.prototype.clearInstance = function (identifier) {
|
||||||
|
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
|
||||||
|
this.instancesDeferred.delete(identifier);
|
||||||
|
this.instancesOptions.delete(identifier);
|
||||||
|
this.instances.delete(identifier);
|
||||||
|
};
|
||||||
|
// app.delete() will call this method on every provider to delete the services
|
||||||
|
// TODO: should we mark the provider as deleted?
|
||||||
|
Provider.prototype.delete = function () {
|
||||||
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
||||||
|
var services;
|
||||||
|
return tslib.__generator(this, function (_a) {
|
||||||
|
switch (_a.label) {
|
||||||
|
case 0:
|
||||||
|
services = Array.from(this.instances.values());
|
||||||
|
return [4 /*yield*/, Promise.all(tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(services
|
||||||
|
.filter(function (service) { return 'INTERNAL' in service; }) // legacy services
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
.map(function (service) { return service.INTERNAL.delete(); })), false), tslib.__read(services
|
||||||
|
.filter(function (service) { return '_delete' in service; }) // modularized services
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
.map(function (service) { return service._delete(); })), false))];
|
||||||
|
case 1:
|
||||||
|
_a.sent();
|
||||||
|
return [2 /*return*/];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Provider.prototype.isComponentSet = function () {
|
||||||
|
return this.component != null;
|
||||||
|
};
|
||||||
|
Provider.prototype.isInitialized = function (identifier) {
|
||||||
|
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
|
||||||
|
return this.instances.has(identifier);
|
||||||
|
};
|
||||||
|
Provider.prototype.getOptions = function (identifier) {
|
||||||
|
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
|
||||||
|
return this.instancesOptions.get(identifier) || {};
|
||||||
|
};
|
||||||
|
Provider.prototype.initialize = function (opts) {
|
||||||
|
var e_2, _a;
|
||||||
|
if (opts === void 0) { opts = {}; }
|
||||||
|
var _b = opts.options, options = _b === void 0 ? {} : _b;
|
||||||
|
var normalizedIdentifier = this.normalizeInstanceIdentifier(opts.instanceIdentifier);
|
||||||
|
if (this.isInitialized(normalizedIdentifier)) {
|
||||||
|
throw Error("".concat(this.name, "(").concat(normalizedIdentifier, ") has already been initialized"));
|
||||||
|
}
|
||||||
|
if (!this.isComponentSet()) {
|
||||||
|
throw Error("Component ".concat(this.name, " has not been registered yet"));
|
||||||
|
}
|
||||||
|
var instance = this.getOrInitializeService({
|
||||||
|
instanceIdentifier: normalizedIdentifier,
|
||||||
|
options: options
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
// resolve any pending promise waiting for the service instance
|
||||||
|
for (var _c = tslib.__values(this.instancesDeferred.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
||||||
|
var _e = tslib.__read(_d.value, 2), instanceIdentifier = _e[0], instanceDeferred = _e[1];
|
||||||
|
var normalizedDeferredIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
|
||||||
|
if (normalizedIdentifier === normalizedDeferredIdentifier) {
|
||||||
|
instanceDeferred.resolve(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
||||||
|
}
|
||||||
|
finally { if (e_2) throw e_2.error; }
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
|
||||||
|
* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
|
||||||
|
*
|
||||||
|
* @param identifier An optional instance identifier
|
||||||
|
* @returns a function to unregister the callback
|
||||||
|
*/
|
||||||
|
Provider.prototype.onInit = function (callback, identifier) {
|
||||||
|
var _a;
|
||||||
|
var normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
|
||||||
|
var existingCallbacks = (_a = this.onInitCallbacks.get(normalizedIdentifier)) !== null && _a !== void 0 ? _a : new Set();
|
||||||
|
existingCallbacks.add(callback);
|
||||||
|
this.onInitCallbacks.set(normalizedIdentifier, existingCallbacks);
|
||||||
|
var existingInstance = this.instances.get(normalizedIdentifier);
|
||||||
|
if (existingInstance) {
|
||||||
|
callback(existingInstance, normalizedIdentifier);
|
||||||
|
}
|
||||||
|
return function () {
|
||||||
|
existingCallbacks.delete(callback);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Invoke onInit callbacks synchronously
|
||||||
|
* @param instance the service instance`
|
||||||
|
*/
|
||||||
|
Provider.prototype.invokeOnInitCallbacks = function (instance, identifier) {
|
||||||
|
var e_3, _a;
|
||||||
|
var callbacks = this.onInitCallbacks.get(identifier);
|
||||||
|
if (!callbacks) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
for (var callbacks_1 = tslib.__values(callbacks), callbacks_1_1 = callbacks_1.next(); !callbacks_1_1.done; callbacks_1_1 = callbacks_1.next()) {
|
||||||
|
var callback = callbacks_1_1.value;
|
||||||
|
try {
|
||||||
|
callback(instance, identifier);
|
||||||
|
}
|
||||||
|
catch (_b) {
|
||||||
|
// ignore errors in the onInit callback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (callbacks_1_1 && !callbacks_1_1.done && (_a = callbacks_1.return)) _a.call(callbacks_1);
|
||||||
|
}
|
||||||
|
finally { if (e_3) throw e_3.error; }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Provider.prototype.getOrInitializeService = function (_a) {
|
||||||
|
var instanceIdentifier = _a.instanceIdentifier, _b = _a.options, options = _b === void 0 ? {} : _b;
|
||||||
|
var instance = this.instances.get(instanceIdentifier);
|
||||||
|
if (!instance && this.component) {
|
||||||
|
instance = this.component.instanceFactory(this.container, {
|
||||||
|
instanceIdentifier: normalizeIdentifierForFactory(instanceIdentifier),
|
||||||
|
options: options
|
||||||
|
});
|
||||||
|
this.instances.set(instanceIdentifier, instance);
|
||||||
|
this.instancesOptions.set(instanceIdentifier, options);
|
||||||
|
/**
|
||||||
|
* Invoke onInit listeners.
|
||||||
|
* Note this.component.onInstanceCreated is different, which is used by the component creator,
|
||||||
|
* while onInit listeners are registered by consumers of the provider.
|
||||||
|
*/
|
||||||
|
this.invokeOnInitCallbacks(instance, instanceIdentifier);
|
||||||
|
/**
|
||||||
|
* Order is important
|
||||||
|
* onInstanceCreated() should be called after this.instances.set(instanceIdentifier, instance); which
|
||||||
|
* makes `isInitialized()` return true.
|
||||||
|
*/
|
||||||
|
if (this.component.onInstanceCreated) {
|
||||||
|
try {
|
||||||
|
this.component.onInstanceCreated(this.container, instanceIdentifier, instance);
|
||||||
|
}
|
||||||
|
catch (_c) {
|
||||||
|
// ignore errors in the onInstanceCreatedCallback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance || null;
|
||||||
|
};
|
||||||
|
Provider.prototype.normalizeInstanceIdentifier = function (identifier) {
|
||||||
|
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
|
||||||
|
if (this.component) {
|
||||||
|
return this.component.multipleInstances ? identifier : DEFAULT_ENTRY_NAME;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return identifier; // assume multiple instances are supported before the component is provided.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Provider.prototype.shouldAutoInitialize = function () {
|
||||||
|
return (!!this.component &&
|
||||||
|
this.component.instantiationMode !== "EXPLICIT" /* InstantiationMode.EXPLICIT */);
|
||||||
|
};
|
||||||
|
return Provider;
|
||||||
|
}());
|
||||||
|
// undefined should be passed to the service factory for the default instance
|
||||||
|
function normalizeIdentifierForFactory(identifier) {
|
||||||
|
return identifier === DEFAULT_ENTRY_NAME ? undefined : identifier;
|
||||||
|
}
|
||||||
|
function isComponentEager(component) {
|
||||||
|
return component.instantiationMode === "EAGER" /* InstantiationMode.EAGER */;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
|
||||||
|
*/
|
||||||
|
var ComponentContainer = /** @class */ (function () {
|
||||||
|
function ComponentContainer(name) {
|
||||||
|
this.name = name;
|
||||||
|
this.providers = new Map();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param component Component being added
|
||||||
|
* @param overwrite When a component with the same name has already been registered,
|
||||||
|
* if overwrite is true: overwrite the existing component with the new component and create a new
|
||||||
|
* provider with the new component. It can be useful in tests where you want to use different mocks
|
||||||
|
* for different tests.
|
||||||
|
* if overwrite is false: throw an exception
|
||||||
|
*/
|
||||||
|
ComponentContainer.prototype.addComponent = function (component) {
|
||||||
|
var provider = this.getProvider(component.name);
|
||||||
|
if (provider.isComponentSet()) {
|
||||||
|
throw new Error("Component ".concat(component.name, " has already been registered with ").concat(this.name));
|
||||||
|
}
|
||||||
|
provider.setComponent(component);
|
||||||
|
};
|
||||||
|
ComponentContainer.prototype.addOrOverwriteComponent = function (component) {
|
||||||
|
var provider = this.getProvider(component.name);
|
||||||
|
if (provider.isComponentSet()) {
|
||||||
|
// delete the existing provider from the container, so we can register the new component
|
||||||
|
this.providers.delete(component.name);
|
||||||
|
}
|
||||||
|
this.addComponent(component);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* getProvider provides a type safe interface where it can only be called with a field name
|
||||||
|
* present in NameServiceMapping interface.
|
||||||
|
*
|
||||||
|
* Firebase SDKs providing services should extend NameServiceMapping interface to register
|
||||||
|
* themselves.
|
||||||
|
*/
|
||||||
|
ComponentContainer.prototype.getProvider = function (name) {
|
||||||
|
if (this.providers.has(name)) {
|
||||||
|
return this.providers.get(name);
|
||||||
|
}
|
||||||
|
// create a Provider for a service that hasn't registered with Firebase
|
||||||
|
var provider = new Provider(name, this);
|
||||||
|
this.providers.set(name, provider);
|
||||||
|
return provider;
|
||||||
|
};
|
||||||
|
ComponentContainer.prototype.getProviders = function () {
|
||||||
|
return Array.from(this.providers.values());
|
||||||
|
};
|
||||||
|
return ComponentContainer;
|
||||||
|
}());
|
||||||
|
|
||||||
|
exports.Component = Component;
|
||||||
|
exports.ComponentContainer = ComponentContainer;
|
||||||
|
exports.Provider = Provider;
|
||||||
|
//# sourceMappingURL=index.cjs.js.map
|
||||||
1
functions/node_modules/@firebase/component/dist/index.cjs.js.map
generated
vendored
Normal file
1
functions/node_modules/@firebase/component/dist/index.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
20
functions/node_modules/@firebase/component/dist/index.d.ts
generated
vendored
Normal file
20
functions/node_modules/@firebase/component/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export { Component } from './src/component';
|
||||||
|
export { ComponentContainer } from './src/component_container';
|
||||||
|
export { Provider } from './src/provider';
|
||||||
|
export { ComponentType, InstanceFactory, InstantiationMode, NameServiceMapping, Name, InstanceFactoryOptions } from './src/types';
|
||||||
43
functions/node_modules/@firebase/component/dist/src/component.d.ts
generated
vendored
Normal file
43
functions/node_modules/@firebase/component/dist/src/component.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { InstantiationMode, InstanceFactory, ComponentType, Dictionary, Name, onInstanceCreatedCallback } from './types';
|
||||||
|
/**
|
||||||
|
* Component for service name T, e.g. `auth`, `auth-internal`
|
||||||
|
*/
|
||||||
|
export declare class Component<T extends Name = Name> {
|
||||||
|
readonly name: T;
|
||||||
|
readonly instanceFactory: InstanceFactory<T>;
|
||||||
|
readonly type: ComponentType;
|
||||||
|
multipleInstances: boolean;
|
||||||
|
/**
|
||||||
|
* Properties to be added to the service namespace
|
||||||
|
*/
|
||||||
|
serviceProps: Dictionary;
|
||||||
|
instantiationMode: InstantiationMode;
|
||||||
|
onInstanceCreated: onInstanceCreatedCallback<T> | null;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param name The public service name, e.g. app, auth, firestore, database
|
||||||
|
* @param instanceFactory Service factory responsible for creating the public interface
|
||||||
|
* @param type whether the service provided by the component is public or private
|
||||||
|
*/
|
||||||
|
constructor(name: T, instanceFactory: InstanceFactory<T>, type: ComponentType);
|
||||||
|
setInstantiationMode(mode: InstantiationMode): this;
|
||||||
|
setMultipleInstances(multipleInstances: boolean): this;
|
||||||
|
setServiceProps(props: Dictionary): this;
|
||||||
|
setInstanceCreatedCallback(callback: onInstanceCreatedCallback<T>): this;
|
||||||
|
}
|
||||||
47
functions/node_modules/@firebase/component/dist/src/component_container.d.ts
generated
vendored
Normal file
47
functions/node_modules/@firebase/component/dist/src/component_container.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { Provider } from './provider';
|
||||||
|
import { Component } from './component';
|
||||||
|
import { Name } from './types';
|
||||||
|
/**
|
||||||
|
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
|
||||||
|
*/
|
||||||
|
export declare class ComponentContainer {
|
||||||
|
private readonly name;
|
||||||
|
private readonly providers;
|
||||||
|
constructor(name: string);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param component Component being added
|
||||||
|
* @param overwrite When a component with the same name has already been registered,
|
||||||
|
* if overwrite is true: overwrite the existing component with the new component and create a new
|
||||||
|
* provider with the new component. It can be useful in tests where you want to use different mocks
|
||||||
|
* for different tests.
|
||||||
|
* if overwrite is false: throw an exception
|
||||||
|
*/
|
||||||
|
addComponent<T extends Name>(component: Component<T>): void;
|
||||||
|
addOrOverwriteComponent<T extends Name>(component: Component<T>): void;
|
||||||
|
/**
|
||||||
|
* getProvider provides a type safe interface where it can only be called with a field name
|
||||||
|
* present in NameServiceMapping interface.
|
||||||
|
*
|
||||||
|
* Firebase SDKs providing services should extend NameServiceMapping interface to register
|
||||||
|
* themselves.
|
||||||
|
*/
|
||||||
|
getProvider<T extends Name>(name: T): Provider<T>;
|
||||||
|
getProviders(): Array<Provider<Name>>;
|
||||||
|
}
|
||||||
24
functions/node_modules/@firebase/component/dist/src/component_container.test.d.ts
generated
vendored
Normal file
24
functions/node_modules/@firebase/component/dist/src/component_container.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import '../test/setup';
|
||||||
|
declare module './types' {
|
||||||
|
interface NameServiceMapping {
|
||||||
|
rocket: {};
|
||||||
|
ship: {};
|
||||||
|
fireball: {};
|
||||||
|
}
|
||||||
|
}
|
||||||
17
functions/node_modules/@firebase/component/dist/src/constants.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/component/dist/src/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export declare const DEFAULT_ENTRY_NAME = "[DEFAULT]";
|
||||||
79
functions/node_modules/@firebase/component/dist/src/provider.d.ts
generated
vendored
Normal file
79
functions/node_modules/@firebase/component/dist/src/provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { ComponentContainer } from './component_container';
|
||||||
|
import { InitializeOptions, Name, NameServiceMapping, OnInitCallBack } from './types';
|
||||||
|
import { Component } from './component';
|
||||||
|
/**
|
||||||
|
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
|
||||||
|
* NameServiceMapping[T] is an alias for the type of the instance
|
||||||
|
*/
|
||||||
|
export declare class Provider<T extends Name> {
|
||||||
|
private readonly name;
|
||||||
|
private readonly container;
|
||||||
|
private component;
|
||||||
|
private readonly instances;
|
||||||
|
private readonly instancesDeferred;
|
||||||
|
private readonly instancesOptions;
|
||||||
|
private onInitCallbacks;
|
||||||
|
constructor(name: T, container: ComponentContainer);
|
||||||
|
/**
|
||||||
|
* @param identifier A provider can provide multiple instances of a service
|
||||||
|
* if this.component.multipleInstances is true.
|
||||||
|
*/
|
||||||
|
get(identifier?: string): Promise<NameServiceMapping[T]>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param options.identifier A provider can provide multiple instances of a service
|
||||||
|
* if this.component.multipleInstances is true.
|
||||||
|
* @param options.optional If optional is false or not provided, the method throws an error when
|
||||||
|
* the service is not immediately available.
|
||||||
|
* If optional is true, the method returns null if the service is not immediately available.
|
||||||
|
*/
|
||||||
|
getImmediate(options: {
|
||||||
|
identifier?: string;
|
||||||
|
optional: true;
|
||||||
|
}): NameServiceMapping[T] | null;
|
||||||
|
getImmediate(options?: {
|
||||||
|
identifier?: string;
|
||||||
|
optional?: false;
|
||||||
|
}): NameServiceMapping[T];
|
||||||
|
getComponent(): Component<T> | null;
|
||||||
|
setComponent(component: Component<T>): void;
|
||||||
|
clearInstance(identifier?: string): void;
|
||||||
|
delete(): Promise<void>;
|
||||||
|
isComponentSet(): boolean;
|
||||||
|
isInitialized(identifier?: string): boolean;
|
||||||
|
getOptions(identifier?: string): Record<string, unknown>;
|
||||||
|
initialize(opts?: InitializeOptions): NameServiceMapping[T];
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
|
||||||
|
* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
|
||||||
|
*
|
||||||
|
* @param identifier An optional instance identifier
|
||||||
|
* @returns a function to unregister the callback
|
||||||
|
*/
|
||||||
|
onInit(callback: OnInitCallBack<T>, identifier?: string): () => void;
|
||||||
|
/**
|
||||||
|
* Invoke onInit callbacks synchronously
|
||||||
|
* @param instance the service instance`
|
||||||
|
*/
|
||||||
|
private invokeOnInitCallbacks;
|
||||||
|
private getOrInitializeService;
|
||||||
|
private normalizeInstanceIdentifier;
|
||||||
|
private shouldAutoInitialize;
|
||||||
|
}
|
||||||
23
functions/node_modules/@firebase/component/dist/src/provider.test.d.ts
generated
vendored
Normal file
23
functions/node_modules/@firebase/component/dist/src/provider.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import '../test/setup';
|
||||||
|
declare module './types' {
|
||||||
|
interface NameServiceMapping {
|
||||||
|
test: {};
|
||||||
|
badtest: {};
|
||||||
|
}
|
||||||
|
}
|
||||||
62
functions/node_modules/@firebase/component/dist/src/types.d.ts
generated
vendored
Normal file
62
functions/node_modules/@firebase/component/dist/src/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { ComponentContainer } from './component_container';
|
||||||
|
export declare const enum InstantiationMode {
|
||||||
|
LAZY = "LAZY",
|
||||||
|
EAGER = "EAGER",
|
||||||
|
EXPLICIT = "EXPLICIT"
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* PUBLIC: A public component provides a set of public APIs to customers. A service namespace will be patched
|
||||||
|
* onto `firebase` namespace. Assume the component name is `test`, customers will be able
|
||||||
|
* to get the service by calling `firebase.test()` or `app.test()` where `app` is a `FirebaseApp` instance.
|
||||||
|
*
|
||||||
|
* PRIVATE: A private component provides a set of private APIs that are used internally by other
|
||||||
|
* Firebase SDKs. No service namespace is created in `firebase` namespace and customers have no way to get them.
|
||||||
|
*/
|
||||||
|
export declare const enum ComponentType {
|
||||||
|
PUBLIC = "PUBLIC",
|
||||||
|
PRIVATE = "PRIVATE",
|
||||||
|
VERSION = "VERSION"
|
||||||
|
}
|
||||||
|
export interface InstanceFactoryOptions {
|
||||||
|
instanceIdentifier?: string;
|
||||||
|
options?: {};
|
||||||
|
}
|
||||||
|
export declare type InitializeOptions = InstanceFactoryOptions;
|
||||||
|
/**
|
||||||
|
* Factory to create an instance of type T, given a ComponentContainer.
|
||||||
|
* ComponentContainer is the IOC container that provides {@link Provider}
|
||||||
|
* for dependencies.
|
||||||
|
*
|
||||||
|
* NOTE: The container only provides {@link Provider} rather than the actual instances of dependencies.
|
||||||
|
* It is useful for lazily loaded dependencies and optional dependencies.
|
||||||
|
*/
|
||||||
|
export declare type InstanceFactory<T extends Name> = (container: ComponentContainer, options: InstanceFactoryOptions) => NameServiceMapping[T];
|
||||||
|
export declare type onInstanceCreatedCallback<T extends Name> = (container: ComponentContainer, instanceIdentifier: string, instance: NameServiceMapping[T]) => void;
|
||||||
|
export interface Dictionary {
|
||||||
|
[key: string]: unknown;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This interface will be extended by Firebase SDKs to provide service name and service type mapping.
|
||||||
|
* It is used as a generic constraint to ensure type safety.
|
||||||
|
*/
|
||||||
|
export interface NameServiceMapping {
|
||||||
|
}
|
||||||
|
export declare type Name = keyof NameServiceMapping;
|
||||||
|
export declare type Service = NameServiceMapping[Name];
|
||||||
|
export declare type OnInitCallBack<T extends Name> = (instance: NameServiceMapping[T], identifier: string) => void;
|
||||||
17
functions/node_modules/@firebase/component/dist/test/setup.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/component/dist/test/setup.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export {};
|
||||||
5
functions/node_modules/@firebase/component/dist/test/util.d.ts
generated
vendored
Normal file
5
functions/node_modules/@firebase/component/dist/test/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { FirebaseApp } from '@firebase/app-types';
|
||||||
|
import { InstanceFactory, InstantiationMode, Name } from '../src/types';
|
||||||
|
import { Component } from '../src/component';
|
||||||
|
export declare function getFakeApp(appName?: string): FirebaseApp;
|
||||||
|
export declare function getFakeComponent<T extends Name>(name: T, factory: InstanceFactory<T>, multipleInstance?: boolean, instantiationMode?: InstantiationMode): Component<T>;
|
||||||
60
functions/node_modules/@firebase/component/package.json
generated
vendored
Normal file
60
functions/node_modules/@firebase/component/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
{
|
||||||
|
"name": "@firebase/component",
|
||||||
|
"version": "0.6.9",
|
||||||
|
"description": "Firebase Component Platform",
|
||||||
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
||||||
|
"main": "dist/index.cjs.js",
|
||||||
|
"browser": "dist/esm/index.esm2017.js",
|
||||||
|
"module": "dist/esm/index.esm2017.js",
|
||||||
|
"esm5": "dist/esm/index.esm5.js",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"require": "./dist/index.cjs.js",
|
||||||
|
"esm5": "./dist/esm/index.esm5.js",
|
||||||
|
"default": "./dist/esm/index.esm2017.js"
|
||||||
|
},
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
|
||||||
|
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
|
||||||
|
"build": "rollup -c",
|
||||||
|
"build:deps": "lerna run --scope @firebase/component --include-dependencies build",
|
||||||
|
"dev": "rollup -c -w",
|
||||||
|
"test": "run-p --npm-path npm lint test:all",
|
||||||
|
"test:all": "run-p --npm-path npm test:browser test:node",
|
||||||
|
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
|
||||||
|
"test:browser": "karma start",
|
||||||
|
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --config ../../config/mocharc.node.js",
|
||||||
|
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@firebase/util": "1.10.0",
|
||||||
|
"tslib": "^2.1.0"
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"rollup": "2.79.1",
|
||||||
|
"rollup-plugin-typescript2": "0.31.2",
|
||||||
|
"typescript": "4.7.4"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"directory": "packages/component",
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
||||||
|
},
|
||||||
|
"typings": "dist/index.d.ts",
|
||||||
|
"nyc": {
|
||||||
|
"extension": [
|
||||||
|
".ts"
|
||||||
|
],
|
||||||
|
"reportDir": "./coverage/node"
|
||||||
|
}
|
||||||
|
}
|
||||||
5
functions/node_modules/@firebase/database-compat/README.md
generated
vendored
Normal file
5
functions/node_modules/@firebase/database-compat/README.md
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# @firebase/database-compat
|
||||||
|
|
||||||
|
This is the compatibility layer for the Firebase Realtime Database component of the Firebase JS SDK.
|
||||||
|
|
||||||
|
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
|
||||||
74
functions/node_modules/@firebase/database-compat/dist/database-compat/src/api/Database.d.ts
generated
vendored
Normal file
74
functions/node_modules/@firebase/database-compat/dist/database-compat/src/api/Database.d.ts
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { FirebaseApp } from '@firebase/app-types';
|
||||||
|
import { FirebaseService } from '@firebase/app-types/private';
|
||||||
|
import { forceLongPolling, forceWebSockets, Database as ModularDatabase } from '@firebase/database';
|
||||||
|
import { Compat, EmulatorMockTokenOptions } from '@firebase/util';
|
||||||
|
import { Reference } from './Reference';
|
||||||
|
/**
|
||||||
|
* Class representing a firebase database.
|
||||||
|
*/
|
||||||
|
export declare class Database implements FirebaseService, Compat<ModularDatabase> {
|
||||||
|
readonly _delegate: ModularDatabase;
|
||||||
|
readonly app: FirebaseApp;
|
||||||
|
static readonly ServerValue: {
|
||||||
|
TIMESTAMP: object;
|
||||||
|
increment: (delta: number) => object;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The constructor should not be called by users of our public API.
|
||||||
|
*/
|
||||||
|
constructor(_delegate: ModularDatabase, app: FirebaseApp);
|
||||||
|
INTERNAL: {
|
||||||
|
delete: () => Promise<void>;
|
||||||
|
forceWebSockets: typeof forceWebSockets;
|
||||||
|
forceLongPolling: typeof forceLongPolling;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Modify this instance to communicate with the Realtime Database emulator.
|
||||||
|
*
|
||||||
|
* <p>Note: This method must be called before performing any other operation.
|
||||||
|
*
|
||||||
|
* @param host - the emulator host (ex: localhost)
|
||||||
|
* @param port - the emulator port (ex: 8080)
|
||||||
|
* @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
|
||||||
|
*/
|
||||||
|
useEmulator(host: string, port: number, options?: {
|
||||||
|
mockUserToken?: EmulatorMockTokenOptions;
|
||||||
|
}): void;
|
||||||
|
/**
|
||||||
|
* Returns a reference to the root or to the path specified in the provided
|
||||||
|
* argument.
|
||||||
|
*
|
||||||
|
* @param path - The relative string path or an existing Reference to a database
|
||||||
|
* location.
|
||||||
|
* @throws If a Reference is provided, throws if it does not belong to the
|
||||||
|
* same project.
|
||||||
|
* @returns Firebase reference.
|
||||||
|
*/
|
||||||
|
ref(path?: string): Reference;
|
||||||
|
ref(path?: Reference): Reference;
|
||||||
|
/**
|
||||||
|
* Returns a reference to the root or the path specified in url.
|
||||||
|
* We throw a exception if the url is not in the same domain as the
|
||||||
|
* current repo.
|
||||||
|
* @returns Firebase reference.
|
||||||
|
*/
|
||||||
|
refFromURL(url: string): Reference;
|
||||||
|
goOffline(): void;
|
||||||
|
goOnline(): void;
|
||||||
|
}
|
||||||
207
functions/node_modules/@firebase/database-compat/dist/database-compat/src/api/Reference.d.ts
generated
vendored
Normal file
207
functions/node_modules/@firebase/database-compat/dist/database-compat/src/api/Reference.d.ts
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { DataSnapshot as ModularDataSnapshot, Query as ExpQuery, DatabaseReference as ModularReference } from '@firebase/database';
|
||||||
|
import { Compat } from '@firebase/util';
|
||||||
|
import { Database } from './Database';
|
||||||
|
import { OnDisconnect } from './onDisconnect';
|
||||||
|
import { TransactionResult } from './TransactionResult';
|
||||||
|
/**
|
||||||
|
* Class representing a firebase data snapshot. It wraps a SnapshotNode and
|
||||||
|
* surfaces the public methods (val, forEach, etc.) we want to expose.
|
||||||
|
*/
|
||||||
|
export declare class DataSnapshot implements Compat<ModularDataSnapshot> {
|
||||||
|
readonly _database: Database;
|
||||||
|
readonly _delegate: ModularDataSnapshot;
|
||||||
|
constructor(_database: Database, _delegate: ModularDataSnapshot);
|
||||||
|
/**
|
||||||
|
* Retrieves the snapshot contents as JSON. Returns null if the snapshot is
|
||||||
|
* empty.
|
||||||
|
*
|
||||||
|
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||||
|
*/
|
||||||
|
val(): unknown;
|
||||||
|
/**
|
||||||
|
* Returns the snapshot contents as JSON, including priorities of node. Suitable for exporting
|
||||||
|
* the entire node contents.
|
||||||
|
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
||||||
|
*/
|
||||||
|
exportVal(): unknown;
|
||||||
|
toJSON(): unknown;
|
||||||
|
/**
|
||||||
|
* Returns whether the snapshot contains a non-null value.
|
||||||
|
*
|
||||||
|
* @returns Whether the snapshot contains a non-null value, or is empty.
|
||||||
|
*/
|
||||||
|
exists(): boolean;
|
||||||
|
/**
|
||||||
|
* Returns a DataSnapshot of the specified child node's contents.
|
||||||
|
*
|
||||||
|
* @param path - Path to a child.
|
||||||
|
* @returns DataSnapshot for child node.
|
||||||
|
*/
|
||||||
|
child(path: string): DataSnapshot;
|
||||||
|
/**
|
||||||
|
* Returns whether the snapshot contains a child at the specified path.
|
||||||
|
*
|
||||||
|
* @param path - Path to a child.
|
||||||
|
* @returns Whether the child exists.
|
||||||
|
*/
|
||||||
|
hasChild(path: string): boolean;
|
||||||
|
/**
|
||||||
|
* Returns the priority of the object, or null if no priority was set.
|
||||||
|
*
|
||||||
|
* @returns The priority.
|
||||||
|
*/
|
||||||
|
getPriority(): string | number | null;
|
||||||
|
/**
|
||||||
|
* Iterates through child nodes and calls the specified action for each one.
|
||||||
|
*
|
||||||
|
* @param action - Callback function to be called
|
||||||
|
* for each child.
|
||||||
|
* @returns True if forEach was canceled by action returning true for
|
||||||
|
* one of the child nodes.
|
||||||
|
*/
|
||||||
|
forEach(action: (snapshot: IteratedDataSnapshot) => boolean | void): boolean;
|
||||||
|
/**
|
||||||
|
* Returns whether this DataSnapshot has children.
|
||||||
|
* @returns True if the DataSnapshot contains 1 or more child nodes.
|
||||||
|
*/
|
||||||
|
hasChildren(): boolean;
|
||||||
|
get key(): string;
|
||||||
|
/**
|
||||||
|
* Returns the number of children for this DataSnapshot.
|
||||||
|
* @returns The number of children that this DataSnapshot contains.
|
||||||
|
*/
|
||||||
|
numChildren(): number;
|
||||||
|
/**
|
||||||
|
* @returns The Firebase reference for the location this snapshot's data came
|
||||||
|
* from.
|
||||||
|
*/
|
||||||
|
getRef(): Reference;
|
||||||
|
get ref(): Reference;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
|
||||||
|
*/
|
||||||
|
export interface IteratedDataSnapshot extends DataSnapshot {
|
||||||
|
key: string;
|
||||||
|
}
|
||||||
|
export interface SnapshotCallback {
|
||||||
|
(dataSnapshot: DataSnapshot, previousChildName?: string | null): unknown;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A Query represents a filter to be applied to a firebase location. This object purely represents the
|
||||||
|
* query expression (and exposes our public API to build the query). The actual query logic is in ViewBase.js.
|
||||||
|
*
|
||||||
|
* Since every Firebase reference is a query, Firebase inherits from this object.
|
||||||
|
*/
|
||||||
|
export declare class Query implements Compat<ExpQuery> {
|
||||||
|
readonly database: Database;
|
||||||
|
readonly _delegate: ExpQuery;
|
||||||
|
constructor(database: Database, _delegate: ExpQuery);
|
||||||
|
on(eventType: string, callback: SnapshotCallback, cancelCallbackOrContext?: ((a: Error) => unknown) | object | null, context?: object | null): SnapshotCallback;
|
||||||
|
off(eventType?: string, callback?: SnapshotCallback, context?: object | null): void;
|
||||||
|
/**
|
||||||
|
* Get the server-value for this query, or return a cached value if not connected.
|
||||||
|
*/
|
||||||
|
get(): Promise<DataSnapshot>;
|
||||||
|
/**
|
||||||
|
* Attaches a listener, waits for the first event, and then removes the listener
|
||||||
|
*/
|
||||||
|
once(eventType: string, callback?: SnapshotCallback, failureCallbackOrContext?: ((a: Error) => void) | object | null, context?: object | null): Promise<DataSnapshot>;
|
||||||
|
/**
|
||||||
|
* Set a limit and anchor it to the start of the window.
|
||||||
|
*/
|
||||||
|
limitToFirst(limit: number): Query;
|
||||||
|
/**
|
||||||
|
* Set a limit and anchor it to the end of the window.
|
||||||
|
*/
|
||||||
|
limitToLast(limit: number): Query;
|
||||||
|
/**
|
||||||
|
* Given a child path, return a new query ordered by the specified grandchild path.
|
||||||
|
*/
|
||||||
|
orderByChild(path: string): Query;
|
||||||
|
/**
|
||||||
|
* Return a new query ordered by the KeyIndex
|
||||||
|
*/
|
||||||
|
orderByKey(): Query;
|
||||||
|
/**
|
||||||
|
* Return a new query ordered by the PriorityIndex
|
||||||
|
*/
|
||||||
|
orderByPriority(): Query;
|
||||||
|
/**
|
||||||
|
* Return a new query ordered by the ValueIndex
|
||||||
|
*/
|
||||||
|
orderByValue(): Query;
|
||||||
|
startAt(value?: number | string | boolean | null, name?: string | null): Query;
|
||||||
|
startAfter(value?: number | string | boolean | null, name?: string | null): Query;
|
||||||
|
endAt(value?: number | string | boolean | null, name?: string | null): Query;
|
||||||
|
endBefore(value?: number | string | boolean | null, name?: string | null): Query;
|
||||||
|
/**
|
||||||
|
* Load the selection of children with exactly the specified value, and, optionally,
|
||||||
|
* the specified name.
|
||||||
|
*/
|
||||||
|
equalTo(value: number | string | boolean | null, name?: string): Query;
|
||||||
|
/**
|
||||||
|
* @returns URL for this location.
|
||||||
|
*/
|
||||||
|
toString(): string;
|
||||||
|
toJSON(): string;
|
||||||
|
/**
|
||||||
|
* Return true if this query and the provided query are equivalent; otherwise, return false.
|
||||||
|
*/
|
||||||
|
isEqual(other: Query): boolean;
|
||||||
|
/**
|
||||||
|
* Helper used by .on and .once to extract the context and or cancel arguments.
|
||||||
|
* @param fnName - The function name (on or once)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static getCancelAndContextArgs_;
|
||||||
|
get ref(): Reference;
|
||||||
|
}
|
||||||
|
export declare class Reference extends Query implements Compat<ModularReference> {
|
||||||
|
readonly database: Database;
|
||||||
|
readonly _delegate: ModularReference;
|
||||||
|
then: Promise<Reference>['then'];
|
||||||
|
catch: Promise<Reference>['catch'];
|
||||||
|
/**
|
||||||
|
* Call options:
|
||||||
|
* new Reference(Repo, Path) or
|
||||||
|
* new Reference(url: string, string|RepoManager)
|
||||||
|
*
|
||||||
|
* Externally - this is the firebase.database.Reference type.
|
||||||
|
*/
|
||||||
|
constructor(database: Database, _delegate: ModularReference);
|
||||||
|
/** @returns {?string} */
|
||||||
|
getKey(): string | null;
|
||||||
|
child(pathString: string): Reference;
|
||||||
|
/** @returns {?Reference} */
|
||||||
|
getParent(): Reference | null;
|
||||||
|
/** @returns {!Reference} */
|
||||||
|
getRoot(): Reference;
|
||||||
|
set(newVal: unknown, onComplete?: (error: Error | null) => void): Promise<void>;
|
||||||
|
update(values: object, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||||
|
setWithPriority(newVal: unknown, newPriority: string | number | null, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||||
|
remove(onComplete?: (a: Error | null) => void): Promise<void>;
|
||||||
|
transaction(transactionUpdate: (currentData: unknown) => unknown, onComplete?: (error: Error | null, committed: boolean, dataSnapshot: DataSnapshot | null) => void, applyLocally?: boolean): Promise<TransactionResult>;
|
||||||
|
setPriority(priority: string | number | null, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||||
|
push(value?: unknown, onComplete?: (a: Error | null) => void): Reference;
|
||||||
|
onDisconnect(): OnDisconnect;
|
||||||
|
get key(): string | null;
|
||||||
|
get parent(): Reference | null;
|
||||||
|
get root(): Reference;
|
||||||
|
}
|
||||||
26
functions/node_modules/@firebase/database-compat/dist/database-compat/src/api/TransactionResult.d.ts
generated
vendored
Normal file
26
functions/node_modules/@firebase/database-compat/dist/database-compat/src/api/TransactionResult.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { DataSnapshot } from './Reference';
|
||||||
|
export declare class TransactionResult {
|
||||||
|
committed: boolean;
|
||||||
|
snapshot: DataSnapshot;
|
||||||
|
/**
|
||||||
|
* A type for the resolve value of Firebase.transaction.
|
||||||
|
*/
|
||||||
|
constructor(committed: boolean, snapshot: DataSnapshot);
|
||||||
|
toJSON(): object;
|
||||||
|
}
|
||||||
41
functions/node_modules/@firebase/database-compat/dist/database-compat/src/api/internal.d.ts
generated
vendored
Normal file
41
functions/node_modules/@firebase/database-compat/dist/database-compat/src/api/internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { FirebaseAppCheckInternal } from '@firebase/app-check-interop-types';
|
||||||
|
import { FirebaseApp } from '@firebase/app-types';
|
||||||
|
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
|
||||||
|
import * as types from '@firebase/database-types';
|
||||||
|
/**
|
||||||
|
* Used by console to create a database based on the app,
|
||||||
|
* passed database URL and a custom auth implementation.
|
||||||
|
*
|
||||||
|
* @param app - A valid FirebaseApp-like object
|
||||||
|
* @param url - A valid Firebase databaseURL
|
||||||
|
* @param version - custom version e.g. firebase-admin version
|
||||||
|
* @param customAuthImpl - custom auth implementation
|
||||||
|
*/
|
||||||
|
export declare function initStandalone<T>({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin }: {
|
||||||
|
app: FirebaseApp;
|
||||||
|
url: string;
|
||||||
|
version: string;
|
||||||
|
customAuthImpl: FirebaseAuthInternal;
|
||||||
|
customAppCheckImpl?: FirebaseAppCheckInternal;
|
||||||
|
namespace: T;
|
||||||
|
nodeAdmin?: boolean;
|
||||||
|
}): {
|
||||||
|
instance: types.Database;
|
||||||
|
namespace: T;
|
||||||
|
};
|
||||||
27
functions/node_modules/@firebase/database-compat/dist/database-compat/src/api/onDisconnect.d.ts
generated
vendored
Normal file
27
functions/node_modules/@firebase/database-compat/dist/database-compat/src/api/onDisconnect.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { OnDisconnect as ModularOnDisconnect } from '@firebase/database';
|
||||||
|
import { Compat } from '@firebase/util';
|
||||||
|
export declare class OnDisconnect implements Compat<ModularOnDisconnect> {
|
||||||
|
readonly _delegate: ModularOnDisconnect;
|
||||||
|
constructor(_delegate: ModularOnDisconnect);
|
||||||
|
cancel(onComplete?: (a: Error | null) => void): Promise<void>;
|
||||||
|
remove(onComplete?: (a: Error | null) => void): Promise<void>;
|
||||||
|
set(value: unknown, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||||
|
setWithPriority(value: unknown, priority: number | string | null, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||||
|
update(objectToMerge: Record<string, unknown>, onComplete?: (a: Error | null) => void): Promise<void>;
|
||||||
|
}
|
||||||
72
functions/node_modules/@firebase/database-compat/dist/database-compat/src/index.d.ts
generated
vendored
Normal file
72
functions/node_modules/@firebase/database-compat/dist/database-compat/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2021 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { FirebaseNamespace } from '@firebase/app-compat';
|
||||||
|
import * as types from '@firebase/database-types';
|
||||||
|
export declare function registerDatabase(instance: FirebaseNamespace): void;
|
||||||
|
declare module '@firebase/app-compat' {
|
||||||
|
interface FirebaseNamespace {
|
||||||
|
database?: {
|
||||||
|
(app?: FirebaseApp): types.FirebaseDatabase;
|
||||||
|
enableLogging: typeof types.enableLogging;
|
||||||
|
ServerValue: types.ServerValue;
|
||||||
|
Database: typeof types.FirebaseDatabase;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
interface FirebaseApp {
|
||||||
|
database?(databaseURL?: string): types.FirebaseDatabase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
import { FirebaseApp as FirebaseAppCompat } from "@firebase/app-compat";
|
||||||
|
import { type DatabaseReference, type EmulatorMockTokenOptions, type DataSnapshot, type Database, type EventType, type Unsubscribe, type ListenOptions, type OnDisconnect, type ThenableReference, type QueryConstraint, type Query, type TransactionOptions, type TransactionResult } from "@firebase/database";
|
||||||
|
declare module "@firebase/database" {
|
||||||
|
function child(parent: types.Reference, path: string): DatabaseReference;
|
||||||
|
function connectDatabaseEmulator(db: types.FirebaseDatabase, host: string, port: number, options?: {
|
||||||
|
mockUserToken?: EmulatorMockTokenOptions | string;
|
||||||
|
}): void;
|
||||||
|
function get(query: types.Query): Promise<DataSnapshot>;
|
||||||
|
function getDatabase(app?: FirebaseAppCompat, url?: string): Database;
|
||||||
|
function goOffline(db: types.FirebaseDatabase): void;
|
||||||
|
function goOnline(db: types.FirebaseDatabase): void;
|
||||||
|
function off(query: types.Query, eventType?: EventType, callback?: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown): void;
|
||||||
|
function onChildAdded(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
|
||||||
|
function onChildAdded(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
|
||||||
|
function onChildAdded(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
|
||||||
|
function onChildChanged(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
|
||||||
|
function onChildChanged(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
|
||||||
|
function onChildChanged(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
|
||||||
|
function onChildMoved(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
|
||||||
|
function onChildMoved(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
|
||||||
|
function onChildMoved(query: types.Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
|
||||||
|
function onChildRemoved(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
|
||||||
|
function onChildRemoved(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
|
||||||
|
function onChildRemoved(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
|
||||||
|
function onDisconnect(ref: types.Reference): OnDisconnect;
|
||||||
|
function onValue(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
|
||||||
|
function onValue(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
|
||||||
|
function onValue(query: types.Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
|
||||||
|
function push(parent: types.Reference, value?: unknown): ThenableReference;
|
||||||
|
function query(query: types.Query, ...queryConstraints: QueryConstraint[]): Query;
|
||||||
|
function ref(db: types.FirebaseDatabase, path?: string): DatabaseReference;
|
||||||
|
function refFromURL(db: types.FirebaseDatabase, url: string): DatabaseReference;
|
||||||
|
function remove(ref: types.Reference): Promise<void>;
|
||||||
|
function runTransaction(ref: types.Reference, transactionUpdate: (currentData: any) => unknown, options?: TransactionOptions): Promise<TransactionResult>;
|
||||||
|
function set(ref: types.Reference, value: unknown): Promise<void>;
|
||||||
|
function setPriority(ref: types.Reference, priority: string | number | null): Promise<void>;
|
||||||
|
function setWithPriority(ref: types.Reference, value: unknown, priority: string | number | null): Promise<void>;
|
||||||
|
function update(ref: types.Reference, values: object): Promise<void>;
|
||||||
|
}
|
||||||
30
functions/node_modules/@firebase/database-compat/dist/database-compat/src/index.node.d.ts
generated
vendored
Normal file
30
functions/node_modules/@firebase/database-compat/dist/database-compat/src/index.node.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2021 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import * as types from '@firebase/database-types';
|
||||||
|
declare module '@firebase/app-compat' {
|
||||||
|
interface FirebaseNamespace {
|
||||||
|
database?: {
|
||||||
|
(app?: FirebaseApp): types.FirebaseDatabase;
|
||||||
|
enableLogging: typeof types.enableLogging;
|
||||||
|
ServerValue: types.ServerValue;
|
||||||
|
Database: typeof types.FirebaseDatabase;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
interface FirebaseApp {
|
||||||
|
database?(): types.FirebaseDatabase;
|
||||||
|
}
|
||||||
|
}
|
||||||
52
functions/node_modules/@firebase/database-compat/dist/database-compat/src/index.standalone.d.ts
generated
vendored
Normal file
52
functions/node_modules/@firebase/database-compat/dist/database-compat/src/index.standalone.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2021 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { FirebaseApp } from '@firebase/app-types';
|
||||||
|
import { enableLogging } from '@firebase/database';
|
||||||
|
import { Database } from './api/Database';
|
||||||
|
import * as INTERNAL from './api/internal';
|
||||||
|
import { DataSnapshot, Query, Reference } from './api/Reference';
|
||||||
|
declare const ServerValue: {
|
||||||
|
TIMESTAMP: object;
|
||||||
|
increment: (delta: number) => object;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* A one off register function which returns a database based on the app and
|
||||||
|
* passed database URL. (Used by the Admin SDK)
|
||||||
|
*
|
||||||
|
* @param app - A valid FirebaseApp-like object
|
||||||
|
* @param url - A valid Firebase databaseURL
|
||||||
|
* @param version - custom version e.g. firebase-admin version
|
||||||
|
* @param nodeAdmin - true if the SDK is being initialized from Firebase Admin.
|
||||||
|
*/
|
||||||
|
export declare function initStandalone(app: FirebaseApp, url: string, version: string, nodeAdmin?: boolean): {
|
||||||
|
instance: import("@firebase/database-types").Database;
|
||||||
|
namespace: {
|
||||||
|
Reference: typeof Reference;
|
||||||
|
Query: typeof Query;
|
||||||
|
Database: typeof Database;
|
||||||
|
DataSnapshot: typeof DataSnapshot;
|
||||||
|
enableLogging: typeof enableLogging;
|
||||||
|
INTERNAL: typeof INTERNAL;
|
||||||
|
ServerValue: {
|
||||||
|
TIMESTAMP: object;
|
||||||
|
increment: (delta: number) => object;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export { Database, Query, Reference, enableLogging, ServerValue };
|
||||||
|
export { OnDisconnect } from '@firebase/database';
|
||||||
|
export { DataSnapshot } from './api/Reference';
|
||||||
17
functions/node_modules/@firebase/database-compat/dist/database-compat/src/util/util.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/database-compat/dist/database-compat/src/util/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2021 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export declare const warn: (msg: string) => void;
|
||||||
18
functions/node_modules/@firebase/database-compat/dist/database-compat/src/util/validation.d.ts
generated
vendored
Normal file
18
functions/node_modules/@firebase/database-compat/dist/database-compat/src/util/validation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2021 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export declare const validateBoolean: (fnName: string, argumentName: string, bool: unknown, optional: boolean) => void;
|
||||||
|
export declare const validateEventType: (fnName: string, eventType: string, optional: boolean) => void;
|
||||||
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/browser/crawler_support.test.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/browser/crawler_support.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export {};
|
||||||
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/database.test.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/database.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import '../src/index';
|
||||||
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/datasnapshot.test.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/datasnapshot.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export {};
|
||||||
34
functions/node_modules/@firebase/database-compat/dist/database-compat/test/helpers/events.d.ts
generated
vendored
Normal file
34
functions/node_modules/@firebase/database-compat/dist/database-compat/test/helpers/events.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* A set of functions to clean up event handlers.
|
||||||
|
*/
|
||||||
|
export declare let eventCleanupHandlers: any[];
|
||||||
|
/** Clean up outstanding event handlers */
|
||||||
|
export declare function eventCleanup(): void;
|
||||||
|
/**
|
||||||
|
* Creates a struct which waits for many events.
|
||||||
|
* @param pathAndEvents - an array of tuples of [Firebase, [event type strings]]
|
||||||
|
*/
|
||||||
|
export declare function eventTestHelper(pathAndEvents: any, helperName?: any): {
|
||||||
|
promise: Promise<unknown>;
|
||||||
|
initPromise: Promise<unknown>;
|
||||||
|
waiter: () => boolean;
|
||||||
|
watchesInitializedWaiter: () => boolean;
|
||||||
|
unregister: () => void;
|
||||||
|
addExpectedEvents(moreEvents: any): void;
|
||||||
|
};
|
||||||
42
functions/node_modules/@firebase/database-compat/dist/database-compat/test/helpers/util.d.ts
generated
vendored
Normal file
42
functions/node_modules/@firebase/database-compat/dist/database-compat/test/helpers/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import '../../src/index';
|
||||||
|
import { Path } from '../../../database/src/core/util/Path';
|
||||||
|
import { Query, Reference } from '../../src/api/Reference';
|
||||||
|
export declare const TEST_PROJECT: any;
|
||||||
|
export declare const DATABASE_ADDRESS: any;
|
||||||
|
export declare const DATABASE_URL: any;
|
||||||
|
export declare function createTestApp(): import("@firebase/app-compat").FirebaseApp;
|
||||||
|
/**
|
||||||
|
* Gets or creates a root node to the test namespace. All calls sharing the
|
||||||
|
* value of opt_i will share an app context.
|
||||||
|
*/
|
||||||
|
export declare function getRootNode(i?: number, ref?: string): any;
|
||||||
|
/**
|
||||||
|
* Create multiple refs to the same top level
|
||||||
|
* push key - each on its own Firebase.Context.
|
||||||
|
*/
|
||||||
|
export declare function getRandomNode(numNodes?: any): Reference | Reference[];
|
||||||
|
export declare function getQueryValue(query: Query): Promise<unknown>;
|
||||||
|
export declare function pause(milliseconds: number): Promise<void>;
|
||||||
|
export declare function getPath(query: Query): string;
|
||||||
|
export declare function shuffle(arr: any, randFn?: () => number): void;
|
||||||
|
export declare function getFreshRepo(path: Path): any;
|
||||||
|
export declare function getFreshRepoFromReference(ref: any): any;
|
||||||
|
export declare function getSnap(path: any): any;
|
||||||
|
export declare function getVal(path: any): any;
|
||||||
|
export declare function canCreateExtraConnections(): boolean;
|
||||||
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/info.test.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/info.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export {};
|
||||||
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/order.test.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/order.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export {};
|
||||||
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/order_by.test.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/order_by.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export {};
|
||||||
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/promise.test.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/promise.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export {};
|
||||||
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/query.test.d.ts
generated
vendored
Normal file
17
functions/node_modules/@firebase/database-compat/dist/database-compat/test/query.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2017 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
export {};
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user