1/**
2* spotify.auth.service.ts — Spotify OAuth authentication service handlers.
3* Implements OpenAPI operations using existing middleware and services.
4*/
5292async function fetchSpotifyUserInfo(accessToken: string) {
293try {
294const userRequest = await fetch("https://api.spotify.com/v1/me", {
295headers: {
296"Authorization": `Bearer ${accessToken}`,
api_ianmenethil_comindex.ts1 match
1// F:\zApps\valtown.servers\APIServer\src\handlers\oauth\index.ts
23export { getGoogleOAuthURL, handleGoogleCallback } from "./googleAuthService.ts";
1// F:\zApps\valtown.servers\APIServer\src\handlers\oauth\google.auth.service.ts
2/**
3* auth.service.ts — OAuth authentication service handlers.
4* Implements OpenAPI operations using existing middleware and services.
5*/
6
1// F:\zApps\valtown.servers\APIServer\src\handlers\oauth\github.auth.service.ts
2/**
3* github.auth.service.ts — GitHub OAuth authentication service handlers.
4* Implements OpenAPI operations using existing middleware and services.
5*/
6296"Authorization": `Bearer ${accessToken}`,
297"Accept": "application/vnd.github.v3+json",
298"User-Agent": "Val.town-API-Server/2.0",
299},
300});
348async function fetchGitHubUserEmail(accessToken: string) {
349try {
350const emailRequest = await fetch("https://api.github.com/user/emails", {
351headers: {
352"Authorization": `Bearer ${accessToken}`,
353"Accept": "application/vnd.github.v3+json",
354"User-Agent": "Val.town-API-Server/2.0",
355},
356});
api_ianmenethil_cominfoService.ts19 matches
45// You can store these in environment variables or a config file
6const API_VERSION = Deno.env.get("API_VERSION") || "1.0.0";
7const API_BUILD = Deno.env.get("API_BUILD") || "unknown";
8const API_ENV = Deno.env.get("API_ENV") || "development";
910/**
11* Service for providing API information and version details
12*/
13export class InfoService {
14/**
15* Get basic API information
16* @returns API info object with status and basic metadata
17*/
18getApiInfo() {
19return {
20success: true,
21name: "ValTown API Server",
22version: API_VERSION,
23status: "operational",
24environment: API_ENV,
25timestamp: getCurrentDateInSydney(),
26uptime: null, // Note: Deno doesn't have process.uptime()
29swagger: "/v1/docs",
30redoc: "/v1/redoc",
31openapi: "/v1/openapi.json",
32},
33external: {
47success: true,
48version: {
49api: API_VERSION,
50build: API_BUILD,
51environment: API_ENV,
52node: Deno.version.deno,
53v8: Deno.version.v8,
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();
94return c.json(info);
95} catch (error) {
96const errorResponse = infoService.createErrorResponse(
97error instanceof Error ? error.message : "Failed to retrieve API information",
98);
99return c.json(errorResponse, 500);
api_ianmenethil_comhashService.ts20 matches
31*/
32export const ZenithHashRequestSchema = z.object({
33apiKey: z.string().min(1, "API key cannot be empty"),
34username: z.string().min(1, "Username cannot be empty"),
35password: z.string().min(1, "Password cannot be empty"),
6061export const AuthenticatedZenithHashRequestSchema = z.object({
62apiKey: z.string().min(1, "API key cannot be empty"),
63username: z.string().optional(),
64password: z.string().optional(),
128*
129* This endpoint helps clients generate the required fingerprint
130* for Zenith Payments API integration without exposing credentials.
131*
132* The generated hash should be used as the 'fingerprint' field
456457// Create hash string according to Zenith format
458const { apiKey, mode, paymentAmount, merchantUniquePaymentId, timestamp } = validatedData;
459const hashString =
460`${apiKey}|${username}|${password}|${mode}|${paymentAmount}|${merchantUniquePaymentId}|${timestamp}`;
461462// Get algorithm
530531/**
532* Generate hash using Web Crypto API
533*/
534async function generateHash(data: string, algorithm: string): Promise<string> {
547break;
548case "SHA3-512":
549// SHA3-512 is not natively supported in Web Crypto API
550// Try it first, fallback to SHA-512
551try {
626suggestion =
627'Payment amount must be in cents/pence as whole numbers only. For $12.34, use "1234". For $100.00, use "10000".';
628} else if (field === "apiKey") {
629suggestion = "API key should be provided by Zenith Payments";
630}
631672673return await c.json({
674purpose: "Generate fingerprint hash for Zenith Payments API",
675endpoint: "/v1/hash",
676current_time: currentTime,
699description: "SHA-1 hash of concatenated fields",
700algorithm: "SHA-1",
701use_case: "Zenith API v3 integration",
702warning: "SHA-1 is deprecated for security reasons, use v5",
703example_request: {
704apiKey: "test_api_key",
705username: "merchant_user",
706password: "merchant_pass",
715description: "SHA-512 hash of concatenated fields",
716algorithm: "SHA-512",
717use_case: "Zenith API v4 integration (recommended by Zenith)",
718example_request: {
719apiKey: "test_api_key",
720username: "merchant_user",
721password: "merchant_pass",
732use_case: "Most secure option for future compatibility",
733example_request: {
734apiKey: "test_api_key",
735username: "merchant_user",
736password: "merchant_pass",
745v3_v4_v5_format: {
746description: "Concatenated string format for hashing",
747format: "apiKey|username|password|mode|paymentAmount|merchantUniquePaymentId|timestamp",
748example: "test_api_key|merchant_user|merchant_pass|0|10050|INV-2025-001|2025-06-15T19:42:13Z",
749},
750required_fields: {
755v3_v4_v5: {
756public_access: [
757"apiKey",
758"username",
759"password",
764],
765authenticated_access: [
766"apiKey",
767"username (optional)",
768"password (optional)",
786},
787authenticated_access: {
788description: "Requires API key or session authentication",
789benefit: "Username and password can use environment defaults if not provided in request",
790},
2import type { HonoVariables as Variables } from "@/types/index.ts";
3import {
4fetchFromFirecrawlAPI,
5FirecrawlMapInput,
6FirecrawlMapInputSchema,
7performFirecrawlMap,
8ScraperInput,
9ScraperSchema,
10} from "../external-apis/firecrawlClient.ts";
1112// Helper function to get error messages
24* firecrawlScrape operation handler
25* POST /v1/firecrawl/scrape
26* Handles requests to the Firecrawl scrape API for a single URL.
27*/
28export async function firecrawlScrapeHandler(
50const scrapeInput: ScraperInput = validationResult.data;
5152// Call the Firecrawl API through the client function
53const firecrawlResponse = await fetchFromFirecrawlAPI(scrapeInput);
5455// Type assertion to ensure it's a valid JSON value
6162// Handle specific error cases
63if (message.includes("Configuration error: invalid or missing FIRECRAWL_API_KEY")) {
64return c.json({
65success: false,
66error: "Firecrawl API configuration error. Please contact support.",
67}, 503); // Service Unavailable
68}
71return c.json({
72success: false,
73error: "Firecrawl API returned an error during scrape.",
74details: error.message,
75}, 502); // Bad Gateway
87* firecrawlMap operation handler
88* POST /v1/firecrawl/map
89* Handles requests to the Firecrawl map API for discovering URLs on a website.
90*/
91export async function firecrawlMapHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
93const requestBody = await c.req.json();
9495// Validate the request body against the FirecrawlMapInputSchema
96const validationResult = FirecrawlMapInputSchema.safeParse(requestBody);
9798if (!validationResult.success) {
106107// Use the validated data with explicit type
108const mapInput: FirecrawlMapInput = validationResult.data;
109110// Call the dedicated map function with validated input
111const firecrawlResponse = await performFirecrawlMap(mapInput);
112113// Type assertion to ensure it's a valid JSON value
119120// Handle specific error cases
121if (message.includes("Configuration error: invalid or missing FIRECRAWL_API_KEY")) {
122return c.json({
123success: false,
124error: "Firecrawl API configuration error. Please contact support.",
125}, 503); // Service Unavailable
126}
129return c.json({
130success: false,
131error: "Firecrawl API returned an error during map operation.",
132details: error.message,
133}, 502); // Bad Gateway
1// F:\zApps\valtown.servers\APIServer\src\handlers\echo.service.ts
2import { getCurrentDateInSydney } from "@/utils/dateUtils.ts";
3
1/**
2* callbackService.ts — Callback endpoint handlers for managing callback records with CRUD operations.
3* Provides RESTful API for creating, listing, viewing, and deleting callback entries.
4*/
5
api_ianmenethil_comauthService.ts10 matches
263/**
264* Exchange Token - implements exchangeToken operation
265* Converts API keys to JWT tokens for secure service access
266*/
267export async function exchangeToken(c: Context<{ Variables: Variables }>): Promise<Response> {
287// Validate token key against configured keys
288const validKeys = [
289AUTH_CONFIG.methods.API_KEY.keys.internal,
290AUTH_CONFIG.methods.API_KEY.keys.serviceToService,
291];
292315// Determine service type based on token key
316let sourceService = "unknown-service";
317let scope = "api:read";
318319if (tokenKey === AUTH_CONFIG.methods.API_KEY.keys.internal) {
320sourceService = "internal-service";
321scope = "internal-service api:read api:write";
322} else if (tokenKey === AUTH_CONFIG.methods.API_KEY.keys.serviceToService) {
323sourceService = "service-to-service";
324scope = "s2s-service api:read api:write";
325}
326328const jwtToken = await internalJwtService.generateInternalToken(c, {
329sourceService,
330targetEndpoint: "api-access",
331scope,
332expiryMinutes: 60, // 1 hour token
355usage: {
356header: "Authorization: Bearer " + jwtToken,
357description: "Use this JWT token for API authentication",
358},
359},