blob: 2dc9edc1e321ffc18c7d76e0f6f174549c81b514 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
|
(define-module (webid-oidc errors)
#:use-module ((webid-oidc stubs) #:prefix stubs:)
#:use-module (ice-9 exceptions)
#:use-module (ice-9 optargs)
#:use-module (ice-9 i18n)
#:use-module (srfi srfi-19)
#:use-module (web uri)
#:use-module (web response))
(define (G_ text)
(let ((out (gettext text)))
(if (string=? out text)
;; No translation, disambiguate
(car (reverse (string-split text #\|)))
out)))
;; This is a collection of all errors that can happen, and a function
;; to log them.
(define-public ¬-base64
(make-exception-type
'¬-base64
&external-error
'(value cause)))
(define-public (raise-not-base64 value cause)
(raise-exception
((record-constructor ¬-base64) value cause)))
(define-public ¬-json
(make-exception-type
'¬-json
&external-error
'(value cause)))
(define-public (raise-not-json value cause)
(raise-exception
((record-constructor ¬-json) value cause)))
(define-public ¬-turtle
(make-exception-type
'¬-turtle
&external-error
'(value cause)))
(define-public (raise-not-turtle value cause)
(raise-exception
((record-constructor ¬-turtle) value cause)))
(define-public &unsupported-crv
(make-exception-type
'&unsupported-crv
&external-error
'(crv)))
(define-public (raise-unsupported-crv crv)
(raise-exception
((record-constructor &unsupported-crv) crv)))
(define-public ¬-a-jwk
(make-exception-type
'¬-a-jwk
&external-error
'(value cause)))
(define-public (raise-not-a-jwk value cause)
(raise-exception
((record-constructor ¬-a-jwk) value cause)))
(define-public ¬-a-public-jwk
(make-exception-type
'¬-a-public-jwk
&external-error
'(value cause)))
(define-public (raise-not-a-public-jwk value cause)
(raise-exception
((record-constructor ¬-a-public-jwk) value cause)))
(define-public ¬-a-private-jwk
(make-exception-type
'¬-a-private-jwk
&external-error
'(value cause)))
(define-public (raise-not-a-private-jwk value cause)
(raise-exception
((record-constructor ¬-a-private-jwk) value cause)))
(define-public ¬-a-jwks
(make-exception-type
'¬-a-jwks
&external-error
'(value cause)))
(define-public (raise-not-a-jwks value cause)
(raise-exception
((record-constructor ¬-a-jwks) value cause)))
(define-public &unsupported-alg
(make-exception-type
'&unsupported-alg
&external-error
'(value)))
(define-public (raise-unsupported-alg value)
(raise-exception
((record-constructor &unsupported-alg) value)))
(define-public &invalid-signature
(make-exception-type
'&invalid-signature
&external-error
'(key payload signature)))
(define-public (raise-invalid-signature key payload signature)
(raise-exception
((record-constructor &invalid-signature) key payload signature)))
(define-public ¬-a-jws-header
(make-exception-type
'¬-a-jws-header
&external-error
'(value cause)))
(define-public (raise-not-a-jws-header value cause)
(raise-exception
((record-constructor ¬-a-jws-header) value cause)))
(define-public ¬-a-jws-payload
(make-exception-type
'¬-a-jws-payload
&external-error
'(value cause)))
(define-public (raise-not-a-jws-payload value cause)
(raise-exception
((record-constructor ¬-a-jws-payload) value cause)))
(define-public ¬-a-jws
(make-exception-type
'¬-a-jws
&external-error
'(value cause)))
(define-public (raise-not-a-jws value cause)
(raise-exception
((record-constructor ¬-a-jws-payload) value cause)))
(define-public ¬-in-3-parts
(make-exception-type
'¬-in-3-parts
&external-error
'(string separator)))
(define-public (raise-not-in-3-parts string separator)
(raise-exception
((record-constructor ¬-in-3-parts) string separator)))
(define-public &missing-alist-key
(make-exception-type
'&missing-alist-key
&external-error
'(value key)))
(define-public (raise-missing-alist-key value key)
(raise-exception
((record-constructor &missing-alist-key) value key)))
(define-public &no-matching-key
(make-exception-type
'&no-matching-key
&external-error
'(candidates alg payload signature other-problems)))
(define-public (raise-no-matching-key candidates alg payload signature)
(raise-exception
((record-constructor &no-matching-key) candidates alg payload signature)))
(define-public &cannot-decode-jws
(make-exception-type
'&cannot-decode-jws
&external-error
'(value cause)))
(define-public (raise-cannot-decode-jws value cause)
(raise-exception
((record-constructor &cannot-decode-jws) value cause)))
(define-public &cannot-encode-jws
(make-exception-type
'&cannot-encode-jws
&external-error
'(jws key cause)))
(define-public (raise-cannot-encode-jws jws key cause)
(raise-exception
((record-constructor &cannot-encode-jws) jws key cause)))
(define-public &request-failed-unexpectedly
(make-exception-type
'&request-failed-unexpectedly
&external-error
'(response-code response-reason-phrase)))
(define-public (raise-request-failed-unexpectedly
response-code response-reason-phrase)
(raise-exception
((record-constructor &request-failed-unexpectedly)
response-code response-reason-phrase)))
(define-public &unexpected-header-value
(make-exception-type
'&unexpected-header-value
&external-error
'(header value)))
(define-public (raise-unexpected-header-value header value)
(raise-exception
((record-constructor &unexpected-header-value) header value)))
(define-public &unexpected-response
(make-exception-type
'&unexpected-response
&external-error
'(response cause)))
(define-public (raise-unexpected-response response cause)
(raise-exception
((record-constructor &unexpected-response) response cause)))
(define-public ¬-an-oidc-configuration
(make-exception-type
'¬-an-oidc-configuration
&external-error
'(value cause)))
(define-public (raise-not-an-oidc-configuration value cause)
(raise-exception
((record-constructor ¬-an-oidc-configuration) value cause)))
(define-public &incorrect-webid-field
(make-exception-type
'&incorrect-webid-field
&external-error
'(value)))
(define-public (raise-incorrect-webid-field value)
(raise-exception
((record-constructor &incorrect-webid-field) value)))
(define-public &incorrect-iss-field
(make-exception-type
'&incorrect-iss-field
&external-error
'(value)))
(define-public (raise-incorrect-iss-field value)
(raise-exception
((record-constructor &incorrect-iss-field) value)))
(define-public &incorrect-aud-field
(make-exception-type
'&incorrect-aud-field
&external-error
'(value)))
(define-public (raise-incorrect-aud-field value)
(raise-exception
((record-constructor &incorrect-aud-field) value)))
(define-public &incorrect-iat-field
(make-exception-type
'&incorrect-iat-field
&external-error
'(value)))
(define-public (raise-incorrect-iat-field value)
(raise-exception
((record-constructor &incorrect-iat-field) value)))
(define-public &incorrect-exp-field
(make-exception-type
'&incorrect-exp-field
&external-error
'(value)))
(define-public (raise-incorrect-exp-field value)
(raise-exception
((record-constructor &incorrect-exp-field) value)))
(define-public &incorrect-cnf/jkt-field
(make-exception-type
'&incorrect-cnf/jkt-field
&external-error
'(value)))
(define-public (raise-incorrect-cnf/jkt-field value)
(raise-exception
((record-constructor &incorrect-cnf/jkt-field) value)))
(define-public &incorrect-client-id-field
(make-exception-type
'&incorrect-client-id-field
&external-error
'(value)))
(define-public (raise-incorrect-client-id-field value)
(raise-exception
((record-constructor &incorrect-client-id-field) value)))
(define-public &incorrect-typ-field
(make-exception-type
'&incorrect-typ-field
&external-error
'(value)))
(define-public (raise-incorrect-typ-field value)
(raise-exception
((record-constructor &incorrect-typ-field) value)))
(define-public &incorrect-jwk-field
(make-exception-type
'&incorrect-jwk-field
&external-error
'(value cause)))
(define-public (raise-incorrect-jwk-field value cause)
(raise-exception
((record-constructor &incorrect-jwk-field) value cause)))
(define-public &incorrect-jti-field
(make-exception-type
'&incorrect-jti-field
&external-error
'(value)))
(define-public (raise-incorrect-jti-field value)
(raise-exception
((record-constructor &incorrect-jti-field) value)))
(define-public &incorrect-htm-field
(make-exception-type
'&incorrect-htm-field
&external-error
'(value)))
(define-public (raise-incorrect-htm-field value)
(raise-exception
((record-constructor &incorrect-htm-field) value)))
(define-public &incorrect-htu-field
(make-exception-type
'&incorrect-htu-field
&external-error
'(value)))
(define-public (raise-incorrect-htu-field value)
(raise-exception
((record-constructor &incorrect-htu-field) value)))
(define-public ¬-an-access-token
(make-exception-type
'¬-an-access-token
&external-error
'(value cause)))
(define-public (raise-not-an-access-token value cause)
(raise-exception
((record-constructor ¬-an-access-token) value cause)))
(define-public ¬-an-access-token-header
(make-exception-type
'¬-an-access-token-header
&external-error
'(value cause)))
(define-public (raise-not-an-access-token-header value cause)
(raise-exception
((record-constructor ¬-an-access-token-header) value cause)))
(define-public ¬-an-access-token-payload
(make-exception-type
'¬-an-access-token-payload
&external-error
'(value cause)))
(define-public (raise-not-an-access-token-payload value cause)
(raise-exception
((record-constructor ¬-an-access-token-payload) value cause)))
(define-public ¬-a-dpop-proof
(make-exception-type
'¬-a-dpop-proof
&external-error
'(value cause)))
(define-public (raise-not-a-dpop-proof value cause)
(raise-exception
((record-constructor ¬-a-dpop-proof) value cause)))
(define-public ¬-a-dpop-proof-header
(make-exception-type
'¬-a-dpop-proof-header
&external-error
'(value cause)))
(define-public (raise-not-a-dpop-proof-header value cause)
(raise-exception
((record-constructor ¬-a-dpop-proof-header) value cause)))
(define-public ¬-a-dpop-proof-payload
(make-exception-type
'¬-a-dpop-proof-payload
&external-error
'(value cause)))
(define-public (raise-not-a-dpop-proof-payload value cause)
(raise-exception
((record-constructor ¬-a-dpop-proof-payload) value cause)))
(define-public &cannot-fetch-issuer-configuration
(make-exception-type
'&cannot-fetch-issuer-configuration
&external-error
'(issuer cause)))
(define-public (raise-cannot-fetch-issuer-configuration issuer cause)
(raise-exception
((record-constructor &cannot-fetch-issuer-configuration) issuer cause)))
(define-public &cannot-fetch-jwks
(make-exception-type
'&cannot-fetch-jwks
&external-error
'(issuer uri cause)))
(define-public (raise-cannot-fetch-jwks issuer uri cause)
(raise-exception
((record-constructor &cannot-fetch-jwks) issuer uri cause)))
(define-public &dpop-method-mismatch
(make-exception-type
'&dpop-method-mismatch
&external-error
'(signed requested)))
(define-public (raise-dpop-method-mismatch signed requested)
(raise-exception
((record-constructor &dpop-method-mismatch) signed requested)))
(define-public &dpop-uri-mismatch
(make-exception-type
'&dpop-uri-mismatch
&external-error
'(signed requested)))
(define-public (raise-dpop-uri-mismatch signed requested)
(raise-exception
((record-constructor &dpop-uri-mismatch) signed requested)))
(define-public &dpop-signed-in-future
(make-exception-type
'&dpop-signed-in-future
&external-error
'(signed requested)))
(define-public (raise-dpop-signed-in-future signed requested)
(raise-exception
((record-constructor &dpop-signed-in-future) signed requested)))
(define-public &dpop-too-old
(make-exception-type
'&dpop-too-old
&external-error
'(signed requested)))
(define-public (raise-dpop-too-old signed requested)
(raise-exception
((record-constructor &dpop-too-old) signed requested)))
(define-public &dpop-unconfirmed-key
(make-exception-type
'&dpop-unconfirmed-key
&external-error
'(key expected cause)))
(define-public (raise-dpop-unconfirmed-key key expected cause)
(raise-exception
((record-constructor &dpop-unconfirmed-key) key expected cause)))
(define-public &jti-found
(make-exception-type
'&jti-found
&external-error
'(jti cause)))
(define-public (raise-jti-found jti cause)
(raise-exception
((record-constructor &jti-found) jti cause)))
(define-public &cannot-decode-access-token
(make-exception-type
'&cannot-decode-access-token
&external-error
'(value cause)))
(define-public (raise-cannot-decode-access-token value cause)
(raise-exception
((record-constructor &cannot-decode-access-token) value cause)))
(define-public &cannot-encode-access-token
(make-exception-type
'&cannot-encode-access-token
&external-error
'(access-token key cause)))
(define-public (raise-cannot-encode-access-token access-token key cause)
(raise-exception
((record-constructor &cannot-encode-access-token) access-token key cause)))
(define-public &cannot-decode-dpop-proof
(make-exception-type
'&cannot-decode-dpop-proof
&external-error
'(value cause)))
(define-public (raise-cannot-decode-dpop-proof value cause)
(raise-exception
((record-constructor &cannot-decode-dpop-proof) value cause)))
(define-public &cannot-encode-dpop-proof
(make-exception-type
'&cannot-encode-dpop-proof
&external-error
'(dpop-proof key cause)))
(define-public (raise-cannot-encode-dpop-proof dpop-proof key cause)
(raise-exception
((record-constructor &cannot-encode-dpop-proof) dpop-proof key cause)))
(define-public &cannot-fetch-linked-data
(make-exception-type
'&cannot-fetch-linked-data
&external-error
'(uri cause)))
(define-public (raise-cannot-fetch-linked-data uri cause)
(raise-exception
((record-constructor &cannot-fetch-linked-data) uri cause)))
(define*-public (error->str err #:key (max-depth #f))
(if (record? err)
(let* ((type (record-type-descriptor err))
(get
(lambda (slot)
((record-accessor type slot) err)))
(recurse
(if (eqv? max-depth 0)
(lambda (err) (G_ "that’s how it is"))
(lambda (err)
(error->str err #:max-depth (and max-depth (- max-depth 1)))))))
(case (record-type-name type)
((¬-base64)
(format #f (G_ "the value ~s is not a base64 string (because ~a)")
(get 'value) (recurse (get 'cause))))
((¬-json)
(format #f (G_ "the value ~s is not JSON (because ~a)")
(get 'value) (recurse (get 'cause))))
((¬-turtle)
(format #f (G_ "the value ~s is not Turtle (because ~a)")
(get 'value) (recurse (get 'cause))))
((&unsupported-crv)
(format #f (G_ "the value ~s does not identify an elleptic curve")
(get 'crv)))
((¬-a-jwk)
(let ((cause (get 'cause)))
(if cause
(format #f (G_ "the value ~s does not identify a JWK (because ~a)")
(get 'value) (recurse cause))
(format #f (G_ "the value ~s does not identify a JWK")
(get 'value)))))
((¬-a-public-jwk)
(let ((cause (get 'cause)))
(if cause
(format #f (G_ "the value ~s does not identify a public JWK (because ~a)")
(get 'value) (recurse cause))
(format #f (G_ "the value ~s does not identify a public JWK")
(get 'value)))))
((¬-a-private-jwk)
(let ((cause (get 'cause)))
(if cause
(format #f (G_ "the value ~s does not identify a private JWK (because ~a)")
(get 'value) cause)
(format #f (G_ "the value ~s does not identify a private JWK")
(get 'value)))))
((¬-a-jwks)
(let ((cause (get 'cause)))
(if cause
(format #f (G_ "the value ~s does not identify a JWKS (because ~a)")
(get 'value) (recurse cause))
(format #f (G_ "the value ~s does not identify a JWKS")
(get 'value)))))
((&unsupported-alg)
(format #f (G_ "the value ~s does not identify a hash algorithm")
(get 'value)))
((&missing-alist-key)
(format #f (G_ "the value ~s is not an alist or misses key ~s")
(get 'value) (get 'key)))
((¬-a-jws-header)
(format #f (G_ "the value ~s is not a JWS header (because ~a)")
(get 'value) (recurse (get 'cause))))
((¬-a-jws-payload)
(format #f (G_ "the value ~s is not a JWS payload (because ~a)")
(get 'value) (recurse (get 'cause))))
((¬-a-jws)
(format #f (G_ "the value ~s is not a JWS (because ~a)")
(get 'value) (recurse (get 'cause))))
((¬-in-3-parts)
(format #f (G_ "the string ~s cannot be split in 3 parts with ~s")
(get 'string) (get 'separator)))
((&no-matching-key)
(format #f (G_ "all key candidates failed to verify signature ~s with algorithm ~s and payload ~a (there were ~a: ~s)")
(get 'signature) (get 'alg) (get 'payload) (length (get 'candidates)) (get 'candidates)))
((&cannot-decode-jws)
(format #f (G_ "I cannot decode JWS ~a (because ~a)")
(get 'value) (recurse (get 'cause))))
((&cannot-encode-jws)
(format #f (G_ "I cannot encode JWS ~a (because ~a)")
(get 'value) (recurse (get 'cause))))
((&response-failed-unexpectedly)
(format #f (G_ "the server request unexpectedly failed with code ~a and reason phrase ~s")
(get 'response-code) (get 'response-reason-phrase)))
((&unexpected-header-value)
(let ((value (get 'value)))
(if value
(format #f (G_ "the header ~a should not have the value ~s")
(get 'header) value)
(format #f (G_ "the header ~a should be present")
(get 'header)))))
((&unexpected-response)
(format #f (G_ "the server response wasn't expected: ~s (because ~a)")
(call-with-output-string
(lambda (port)
(write-response (get 'response) port)))
(recurse (get 'cause))))
((¬-an-oidc-configuration)
(format #f (G_ "the value ~s is not an OIDC configuration (because ~a)")
(get 'value) (recurse (get 'cause))))
((&incorrect-webid-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the webid field is incorrect: ~s") value)
(format #f (G_ "the webid field is missing")))))
((&incorrect-iss-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the iss field is incorrect: ~s") value)
(format #f (G_ "the iss field is missing")))))
((&incorrect-aud-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the aud field is incorrect: ~s") value)
(format #f (G_ "the aud field is missing")))))
((&incorrect-iat-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the iat field is incorrect: ~s") value)
(format #f (G_ "the iat field is missing")))))
((&incorrect-exp-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the exp field is incorrect: ~s") value)
(format #f (G_ "the exp field is missing")))))
((&incorrect-cnf/jkt-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the cnf/jkt field is incorrect: ~s") value)
(format #f (G_ "the cnf/jkt field is missing")))))
((&incorrect-client-id-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the client-id field is incorrect: ~s") value)
(format #f (G_ "the client-id field is missing")))))
((&incorrect-typ-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the typ field is incorrect: ~s") value)
(format #f (G_ "the typ field is missing")))))
((&incorrect-jwk-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the jwk field is incorrect: ~s (because ~a)")
value (recurse (get 'cause)))
(format #f (G_ "the jwk field is missing")))))
((&incorrect-jti-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the jti field is incorrect: ~s") value)
(format #f (G_ "the jti field is missing")))))
((&incorrect-htm-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the htm field is incorrect: ~s") value)
(format #f (G_ "the htm field is missing")))))
((&incorrect-htu-field)
(let ((value (get 'value)))
(if value
(format #f (G_ "the htu field is incorrect: ~s") value)
(format #f (G_ "the htu field is missing")))))
((¬-an-access-token)
(format #f (G_ "~s is not an access token (because ~a)")
(get 'value) (recurse (get 'cause))))
((¬-an-access-token-header)
(format #f (G_ "~s is not an access token header (because ~a)")
(get 'value) (recurse (get 'cause))))
((¬-an-access-token-payload)
(format #f (G_ "~s is not an access token payload (because ~a)")
(get 'value) (recurse (get 'cause))))
((¬-a-dpop-proof)
(format #f (G_ "~s is not a DPoP proof (because ~a)")
(get 'value) (recurse (get 'cause))))
((¬-a-dpop-proof-header)
(format #f (G_ "~s is not a DPoP proof header (because ~a)")
(get 'value) (recurse (get 'cause))))
((¬-a-dpop-proof-payload)
(format #f (G_ "~s is not a DPoP proof payload (because ~a)")
(get 'value) (recurse (get 'cause))))
((&cannot-fetch-issuer-configuration)
(format #f (G_ "I cannot fetch the issuer configuration of ~a (because ~a)")
(let ((iss (get 'issuer)))
(when (uri? iss)
(set! iss (uri->string iss)))
iss)
(recurse (get 'cause))))
((&cannot-fetch-jwks)
(format #f (G_ "I cannot fetch the JWKS of ~a at ~a (because ~a)")
(let ((iss (get 'issuer)))
(when (uri? iss)
(set! iss (uri->string iss)))
iss)
(let ((uri (get 'uri)))
(when (uri? uri)
(set! uri (uri->string uri)))
uri)
(recurse (get 'cause))))
((&dpop-method-mismatch)
(format #f (G_ "the HTTP method is signed for ~s, but ~s was requested")
(get 'signed) (get 'requested)))
((&dpop-uri-mismatch)
(format #f (G_ "the HTTP uri is signed for ~a, but ~a was requested")
(uri->string (get 'signed)) (uri->string (get 'requested))))
((&dpop-signed-in-future)
(format #f (G_ "the date is ~a, but the DPoP proof is signed in the future at ~a")
(time-second (date->time-utc (get 'signed)))
(time-second (date->time-utc (get 'requested)))))
((&dpop-too-old)
(format #f (G_ "the date is ~a, but the DPoP proof was signed too long ago at ~a")
(time-second (date->time-utc (get 'signed)))
(time-second (date->time-utc (get 'requested)))))
((&dpop-unconfirmed-key)
(let ((key (get 'key))
(expected (get 'expected))
(cause (get 'cause)))
(cond
(expected
(format #f (G_ "the key ~s does not hash to ~a") key expected))
(cause
(format #f (G_ "the key confirmation of ~s failed (because ~a)") key (recurse cause)))
(else
(format #f (G_ "the key confirmation of ~s failed") key)))))
((&jti-found)
(format #f (G_ "the jti ~s has already been found (because ~a)")
(get 'jti) (recurse (get 'cause))))
((&cannot-decode-access-token)
(format #f (G_ "I cannot decode ~s as an access token (because ~a)")
(get 'value) (recurse (get 'cause))))
((&cannot-encode-access-token)
(format #f (G_ "I cannot encode ~s as an access token with key ~s (because ~a)")
(get 'access-token) (get 'key) (recurse (get 'cause))))
((&cannot-decode-dpop-proof)
(format #f (G_ "I cannot decode ~s as a DPoP proof (because ~a)")
(get 'value) (recurse (get 'cause))))
((&cannot-encode-dpop-proof)
(format #f (G_ "I cannot encode ~s as a DPoP proof (because ~a)")
(get 'value) (recurse (get 'cause))))
((&cannot-fetch-linked-data)
(format #f (G_ "I could not fetch a RDF graph at ~a (because ~a)")
(uri->string (get 'uri)) (recurse (get 'cause))))
((&compound-exception)
(let ((components (get 'components)))
(if (null? components)
(G_ "that’s it")
(if (null? (cdr components))
(recurse (car components))
(if (null? (cddr components))
(format #f (G_ "~a and ~a")
(recurse (car components))
(recurse (cadr components)))
(format #f (G_ "~a, ~a")
(recurse (car components))
(recurse (apply make-exception (cdr components)))))))))
((&invalid-signature)
(format #f (G_ "the signature ~a does not match key ~s with payload ~a")
(get 'signature) (get 'key) (get 'payload)))
((&undefined-variable)
(G_ "there is an undefined variable"))
((&origin)
(format #f (G_ "the origin is ~a")
(exception-origin err)))
((&message)
(format #f (G_ "a message is attached: ~a")
(exception-message err)))
((&irritants)
(format #f (G_ "the values ~s are problematic")
(exception-irritants err)))
((&exception-with-kind-and-args)
(format #f (G_ "there is a kind and args")))
((&assertion-failure)
(format #f (G_ "there is an assertion failure")))
((&quit-exception)
(format #f (G_ "the program quits with code ~a")
(get 'code)))
((&non-continuable)
(format #f (G_ "the program cannot recover from this exception")))
((&error)
(format #f (G_ "there is an error")))
(else
(error (format #f (G_ "Unhandled exception type ~a.")
(record-type-name type))))))
(format #f "~a" err)))
|