mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
firebase auth webhook
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import { Typography, Link, TextField } from "@mui/material";
|
||||
import InlineOpenInNewIcon from "@src/components/InlineOpenInNewIcon";
|
||||
import { TableSettings } from "@src/types/table";
|
||||
import {
|
||||
IWebhook,
|
||||
ISecret,
|
||||
} from "@src/components/TableModals/WebhooksModal/utils";
|
||||
|
||||
export const webhookFirebaseAuth = {
|
||||
name: "firebaseAuth",
|
||||
parser: {
|
||||
additionalVariables: null,
|
||||
extraLibs: null,
|
||||
template: (
|
||||
table: TableSettings
|
||||
) => `const firebaseAuthParser: Parser = async({req, db, ref, logging}) =>{
|
||||
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
logging.log("firebaseAuthParser started")
|
||||
/**
|
||||
* This is a sample parser for firebase authentication
|
||||
* creates a user document in the collection if it doesn't exist
|
||||
// check if document exists,
|
||||
const userDoc = await ref.doc(user.uid).get()
|
||||
if(!userDoc.exists){
|
||||
await ref.doc(user.uid).set({email:user.email})
|
||||
}
|
||||
*/
|
||||
return;
|
||||
};`,
|
||||
},
|
||||
condition: {
|
||||
additionalVariables: null,
|
||||
extraLibs: null,
|
||||
template: (
|
||||
table: TableSettings
|
||||
) => `const condition: Condition = async({ref, req, db, logging}) => {
|
||||
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
logging.log("condition started")
|
||||
|
||||
return true;
|
||||
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
|
||||
}`,
|
||||
},
|
||||
auth: (
|
||||
webhookObject: IWebhook,
|
||||
setWebhookObject: (w: IWebhook) => void,
|
||||
secrets: ISecret
|
||||
) => {
|
||||
return (
|
||||
<>
|
||||
<Typography variant="inherit" paragraph>
|
||||
For Firebase authentication, you need to include the following header
|
||||
in your request:
|
||||
<br />
|
||||
<code>Authorization: Bear ACCESS_TOKEN</code>
|
||||
</Typography>
|
||||
|
||||
<Typography variant="inherit" paragraph>
|
||||
Once enabled requests without a valid token will return{" "}
|
||||
<code>401</code> response.
|
||||
</Typography>
|
||||
</>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export default webhookFirebaseAuth;
|
||||
@@ -1,7 +1,8 @@
|
||||
import basic from "./basic";
|
||||
import firebaseAuth from "./firebaseAuth";
|
||||
import typeform from "./typeform";
|
||||
import sendgrid from "./sendgrid";
|
||||
import webform from "./webform";
|
||||
import stripe from "./stripe";
|
||||
|
||||
export { basic, typeform, sendgrid, webform, stripe };
|
||||
export { basic, typeform, sendgrid, webform, stripe, firebaseAuth };
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
import { TableSettings } from "@src/types/table";
|
||||
import { generateId } from "@src/utils/table";
|
||||
import { typeform, basic, sendgrid, webform, stripe } from "./Schemas";
|
||||
import {
|
||||
typeform,
|
||||
basic,
|
||||
sendgrid,
|
||||
webform,
|
||||
stripe,
|
||||
firebaseAuth,
|
||||
} from "./Schemas";
|
||||
|
||||
export const webhookTypes = [
|
||||
"basic",
|
||||
"typeform",
|
||||
"sendgrid",
|
||||
"webform",
|
||||
"firebaseAuth",
|
||||
//"shopify",
|
||||
//"twitter",
|
||||
"stripe",
|
||||
@@ -35,6 +43,18 @@ export const parserExtraLibs = [
|
||||
send: (v:any)=>void;
|
||||
sendStatus: (status:number)=>void
|
||||
};
|
||||
user: {
|
||||
uid: string;
|
||||
email: string;
|
||||
email_verified: boolean;
|
||||
exp: number;
|
||||
iat: number;
|
||||
iss: string;
|
||||
aud: string;
|
||||
auth_time: number;
|
||||
phone_number: string;
|
||||
picture: string;
|
||||
} | undefined;
|
||||
logging: RowyLogging;
|
||||
auth:firebaseauth.BaseAuth;
|
||||
storage:firebasestorage.Storage;
|
||||
@@ -71,6 +91,7 @@ export type WebhookType = typeof webhookTypes[number];
|
||||
export const webhookNames: Record<WebhookType, string> = {
|
||||
sendgrid: "SendGrid",
|
||||
typeform: "Typeform",
|
||||
firebaseAuth: "Firebase Auth",
|
||||
//github:"GitHub",
|
||||
// shopify: "Shopify",
|
||||
// twitter: "Twitter",
|
||||
@@ -110,6 +131,7 @@ export const webhookSchemas = {
|
||||
sendgrid,
|
||||
webform,
|
||||
stripe,
|
||||
firebaseAuth,
|
||||
};
|
||||
|
||||
export function emptyWebhookObject(
|
||||
|
||||
Reference in New Issue
Block a user