mirror of github:amycatgirl/amycatgirl.github.io
0
fork

Configure Feed

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

feat: experimental webvh support

Completely untested. I haven't come across any did:webvh documents in
the wild just yet, but I plan moving DID resolution things to it's own
separate library in the future, so might as well start supporting
other non-atproto-blessed DID methods!

Spec: https://identity.foundation/didwebvh/v1.0

Signed-off-by: Amy <amy+git@amogus.cloud>

Amy 259f105c eb1b7d12

+39 -5
+39 -5
fallback.lisp
··· 29 29 (t (list accessor-fn (construct (car ys) (cdr ys)) y))))) 30 30 (construct (car rev-indicators) (cdr rev-indicators))))) 31 31 32 + (defun parse-json-lines (file) 33 + "Parse a jsonl file. `DOCUMENT' here refers to the file being 34 + parsed. See https://jsonlines.org/ for spec." 35 + (loop for line from (uiop:split-string file :separator '(\#newline)) 36 + collecting (yason:parse-json line :object-as :plist :object-key-fn #'keywordize))) 37 + 32 38 ;; Git 33 39 (defun git-add (&rest files) 34 40 (run-command `("git" "add" ,@files))) ··· 61 67 (defun resolve-did-document--plc (did) 62 68 (make-request (format nil "https://plc.directory/~a" did))) 63 69 70 + (defun did->https (did) 71 + "Convert `did' to a proper http form." 72 + (let* ((method (get-did-method did)) 73 + (loq (document-location (subseq did (length (format nil "did:~A:" method)))))) 74 + (concatenate 'string 75 + "https://" 76 + loq))) 77 + 64 78 (defun resolve-did-document--web (did) 65 79 "Resolve a DID document via DID:WEB method. 66 - See https://w3c-ccg.github.io/did-method-web/ for specification details." 67 - (let* ((document-location (subseq did (length "did:web:"))) 68 - (qualified-path (concatenate 'string "https://" document-location "/.well-known/did.json")) 80 + See https://w3c-ccg.github.io/did-method-web/ for specification 81 + details." 82 + (let* ((qualified-path (concatenate 'string (did->http did) "/.well-known/did.json")) 69 83 (document (make-request qualified-path))) 70 84 (if (equal (getf document :id) did) 71 85 document 72 86 (error "Could not resolve document from did:web ~S" did)))) 73 87 88 + (defun webvh-get-latest-document-unsafe (log) 89 + "Get the latest DID document from the provided webvh `LOG'. 90 + Does not ensure integrity and does not process the entire log in order." 91 + (getf :state (last log))) 92 + 93 + (defun resolve-did-document--webvh (did) 94 + "Resolve a DID document via did:webvh method. This is not up to spec, 95 + it does not check whether the encoded path is valid. 96 + See https://identity.foundation/didwebvh/v1.0/#read-resolve for spec 97 + details." 98 + (let* ((qualified-path (concatenate 'string 99 + "https://" 100 + (did->http did) 101 + "/.well-known/did.jsonl")) 102 + (log-json-lines (make-request qualified-path)) 103 + (log (parse-json-lines log-json-lines))) 104 + (webvh-get-latest-document-unsafe log))) 105 + 74 106 (defun get-did-method (did) 75 - (cl-ppcre:register-groups-bind (method) ("^did:([a-z]+):[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$" did) 76 - method)) 107 + (cl-ppcre:register-groups-bind (method) 108 + ("^did:([a-z]+):[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$" did) 109 + method)) 77 110 78 111 (defun resolve-pds (did) 79 112 "Resolve a PDS by DID." ··· 81 114 (document (case did-method 82 115 ("web" (resolve-did-document--web did)) 83 116 ("plc" (resolve-did-document--plc did)) 117 + ("webvh" (resolve-did-document-webvh did)) 84 118 (_ (error "Unsuported DID method ~S" did-method)))) 85 119 (services (getf document :service))) 86 120 (getf (find-if (lambda (service)