this repo has no description
0
fork

Configure Feed

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

day six and some hacks

+31 -16
+21 -14
shared/challenges_markdown/six/part_two.md
··· 1 - ## XRPC Service Proxying 1 + Most atproto endpoints use something called [XRPC](https://atproto.com/specs/xrpc), you've probably seen it in something 2 + like this URL to get a Bluesky profile of 3 + someone [https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=jcsalterego.bsky.social](https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=jcsalterego.bsky.social). 4 + In short XRPC is a way to write HTTP endpoints that can be defined by 5 + a [lexicon schema](https://atproto.com/specs/lexicon#query-and-procedure-http-api) so you know what data is returned 6 + from the endpoint, what type of request, parmeters, errors, etc. And since this is all defined in a lexicon schema you 7 + can generate a client from it as well. 2 8 3 - Now that you can create a serviceAuth JWT, let's use it in an actual XRPC request. 9 + With XRPC you can also do something called [Service Proxying](https://atproto.com/specs/xrpc#service-proxying) which 10 + means if you call the XRPC endpoint on your PDS while authenicated with the `atproto-proxy` header with the did and the 11 + service like so `did:web:labeler.example.com#atproto_labeler` it looks up the service and proxies the request to the 12 + service with a serviceAuth JWT set as the bearer. 4 13 5 - Make an HTTP GET request to our XRPC endpoint with your JWT in the `Authorization` header: 14 + For example, this is how Bluesky DMs work 6 15 7 - ``` 8 - GET https://{{service_did_domain}}/xrpc/codes.advent.challenge.getDay6Code 9 - Authorization: Bearer <your-jwt> 10 - ``` 16 + - On requests to the PDS for DMs there is an `atproto-proxy` header that looks like 17 + `did:web:api.bsky.chat#bsky_chat`. 18 + - When you call the PDS it takes the URL from the `did:web` to find a did doc at 19 + `https://api.bsky.chat/.well-known/did.json` 20 + - It then looks up the service `bsky_chat` in the did doc andthen proxies the web request to the `serviceEndpoint` 21 + listed there. 22 + - It then proxies the request to the service with the serviceAuth JWT set as the bearer. 11 23 12 - Your JWT for this request must have: 13 - - `iss`: Your DID 14 - - `aud`: `{{service_did}}` 15 - - `lxm`: `{{lxm_part_two}}` 16 - - `exp`: A UNIX timestamp in the future 17 - 18 - The response will contain a JSON object with your verification code. Paste that code below. 24 + Today's part two is for you to make a XRPC query request to the `codes.advent.challenge.getCode` XRPC endpoint to the 25 + service `did:web:{{service_did_domain}}#advent` to get your verification code.
+5 -2
web/src/main.rs
··· 288 288 ) 289 289 .route( 290 290 "/day/3/upload-car", 291 - post(handlers::custom::day_three::inspect_car) // 2MB max for default axum 291 + post(handlers::custom::day_three::inspect_car), // 2MB max for default axum 292 292 ) 293 293 .route( 294 294 "/day/5/{user_did}", 295 295 get(handlers::custom::day_five::create_record_handler), 296 296 ) 297 297 .route( 298 - "/xrpc/codes.advent.challenge.getChallengeCode", 298 + "/xrpc/codes.advent.challenge.getCode", 299 299 get(handlers::custom::day_six::xrpc_handler), 300 300 ) 301 301 .route( ··· 358 358 .map(|(_, s)| s) 359 359 .unwrap_or(&CompletionStatus::None); 360 360 if *prev_status == CompletionStatus::Both { 361 + unlocked.push(window[1]); 362 + } else if (prev == 4 || prev == 5) && *prev_status == CompletionStatus::PartOne { 363 + //HACK hardcoded for the workshop since we don't have a part 2 for day 4 361 364 unlocked.push(window[1]); 362 365 } else { 363 366 break;
+5
web/src/unlock.rs
··· 63 63 .map(|(_, s)| s) 64 64 .unwrap_or(&CompletionStatus::None); 65 65 66 + //HACK hardcoded for the workshop since we don't have a part 2 for day 4 67 + if (pos == 4 || pos == 5) && *prev_status == CompletionStatus::PartOne { 68 + return next.run(request).await; 69 + } 70 + 66 71 if *prev_status != CompletionStatus::Both { 67 72 return ( 68 73 http::StatusCode::FORBIDDEN,