21* Get Google OAuth URL - implements getGoogleOAuthURL operation
22*/
23export function getGoogleOAuthURL(c: Context<{ Variables: Variables }>): Promise<Response> {
24try {
25// Generate CSRF state token
35});
3637// Generate OAuth URL using existing function
38const authUrl = generateOAuthUrl("google", state);
3978* Handle Google OAuth callback - implements handleGoogleCallback operation
79*/
80export async function handleGoogleCallback(
81c: Context<{ Variables: Variables }>,
82): Promise<Response> {
231* Exchange authorization code for access tokens
232*/
233async function exchangeCodeForTokens(code: string) {
234try {
235const googleConfig = AUTH_CONFIG.oauth.providers.GOOGLE;
279* Fetch user information from Google
280*/
281async function fetchGoogleUserInfo(accessToken: string) {
282try {
283const googleConfig = AUTH_CONFIG.oauth.providers.GOOGLE;
21* Get GitHub OAuth URL - implements getGitHubOAuthURL operation
22*/
23export function getGitHubOAuthURL(c: Context<{ Variables: Variables }>): Promise<Response> {
24try {
25// Generate CSRF state token
35});
3637// Generate OAuth URL using existing function
38const authUrl = generateOAuthUrl("github", state);
3978* Handle GitHub OAuth callback - implements handleGitHubCallback operation
79*/
80export async function handleGitHubCallback(
81c: Context<{ Variables: Variables }>,
82): Promise<Response> {
231* Exchange authorization code for access tokens
232*/
233async function exchangeCodeForTokens(code: string) {
234try {
235const githubConfig = AUTH_CONFIG.oauth.providers.GITHUB;
288* Fetch user information from GitHub
289*/
290async function fetchGitHubUserInfo(accessToken: string) {
291try {
292const githubConfig = AUTH_CONFIG.oauth.providers.GITHUB;
346* Fetch user email from GitHub emails endpoint (fallback)
347*/
348async function fetchGitHubUserEmail(accessToken: string) {
349try {
350const emailRequest = await fetch("https://api.github.com/user/emails", {
api_ianmenethil_cominfoService.ts4 matches
8586/**
87* API info handler function for use in service router
88* @param c - Hono context with Variables
89* @returns Response with API information
90*/
91export function getApiInfo(c: Context<{ Variables: Variables }>): Response {
92try {
93const info = infoService.getApiInfo();
102103/**
104* Version handler function for use in service router
105* @param c - Hono context with Variables
106* @returns Response with version information
107*/
108export function getVersion(c: Context<{ Variables: Variables }>): Response {
109try {
110const versionInfo = infoService.getVersionInfo();
api_ianmenethil_comhashService.ts12 matches
133* when calling Zenith's /initiate-payment endpoint.
134*/
135export async function hashData(c: Context<{ Variables: Variables }>): Promise<Response> {
136const requestId = crypto.randomUUID();
137251* Handle v1/v2 versions - Base64 encoding
252*/
253async function handleV1V2(
254c: Context<{ Variables: Variables }>,
255requestBody: any,
362* Handle v3/v4/v5 versions - Hash generation for Zenith fingerprint
363*/
364async function handleV3V4V5(
365c: Context<{ Variables: Variables }>,
366requestBody: any,
527}
528529// ==================== UTILITY FUNCTIONS ====================
530531/**
532* Generate hash using Web Crypto API
533*/
534async function generateHash(data: string, algorithm: string): Promise<string> {
535const encoder = new TextEncoder();
536const dataBuffer = encoder.encode(data);
575* Check if timestamp is in valid ISO 8601 format
576*/
577function isValidISO8601(timestamp: string): boolean {
578try {
579const date = new Date(timestamp);
594* Check if timestamp is within acceptable time window (5 minutes)
595*/
596function isTimestampRecent(timestamp: string): boolean {
597try {
598const providedTime = new Date(timestamp).getTime();
610* Format Zod errors for user-friendly error response
611*/
612function formatZodErrors(error: z.ZodError): HashErrorResponse["details"] {
613return error.errors.map((err) => {
614const field = err.path.join(".");
643* Create standardized error response
644*/
645function createHashErrorResponse(
646code: string,
647message: string,
666* Optional info endpoint handler for documentation
667*/
668export async function hashInfo(c: Context): Promise<Response> {
669const currentTime = new Date().toISOString();
670825826/**
827* Hash handler function for use in service router
828* @param c - Hono context with Variables
829* @returns Response with hash result
830*/
831export async function getHash(c: Context<{ Variables: Variables }>): Promise<Response> {
832return await hashData(c);
833}
api_ianmenethil_comhash.service.ts12 matches
133* when calling Zenith's /initiate-payment endpoint.
134*/
135export async function hashData(c: Context<{ Variables: Variables }>): Promise<Response> {
136const requestId = crypto.randomUUID();
137251* Handle v1/v2 versions - Base64 encoding
252*/
253async function handleV1V2(
254c: Context<{ Variables: Variables }>,
255requestBody: any,
362* Handle v3/v4/v5 versions - Hash generation for Zenith fingerprint
363*/
364async function handleV3V4V5(
365c: Context<{ Variables: Variables }>,
366requestBody: any,
527}
528529// ==================== UTILITY FUNCTIONS ====================
530531/**
532* Generate hash using Web Crypto API
533*/
534async function generateHash(data: string, algorithm: string): Promise<string> {
535const encoder = new TextEncoder();
536const dataBuffer = encoder.encode(data);
575* Check if timestamp is in valid ISO 8601 format
576*/
577function isValidISO8601(timestamp: string): boolean {
578try {
579const date = new Date(timestamp);
594* Check if timestamp is within acceptable time window (5 minutes)
595*/
596function isTimestampRecent(timestamp: string): boolean {
597try {
598const providedTime = new Date(timestamp).getTime();
610* Format Zod errors for user-friendly error response
611*/
612function formatZodErrors(error: z.ZodError): HashErrorResponse["details"] {
613return error.errors.map((err) => {
614const field = err.path.join(".");
643* Create standardized error response
644*/
645function createHashErrorResponse(
646code: string,
647message: string,
666* Optional info endpoint handler for documentation
667*/
668export async function hashInfo(c: Context): Promise<Response> {
669const currentTime = new Date().toISOString();
670825826/**
827* Hash handler function for use in service router
828* @param c - Hono context with Variables
829* @returns Response with hash result
830*/
831export async function getHash(c: Context<{ Variables: Variables }>): Promise<Response> {
832return await hashData(c);
833}
10} from "../external-apis/firecrawlClient.ts";
1112// Helper function to get error messages
13// In a real project, move this to a shared utility file (e.g., src/utils/error.utils.ts)
14function getLocalErrorMessage(error: unknown): string {
15if (error instanceof Error) return error.message;
16if (typeof error === "string") return error;
26* Handles requests to the Firecrawl scrape API for a single URL.
27*/
28export async function firecrawlScrapeHandler(
29c: Context<{ Variables: Variables }>,
30): Promise<Response> {
50const scrapeInput: ScraperInput = validationResult.data;
5152// Call the Firecrawl API through the client function
53const firecrawlResponse = await fetchFromFirecrawlAPI(scrapeInput);
5489* Handles requests to the Firecrawl map API for discovering URLs on a website.
90*/
91export async function firecrawlMapHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
92try {
93const requestBody = await c.req.json();
108const mapInput: FirecrawlMapInput = validationResult.data;
109110// Call the dedicated map function with validated input
111const firecrawlResponse = await performFirecrawlMap(mapInput);
112
api_ianmenethil_comechoService.ts3 matches
3637/**
38* Echo Service - Handles echo functionality
39* Returns request data for testing and debugging purposes
40*/
112113/**
114* Echo handler function for use in service router
115* @param c - Hono context with Variables
116* @returns Response with echo data
117*/
118export async function echo(c: any): Promise<Response> {
119try {
120const method = c.req.method;
23* @returns Sanitized string
24*/
25function sanitizeInput(input: string): string {
26return input.replace(/[<>\"'&]/g, "").trim();
27}
33* @returns Parsed timestamp filter object
34*/
35function parseTimestampFilters(from?: string, to?: string): { from?: Date; to?: Date } {
36const result: { from?: Date; to?: Date } = {};
3758* @returns Headers as key-value object
59*/
60function extractHeaders(request: Request): Record<string, string> {
61const headers: Record<string, string> = {};
62request.headers.forEach((value, key) => {
71* @returns Response with callback creation result
72*/
73export async function createCallback(c: Context<{ Variables: Variables }>): Promise<Response> {
74const requestId = crypto.randomUUID();
75159* @returns Response with callback records list
160*/
161export async function listCallbacks(c: Context<{ Variables: Variables }>): Promise<Response> {
162const requestId = crypto.randomUUID();
163249* @returns Response with callback record details
250*/
251export async function getCallback(c: Context<{ Variables: Variables }>): Promise<Response> {
252const requestId = crypto.randomUUID();
253316* @returns Response with deletion confirmation
317*/
318export async function deleteCallback(c: Context<{ Variables: Variables }>): Promise<Response> {
319const requestId = crypto.randomUUID();
320
api_ianmenethil_comauthService.ts4 matches
18* Generates and returns a new CSRF token for form protection
19*/
20export function getCsrfToken(c: Context<{ Variables: Variables }>): Response {
21try {
22// Generate a secure CSRF token
73* Returns the current authenticated user from the OAuth session
74*/
75export function getCurrentUser(c: Context<{ Variables: Variables }>): Response {
76try {
77// Get session data from cookie
197* Clears OAuth session cookies and ends the user session
198*/
199export function logout(c: Context<{ Variables: Variables }>): Response {
200try {
201// Get current session for logging
265* Converts API keys to JWT tokens for secure service access
266*/
267export async function exchangeToken(c: Context<{ Variables: Variables }>): Promise<Response> {
268try {
269// Extract token key from header or query parameter
api_ianmenethil_comtavilyClient.ts5 matches
104105// API configuration
106function getTavilyApiKey(): string {
107const key = Deno.env.get("TAVILY_API_KEY") || "";
108if (!key) {
117* Perform a search using the Tavily API.
118*/
119export async function performTavilySearch(input: TavilySearchInput): Promise<unknown> {
120const apiKey = getTavilyApiKey();
121const options = {
148* Perform an extract using the Tavily API.
149*/
150export async function performTavilyExtract(input: TavilyExtractInput): Promise<unknown> {
151const apiKey = getTavilyApiKey();
152186* Perform a crawl using the Tavily API (BETA).
187*/
188export async function performTavilyCrawl(input: TavilyCrawlInput): Promise<unknown> {
189const apiKey = getTavilyApiKey();
190228* Perform a site map using the Tavily API (BETA).
229*/
230export async function performTavilyMap(input: TavilyMapInput): Promise<unknown> {
231const apiKey = getTavilyApiKey();
232