the universal sandbox runtime for agents and humans. pocketenv.io
sandbox openclaw agent claude-code vercel-sandbox deno-sandbox cloudflare-sandbox atproto sprites daytona
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 100 lines 3.0 kB view raw
1/** 2 * Welcome to Cloudflare Workers! This is your first worker. 3 * 4 * - Run `npm run dev` in your terminal to start a development server 5 * - Open a browser tab at http://localhost:8787/ to see your worker in action 6 * - Run `npm run deploy` to publish your worker 7 * 8 * Bind resources to your worker in `wrangler.json`. After adding bindings, a type definition for the 9 * `Env` object can be regenerated with `npm run cf-typegen`. 10 * 11 * Learn more at https://developers.cloudflare.com/workers/ 12 */ 13 14const metadata = { 15 redirect_uris: ['https://pocketenv.io/oauth/callback'], 16 response_types: ['code'], 17 grant_types: ['authorization_code', 'refresh_token'], 18 scope: 'atproto repo:io.pocketenv.sandbox repo:sh.tangled.repo repo:sh.tangled.string repo:sh.tangled.pull repo:sh.tangled.pull.comment', 19 token_endpoint_auth_method: 'private_key_jwt', 20 token_endpoint_auth_signing_alg: 'ES256', 21 jwks_uri: 'https://pocketenv.io/jwks.json', 22 application_type: 'web', 23 subject_type: 'public', 24 authorization_signed_response_alg: 'RS256', 25 client_id: 'https://pocketenv.io/oauth-client-metadata.json', 26 client_name: 'Pocketenv', 27 client_uri: 'https://pocketenv.io', 28 dpop_bound_access_tokens: true, 29}; 30 31const jwks = { 32 keys: [ 33 { 34 kty: 'EC', 35 alg: 'ES256', 36 kid: '06b0a81c-7950-4dbe-8ddc-022a3e4997d8', 37 crv: 'P-256', 38 x: 'gROA2cWzloO6YxQhyHsiOEAZNwdql9vnjBjUGYAxGfU', 39 y: 'Q5AN7_kj_lCZrnbDlr7QEdemkeNWx7rBkKjBF-ual5U', 40 }, 41 { 42 kty: 'EC', 43 alg: 'ES256', 44 kid: '2867d54f-56f8-4d02-adb7-6ef75142c8cc', 45 crv: 'P-256', 46 x: 'wf-Nx8kx6rH30CS0ILWHmSYB12v3v20ucrkNNPdgUqI', 47 y: 'LzCJEhzltf4mfeW2ju1rw-mYL273pKF2FJKEqsPaFNM', 48 }, 49 { 50 kty: 'EC', 51 alg: 'ES256', 52 kid: '0b671ab1-d51d-458d-bede-4e8852ec5001', 53 crv: 'P-256', 54 x: 'QshM55rfsX0SLZl9DuDpC_u3IquZE-BCXFS4A2-Vi9o', 55 y: '07cPlcILsk6i8t7FfeZcjG_JFuSom8q4eP7CZJ4ntsU', 56 }, 57 ], 58}; 59 60export default { 61 async fetch(request, env, ctx): Promise<Response> { 62 const url = new URL(request.url); 63 let redirectToApi = false; 64 65 const API_ROUTES = ['/login', '/profile', '/token', '/oauth-client-metadata.json', '/jwks.json']; 66 67 console.log('Request URL:', url.pathname, url.pathname === '/client-metadata.json'); 68 69 if (url.pathname === '/oauth-client-metadata.json') { 70 return Response.json(metadata); 71 } 72 73 if (url.pathname === '/jwks.json') { 74 return Response.json(jwks); 75 } 76 77 if ( 78 API_ROUTES.includes(url.pathname) || 79 url.pathname.startsWith('/oauth/callback') || 80 url.pathname.startsWith('/xrpc') || 81 url.pathname.startsWith('/ssh') || 82 url.pathname.startsWith('/pty') || 83 url.pathname.startsWith('/tty') 84 ) { 85 redirectToApi = true; 86 } 87 88 if (redirectToApi) { 89 const proxyUrl = new URL(request.url); 90 proxyUrl.host = 'api.pocketenv.io'; 91 proxyUrl.hostname = 'api.pocketenv.io'; 92 return fetch(proxyUrl, request) as any; 93 } 94 95 const proxyUrl = new URL(request.url); 96 proxyUrl.host = 'pocketenv.pages.dev'; 97 proxyUrl.hostname = 'pocketenv.pages.dev'; 98 return fetch(proxyUrl, request); 99 }, 100} satisfies ExportedHandler<Env>;