ZenServertest-frontend-client.tsx25 matches
334const [currentNonce, setCurrentNonce] = useState(null);
335const [attemptCount, setAttemptCount] = useState(0);
336const [prefetchedNonce, setPrefetchedNonce] = useState(null);
337const [isPrefetching, setIsPrefetching] = useState(false);
338const [step, setStep] = useState(0);
339const [selectedTour, setSelectedTour] = useState(null);
436437let nonce = '';
438if (prefetchedNonce) {
439console.log('♻️ Using prefetched nonce:', prefetchedNonce);
440nonce = prefetchedNonce;
441setPrefetchedNonce(null);
442setAttemptCount(prev => prev + 1);
443} else {
450};
451452const nonceResponse = await fetch(NONCE_ENDPOINT, {
453method: 'POST',
454headers: {
494console.log('🔍 Fingerprint payload for hash:', fingerprintPayload);
495496const apiResponse = await fetch(HASH_ENDPOINT, {
497method: 'POST',
498headers: {
529console.error('❌ Hash API failed:', msg);
530setIsProcessing(false);
531prefetchNewNonce();
532return;
533}
572console.error('❌ ZenPay payment failed:', msg);
573setIsProcessing(false);
574prefetchNewNonce();
575}
576}, [formData, bookingId, prefetchedNonce, fingerprintPayload]);
577578const prefetchNewNonce = useCallback(async () => {
579if (isPrefetching || attemptCount >= 5) return;
580581setIsPrefetching(true);
582console.log('🔄 Pre-fetching new nonce for retry...');
583584try {
589};
590591const nonceResponse = await fetch(NONCE_ENDPOINT, {
592method: 'POST',
593headers: {
602if (nonceResponse.ok) {
603const nonceData = await nonceResponse.json();
604setPrefetchedNonce(nonceData.nonce);
605console.log('✅ Pre-fetched nonce ready:', nonceData.nonce);
606}
607} catch (e) {
608console.error('⚠️ Failed to pre-fetch nonce:', e);
609} finally {
610setIsPrefetching(false);
611}
612}, [bookingId, formData.email_verify, attemptCount, isPrefetching]);
613614if (step === 0) {
1013]),
10141015isPrefetching && React.createElement('div', {
1016key: 'prefetch-status',
1017className: "mt-4"
1018}, React.createElement(Alert, {
1081},
1082className: "w-full",
1083disabled: isPrefetching
1084}, isPrefetching ? 'Preparing retry...' : (prefetchedNonce ? 'Try Again (Ready)' : 'Try Again')),
1085React.createElement(Button, {
1086key: 'refresh',
ZenServerDOCUMENTATION.md9 matches
178S->>DB: Validate Token (exists, not expired)
179S->>DB: Get Booking ID from Token
180S->>DB: Fetch Booking Details
181S-->>U: Return Booking Information
182```
254```javascript
255// Frontend Usage
256const response = await fetch(`/booking/${token}`);
257const { booking } = await response.json();
258```
265```javascript
266// Admin Usage
267const response = await fetch('/api/generate-booking-token', {
268method: 'POST',
269headers: {
285```javascript
286// Frontend Usage
287const response = await fetch('/api/create-payment-nonce', {
288method: 'POST',
289headers: { 'Content-Type': 'application/json' },
300```javascript
301// Frontend Usage - CRITICAL SECURITY
302const response = await fetch('/api/create-payment-hash', {
303method: 'POST',
304headers: {
325```javascript
326// Frontend Usage - After Payment Failure
327const response = await fetch('/api/v1/payment/refresh', {
328method: 'POST',
329headers: { 'Content-Type': 'application/json' },
342```javascript
343// Frontend Usage
344const response = await fetch('/api/v1/turnstile/verify', {
345method: 'POST',
346headers: { 'Content-Type': 'application/json' },
388try {
389// Step 1: Generate nonce
390const nonceResponse = await fetch('/api/create-payment-nonce', {
391method: 'POST',
392headers: { 'Content-Type': 'application/json' },
396397// Step 2: Create payment hash with dual authentication
398const hashResponse = await fetch('/api/create-payment-hash', {
399method: 'POST',
400headers: {
42}
4344const verificationResponse = await fetch('https://challenges.cloudflare.com/turnstile/v0/siteverify', {
45method: 'POST',
46headers: {
ZenBackendtest-frontend-client.tsx25 matches
334const [currentNonce, setCurrentNonce] = useState(null);
335const [attemptCount, setAttemptCount] = useState(0);
336const [prefetchedNonce, setPrefetchedNonce] = useState(null);
337const [isPrefetching, setIsPrefetching] = useState(false);
338const [step, setStep] = useState(0);
339const [selectedTour, setSelectedTour] = useState(null);
436437let nonce = '';
438if (prefetchedNonce) {
439console.log('♻️ Using prefetched nonce:', prefetchedNonce);
440nonce = prefetchedNonce;
441setPrefetchedNonce(null);
442setAttemptCount(prev => prev + 1);
443} else {
450};
451452const nonceResponse = await fetch(NONCE_ENDPOINT, {
453method: 'POST',
454headers: {
494console.log('🔍 Fingerprint payload for hash:', fingerprintPayload);
495496const apiResponse = await fetch(HASH_ENDPOINT, {
497method: 'POST',
498headers: {
529console.error('❌ Hash API failed:', msg);
530setIsProcessing(false);
531prefetchNewNonce();
532return;
533}
572console.error('❌ ZenPay payment failed:', msg);
573setIsProcessing(false);
574prefetchNewNonce();
575}
576}, [formData, bookingId, prefetchedNonce, fingerprintPayload]);
577578const prefetchNewNonce = useCallback(async () => {
579if (isPrefetching || attemptCount >= 5) return;
580581setIsPrefetching(true);
582console.log('🔄 Pre-fetching new nonce for retry...');
583584try {
589};
590591const nonceResponse = await fetch(NONCE_ENDPOINT, {
592method: 'POST',
593headers: {
602if (nonceResponse.ok) {
603const nonceData = await nonceResponse.json();
604setPrefetchedNonce(nonceData.nonce);
605console.log('✅ Pre-fetched nonce ready:', nonceData.nonce);
606}
607} catch (e) {
608console.error('⚠️ Failed to pre-fetch nonce:', e);
609} finally {
610setIsPrefetching(false);
611}
612}, [bookingId, formData.email_verify, attemptCount, isPrefetching]);
613614if (step === 0) {
1013]),
10141015isPrefetching && React.createElement('div', {
1016key: 'prefetch-status',
1017className: "mt-4"
1018}, React.createElement(Alert, {
1081},
1082className: "w-full",
1083disabled: isPrefetching
1084}, isPrefetching ? 'Preparing retry...' : (prefetchedNonce ? 'Try Again (Ready)' : 'Try Again')),
1085React.createElement(Button, {
1086key: 'refresh',
ZenBackendDOCUMENTATION.md9 matches
178S->>DB: Validate Token (exists, not expired)
179S->>DB: Get Booking ID from Token
180S->>DB: Fetch Booking Details
181S-->>U: Return Booking Information
182```
254```javascript
255// Frontend Usage
256const response = await fetch(`/booking/${token}`);
257const { booking } = await response.json();
258```
265```javascript
266// Admin Usage
267const response = await fetch('/api/generate-booking-token', {
268method: 'POST',
269headers: {
285```javascript
286// Frontend Usage
287const response = await fetch('/api/create-payment-nonce', {
288method: 'POST',
289headers: { 'Content-Type': 'application/json' },
300```javascript
301// Frontend Usage - CRITICAL SECURITY
302const response = await fetch('/api/create-payment-hash', {
303method: 'POST',
304headers: {
325```javascript
326// Frontend Usage - After Payment Failure
327const response = await fetch('/api/v1/payment/refresh', {
328method: 'POST',
329headers: { 'Content-Type': 'application/json' },
342```javascript
343// Frontend Usage
344const response = await fetch('/api/v1/turnstile/verify', {
345method: 'POST',
346headers: { 'Content-Type': 'application/json' },
388try {
389// Step 1: Generate nonce
390const nonceResponse = await fetch('/api/create-payment-nonce', {
391method: 'POST',
392headers: { 'Content-Type': 'application/json' },
396397// Step 2: Create payment hash with dual authentication
398const hashResponse = await fetch('/api/create-payment-hash', {
399method: 'POST',
400headers: {
ESP32-FirmwareFlasherapi.ts14 matches
1314/**
15* Generic fetch wrapper with error handling
16*/
17private async fetchWithErrorHandling<T>(
18endpoint: string,
19options: RequestInit = {}
20): Promise<{ success: boolean; data?: T; error?: string }> {
21try {
22const response = await fetch(`${this.baseUrl}${endpoint}`, {
23...options,
24headers: {
51*/
52async getFirmwareList(): Promise<{ success: boolean; data?: FirmwareInfo[]; error?: string }> {
53return this.fetchWithErrorHandling<FirmwareInfo[]>('/api/firmware');
54}
5558*/
59async getFirmwareByCategory(category: string): Promise<{ success: boolean; data?: FirmwareInfo[]; error?: string }> {
60return this.fetchWithErrorHandling<FirmwareInfo[]>(`/api/firmware/category/${encodeURIComponent(category)}`);
61}
6265*/
66async searchFirmware(query: string): Promise<{ success: boolean; data?: FirmwareInfo[]; error?: string }> {
67return this.fetchWithErrorHandling<FirmwareInfo[]>(`/api/firmware/search?q=${encodeURIComponent(query)}`);
68}
6972*/
73async getFirmwareInfo(name: string): Promise<{ success: boolean; data?: FirmwareInfo; error?: string }> {
74return this.fetchWithErrorHandling<FirmwareInfo>(`/api/firmware/${encodeURIComponent(name)}/info`);
75}
7680async downloadFirmware(name: string): Promise<{ success: boolean; data?: ArrayBuffer; error?: string }> {
81try {
82const response = await fetch(`${this.baseUrl}/api/firmware/${encodeURIComponent(name)}/download`);
83
84if (!response.ok) {
113formData.append('chipType', chipType);
114115const response = await fetch(`${this.baseUrl}/api/serial/convert`, {
116method: 'POST',
117body: formData,
145formData.append('elf', elfFile);
146147const response = await fetch(`${this.baseUrl}/api/serial/validate`, {
148method: 'POST',
149body: formData,
173*/
174async getChipTypes(): Promise<{ success: boolean; data?: string[]; error?: string }> {
175return this.fetchWithErrorHandling<string[]>('/api/serial/chip-types');
176}
177180*/
181async getDeviceConfig(chipType: string): Promise<{ success: boolean; data?: any; error?: string }> {
182return this.fetchWithErrorHandling(`/api/serial/device-config/${encodeURIComponent(chipType)}`);
183}
184187*/
188async getServiceStatus(): Promise<{ success: boolean; data?: any; error?: string }> {
189return this.fetchWithErrorHandling('/api/serial/status');
190}
191194*/
195async getFirmwareStats(): Promise<{ success: boolean; data?: any; error?: string }> {
196return this.fetchWithErrorHandling('/api/firmware/stats');
197}
198}
ESP32-FirmwareFlasherindex.ts2 matches
8788// For non-API routes, serve the main app (SPA routing)
89return staticRoutes.fetch(new Request(c.req.url.replace(path, "/")));
90});
91128129// Export the app for Val Town
130export default app.fetch;
173174try {
175const response = await fetch(API_ENDPOINT, {
176method: 'POST',
177headers: { 'Content-Type': 'application/json' },
183applyUpdates(data);
184} catch (error) {
185console.error('Fetch error:', error);
186reasoningEl.textContent = 'An error occurred. The artistic muse must be sleeping. Please try again.';
187}
300});
301302export default app.fetch;
Astra-Productionmain.ts2 matches
3334if (path === "/users" && method === "GET") {
35const res = await fetch(`${ASTRA_URL}/api/rest/v2/namespaces/${KEYSPACE}/collections/${COLLECTION}`, {
36method: "GET",
37headers,
44try {
45const body = await req.json();
46const res = await fetch(`${ASTRA_URL}/api/rest/v2/namespaces/${KEYSPACE}/collections/${COLLECTION}`, {
47method: "POST",
48headers,
wordstreammain.tsx1 match
199try {
200statusDisplay.textContent = 'Requesting next journey...';
201const response = await fetch(\`\${API_URL}?action=getJourney&after_id=\${lastSeenJourneyId}\`, {
202method: 'POST'
203});