@thurinlabs/identity-kit 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1857 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/core/abi.ts
2
+ var REGISTRY_ABI = [
3
+ {
4
+ "type": "function",
5
+ "name": "ATTEST_TYPEHASH",
6
+ "inputs": [],
7
+ "outputs": [
8
+ {
9
+ "name": "",
10
+ "type": "bytes32",
11
+ "internalType": "bytes32"
12
+ }
13
+ ],
14
+ "stateMutability": "view"
15
+ },
16
+ {
17
+ "type": "function",
18
+ "name": "DOMAIN_SEPARATOR",
19
+ "inputs": [],
20
+ "outputs": [
21
+ {
22
+ "name": "",
23
+ "type": "bytes32",
24
+ "internalType": "bytes32"
25
+ }
26
+ ],
27
+ "stateMutability": "view"
28
+ },
29
+ {
30
+ "type": "function",
31
+ "name": "EIP712_NAME",
32
+ "inputs": [],
33
+ "outputs": [
34
+ {
35
+ "name": "",
36
+ "type": "string",
37
+ "internalType": "string"
38
+ }
39
+ ],
40
+ "stateMutability": "view"
41
+ },
42
+ {
43
+ "type": "function",
44
+ "name": "EIP712_VERSION",
45
+ "inputs": [],
46
+ "outputs": [
47
+ {
48
+ "name": "",
49
+ "type": "string",
50
+ "internalType": "string"
51
+ }
52
+ ],
53
+ "stateMutability": "view"
54
+ },
55
+ {
56
+ "type": "function",
57
+ "name": "MAX_KEY_BYTES",
58
+ "inputs": [],
59
+ "outputs": [
60
+ {
61
+ "name": "",
62
+ "type": "uint256",
63
+ "internalType": "uint256"
64
+ }
65
+ ],
66
+ "stateMutability": "view"
67
+ },
68
+ {
69
+ "type": "function",
70
+ "name": "MAX_RECORD_BYTES",
71
+ "inputs": [],
72
+ "outputs": [
73
+ {
74
+ "name": "",
75
+ "type": "uint256",
76
+ "internalType": "uint256"
77
+ }
78
+ ],
79
+ "stateMutability": "view"
80
+ },
81
+ {
82
+ "type": "function",
83
+ "name": "MAX_SIG_BYTES",
84
+ "inputs": [],
85
+ "outputs": [
86
+ {
87
+ "name": "",
88
+ "type": "uint256",
89
+ "internalType": "uint256"
90
+ }
91
+ ],
92
+ "stateMutability": "view"
93
+ },
94
+ {
95
+ "type": "function",
96
+ "name": "MESSAGE_VERSION",
97
+ "inputs": [],
98
+ "outputs": [
99
+ {
100
+ "name": "",
101
+ "type": "uint8",
102
+ "internalType": "uint8"
103
+ }
104
+ ],
105
+ "stateMutability": "view"
106
+ },
107
+ {
108
+ "type": "function",
109
+ "name": "REATTEST_TYPEHASH",
110
+ "inputs": [],
111
+ "outputs": [
112
+ {
113
+ "name": "",
114
+ "type": "bytes32",
115
+ "internalType": "bytes32"
116
+ }
117
+ ],
118
+ "stateMutability": "view"
119
+ },
120
+ {
121
+ "type": "function",
122
+ "name": "REVOKE_TYPEHASH",
123
+ "inputs": [],
124
+ "outputs": [
125
+ {
126
+ "name": "",
127
+ "type": "bytes32",
128
+ "internalType": "bytes32"
129
+ }
130
+ ],
131
+ "stateMutability": "view"
132
+ },
133
+ {
134
+ "type": "function",
135
+ "name": "SET_RECORD_TYPEHASH",
136
+ "inputs": [],
137
+ "outputs": [
138
+ {
139
+ "name": "",
140
+ "type": "bytes32",
141
+ "internalType": "bytes32"
142
+ }
143
+ ],
144
+ "stateMutability": "view"
145
+ },
146
+ {
147
+ "type": "function",
148
+ "name": "UPDATE_KEY_TYPEHASH",
149
+ "inputs": [],
150
+ "outputs": [
151
+ {
152
+ "name": "",
153
+ "type": "bytes32",
154
+ "internalType": "bytes32"
155
+ }
156
+ ],
157
+ "stateMutability": "view"
158
+ },
159
+ {
160
+ "type": "function",
161
+ "name": "VERSION",
162
+ "inputs": [],
163
+ "outputs": [
164
+ {
165
+ "name": "",
166
+ "type": "uint8",
167
+ "internalType": "uint8"
168
+ }
169
+ ],
170
+ "stateMutability": "view"
171
+ },
172
+ {
173
+ "type": "function",
174
+ "name": "addressesFor",
175
+ "inputs": [
176
+ {
177
+ "name": "fingerprintHash",
178
+ "type": "bytes32",
179
+ "internalType": "bytes32"
180
+ }
181
+ ],
182
+ "outputs": [
183
+ {
184
+ "name": "",
185
+ "type": "address[]",
186
+ "internalType": "address[]"
187
+ }
188
+ ],
189
+ "stateMutability": "view"
190
+ },
191
+ {
192
+ "type": "function",
193
+ "name": "addressesForCount",
194
+ "inputs": [
195
+ {
196
+ "name": "fingerprintHash",
197
+ "type": "bytes32",
198
+ "internalType": "bytes32"
199
+ }
200
+ ],
201
+ "outputs": [
202
+ {
203
+ "name": "",
204
+ "type": "uint256",
205
+ "internalType": "uint256"
206
+ }
207
+ ],
208
+ "stateMutability": "view"
209
+ },
210
+ {
211
+ "type": "function",
212
+ "name": "addressesForRange",
213
+ "inputs": [
214
+ {
215
+ "name": "fingerprintHash",
216
+ "type": "bytes32",
217
+ "internalType": "bytes32"
218
+ },
219
+ {
220
+ "name": "start",
221
+ "type": "uint256",
222
+ "internalType": "uint256"
223
+ },
224
+ {
225
+ "name": "count",
226
+ "type": "uint256",
227
+ "internalType": "uint256"
228
+ }
229
+ ],
230
+ "outputs": [
231
+ {
232
+ "name": "out",
233
+ "type": "address[]",
234
+ "internalType": "address[]"
235
+ }
236
+ ],
237
+ "stateMutability": "view"
238
+ },
239
+ {
240
+ "type": "function",
241
+ "name": "attest",
242
+ "inputs": [
243
+ {
244
+ "name": "fingerprint",
245
+ "type": "bytes",
246
+ "internalType": "bytes"
247
+ },
248
+ {
249
+ "name": "pgpSignature",
250
+ "type": "bytes",
251
+ "internalType": "bytes"
252
+ },
253
+ {
254
+ "name": "pgpPublicKey",
255
+ "type": "bytes",
256
+ "internalType": "bytes"
257
+ }
258
+ ],
259
+ "outputs": [
260
+ {
261
+ "name": "index",
262
+ "type": "uint256",
263
+ "internalType": "uint256"
264
+ }
265
+ ],
266
+ "stateMutability": "nonpayable"
267
+ },
268
+ {
269
+ "type": "function",
270
+ "name": "attestFor",
271
+ "inputs": [
272
+ {
273
+ "name": "owner",
274
+ "type": "address",
275
+ "internalType": "address"
276
+ },
277
+ {
278
+ "name": "fingerprint",
279
+ "type": "bytes",
280
+ "internalType": "bytes"
281
+ },
282
+ {
283
+ "name": "pgpSignature",
284
+ "type": "bytes",
285
+ "internalType": "bytes"
286
+ },
287
+ {
288
+ "name": "pgpPublicKey",
289
+ "type": "bytes",
290
+ "internalType": "bytes"
291
+ },
292
+ {
293
+ "name": "deadline",
294
+ "type": "uint256",
295
+ "internalType": "uint256"
296
+ },
297
+ {
298
+ "name": "signature",
299
+ "type": "bytes",
300
+ "internalType": "bytes"
301
+ }
302
+ ],
303
+ "outputs": [
304
+ {
305
+ "name": "index",
306
+ "type": "uint256",
307
+ "internalType": "uint256"
308
+ }
309
+ ],
310
+ "stateMutability": "nonpayable"
311
+ },
312
+ {
313
+ "type": "function",
314
+ "name": "attestationCount",
315
+ "inputs": [
316
+ {
317
+ "name": "owner",
318
+ "type": "address",
319
+ "internalType": "address"
320
+ }
321
+ ],
322
+ "outputs": [
323
+ {
324
+ "name": "",
325
+ "type": "uint256",
326
+ "internalType": "uint256"
327
+ }
328
+ ],
329
+ "stateMutability": "view"
330
+ },
331
+ {
332
+ "type": "function",
333
+ "name": "attestationsOf",
334
+ "inputs": [
335
+ {
336
+ "name": "owner",
337
+ "type": "address",
338
+ "internalType": "address"
339
+ }
340
+ ],
341
+ "outputs": [
342
+ {
343
+ "name": "",
344
+ "type": "tuple[]",
345
+ "internalType": "struct PGPRegistry.Attestation[]",
346
+ "components": [
347
+ {
348
+ "name": "fingerprint",
349
+ "type": "bytes",
350
+ "internalType": "bytes"
351
+ },
352
+ {
353
+ "name": "createdAt",
354
+ "type": "uint64",
355
+ "internalType": "uint64"
356
+ },
357
+ {
358
+ "name": "revokedAt",
359
+ "type": "uint64",
360
+ "internalType": "uint64"
361
+ },
362
+ {
363
+ "name": "messageVersion",
364
+ "type": "uint8",
365
+ "internalType": "uint8"
366
+ },
367
+ {
368
+ "name": "keyPtr",
369
+ "type": "address",
370
+ "internalType": "address"
371
+ },
372
+ {
373
+ "name": "sigPtr",
374
+ "type": "address",
375
+ "internalType": "address"
376
+ }
377
+ ]
378
+ }
379
+ ],
380
+ "stateMutability": "view"
381
+ },
382
+ {
383
+ "type": "function",
384
+ "name": "attestationsOfRange",
385
+ "inputs": [
386
+ {
387
+ "name": "owner",
388
+ "type": "address",
389
+ "internalType": "address"
390
+ },
391
+ {
392
+ "name": "start",
393
+ "type": "uint256",
394
+ "internalType": "uint256"
395
+ },
396
+ {
397
+ "name": "count",
398
+ "type": "uint256",
399
+ "internalType": "uint256"
400
+ }
401
+ ],
402
+ "outputs": [
403
+ {
404
+ "name": "out",
405
+ "type": "tuple[]",
406
+ "internalType": "struct PGPRegistry.Attestation[]",
407
+ "components": [
408
+ {
409
+ "name": "fingerprint",
410
+ "type": "bytes",
411
+ "internalType": "bytes"
412
+ },
413
+ {
414
+ "name": "createdAt",
415
+ "type": "uint64",
416
+ "internalType": "uint64"
417
+ },
418
+ {
419
+ "name": "revokedAt",
420
+ "type": "uint64",
421
+ "internalType": "uint64"
422
+ },
423
+ {
424
+ "name": "messageVersion",
425
+ "type": "uint8",
426
+ "internalType": "uint8"
427
+ },
428
+ {
429
+ "name": "keyPtr",
430
+ "type": "address",
431
+ "internalType": "address"
432
+ },
433
+ {
434
+ "name": "sigPtr",
435
+ "type": "address",
436
+ "internalType": "address"
437
+ }
438
+ ]
439
+ }
440
+ ],
441
+ "stateMutability": "view"
442
+ },
443
+ {
444
+ "type": "function",
445
+ "name": "cancelAuthorization",
446
+ "inputs": [],
447
+ "outputs": [],
448
+ "stateMutability": "nonpayable"
449
+ },
450
+ {
451
+ "type": "function",
452
+ "name": "current",
453
+ "inputs": [
454
+ {
455
+ "name": "owner",
456
+ "type": "address",
457
+ "internalType": "address"
458
+ }
459
+ ],
460
+ "outputs": [
461
+ {
462
+ "name": "found",
463
+ "type": "bool",
464
+ "internalType": "bool"
465
+ },
466
+ {
467
+ "name": "index",
468
+ "type": "uint256",
469
+ "internalType": "uint256"
470
+ },
471
+ {
472
+ "name": "attestation",
473
+ "type": "tuple",
474
+ "internalType": "struct PGPRegistry.Attestation",
475
+ "components": [
476
+ {
477
+ "name": "fingerprint",
478
+ "type": "bytes",
479
+ "internalType": "bytes"
480
+ },
481
+ {
482
+ "name": "createdAt",
483
+ "type": "uint64",
484
+ "internalType": "uint64"
485
+ },
486
+ {
487
+ "name": "revokedAt",
488
+ "type": "uint64",
489
+ "internalType": "uint64"
490
+ },
491
+ {
492
+ "name": "messageVersion",
493
+ "type": "uint8",
494
+ "internalType": "uint8"
495
+ },
496
+ {
497
+ "name": "keyPtr",
498
+ "type": "address",
499
+ "internalType": "address"
500
+ },
501
+ {
502
+ "name": "sigPtr",
503
+ "type": "address",
504
+ "internalType": "address"
505
+ }
506
+ ]
507
+ }
508
+ ],
509
+ "stateMutability": "view"
510
+ },
511
+ {
512
+ "type": "function",
513
+ "name": "fingerprintsForKeyId",
514
+ "inputs": [
515
+ {
516
+ "name": "keyId",
517
+ "type": "bytes8",
518
+ "internalType": "bytes8"
519
+ }
520
+ ],
521
+ "outputs": [
522
+ {
523
+ "name": "",
524
+ "type": "bytes[]",
525
+ "internalType": "bytes[]"
526
+ }
527
+ ],
528
+ "stateMutability": "view"
529
+ },
530
+ {
531
+ "type": "function",
532
+ "name": "fingerprintsForKeyIdCount",
533
+ "inputs": [
534
+ {
535
+ "name": "keyId",
536
+ "type": "bytes8",
537
+ "internalType": "bytes8"
538
+ }
539
+ ],
540
+ "outputs": [
541
+ {
542
+ "name": "",
543
+ "type": "uint256",
544
+ "internalType": "uint256"
545
+ }
546
+ ],
547
+ "stateMutability": "view"
548
+ },
549
+ {
550
+ "type": "function",
551
+ "name": "fingerprintsForKeyIdRange",
552
+ "inputs": [
553
+ {
554
+ "name": "keyId",
555
+ "type": "bytes8",
556
+ "internalType": "bytes8"
557
+ },
558
+ {
559
+ "name": "start",
560
+ "type": "uint256",
561
+ "internalType": "uint256"
562
+ },
563
+ {
564
+ "name": "count",
565
+ "type": "uint256",
566
+ "internalType": "uint256"
567
+ }
568
+ ],
569
+ "outputs": [
570
+ {
571
+ "name": "out",
572
+ "type": "bytes[]",
573
+ "internalType": "bytes[]"
574
+ }
575
+ ],
576
+ "stateMutability": "view"
577
+ },
578
+ {
579
+ "type": "function",
580
+ "name": "getAttestation",
581
+ "inputs": [
582
+ {
583
+ "name": "owner",
584
+ "type": "address",
585
+ "internalType": "address"
586
+ },
587
+ {
588
+ "name": "index",
589
+ "type": "uint256",
590
+ "internalType": "uint256"
591
+ }
592
+ ],
593
+ "outputs": [
594
+ {
595
+ "name": "",
596
+ "type": "tuple",
597
+ "internalType": "struct PGPRegistry.Attestation",
598
+ "components": [
599
+ {
600
+ "name": "fingerprint",
601
+ "type": "bytes",
602
+ "internalType": "bytes"
603
+ },
604
+ {
605
+ "name": "createdAt",
606
+ "type": "uint64",
607
+ "internalType": "uint64"
608
+ },
609
+ {
610
+ "name": "revokedAt",
611
+ "type": "uint64",
612
+ "internalType": "uint64"
613
+ },
614
+ {
615
+ "name": "messageVersion",
616
+ "type": "uint8",
617
+ "internalType": "uint8"
618
+ },
619
+ {
620
+ "name": "keyPtr",
621
+ "type": "address",
622
+ "internalType": "address"
623
+ },
624
+ {
625
+ "name": "sigPtr",
626
+ "type": "address",
627
+ "internalType": "address"
628
+ }
629
+ ]
630
+ }
631
+ ],
632
+ "stateMutability": "view"
633
+ },
634
+ {
635
+ "type": "function",
636
+ "name": "getPayload",
637
+ "inputs": [
638
+ {
639
+ "name": "owner",
640
+ "type": "address",
641
+ "internalType": "address"
642
+ },
643
+ {
644
+ "name": "index",
645
+ "type": "uint256",
646
+ "internalType": "uint256"
647
+ }
648
+ ],
649
+ "outputs": [
650
+ {
651
+ "name": "pgpSignature",
652
+ "type": "bytes",
653
+ "internalType": "bytes"
654
+ },
655
+ {
656
+ "name": "pgpPublicKey",
657
+ "type": "bytes",
658
+ "internalType": "bytes"
659
+ }
660
+ ],
661
+ "stateMutability": "view"
662
+ },
663
+ {
664
+ "type": "function",
665
+ "name": "nonces",
666
+ "inputs": [
667
+ {
668
+ "name": "",
669
+ "type": "address",
670
+ "internalType": "address"
671
+ }
672
+ ],
673
+ "outputs": [
674
+ {
675
+ "name": "",
676
+ "type": "uint256",
677
+ "internalType": "uint256"
678
+ }
679
+ ],
680
+ "stateMutability": "view"
681
+ },
682
+ {
683
+ "type": "function",
684
+ "name": "reattest",
685
+ "inputs": [
686
+ {
687
+ "name": "revokeIndex",
688
+ "type": "uint256",
689
+ "internalType": "uint256"
690
+ },
691
+ {
692
+ "name": "fingerprint",
693
+ "type": "bytes",
694
+ "internalType": "bytes"
695
+ },
696
+ {
697
+ "name": "pgpSignature",
698
+ "type": "bytes",
699
+ "internalType": "bytes"
700
+ },
701
+ {
702
+ "name": "pgpPublicKey",
703
+ "type": "bytes",
704
+ "internalType": "bytes"
705
+ }
706
+ ],
707
+ "outputs": [
708
+ {
709
+ "name": "index",
710
+ "type": "uint256",
711
+ "internalType": "uint256"
712
+ }
713
+ ],
714
+ "stateMutability": "nonpayable"
715
+ },
716
+ {
717
+ "type": "function",
718
+ "name": "reattestFor",
719
+ "inputs": [
720
+ {
721
+ "name": "owner",
722
+ "type": "address",
723
+ "internalType": "address"
724
+ },
725
+ {
726
+ "name": "revokeIndex",
727
+ "type": "uint256",
728
+ "internalType": "uint256"
729
+ },
730
+ {
731
+ "name": "fingerprint",
732
+ "type": "bytes",
733
+ "internalType": "bytes"
734
+ },
735
+ {
736
+ "name": "pgpSignature",
737
+ "type": "bytes",
738
+ "internalType": "bytes"
739
+ },
740
+ {
741
+ "name": "pgpPublicKey",
742
+ "type": "bytes",
743
+ "internalType": "bytes"
744
+ },
745
+ {
746
+ "name": "deadline",
747
+ "type": "uint256",
748
+ "internalType": "uint256"
749
+ },
750
+ {
751
+ "name": "signature",
752
+ "type": "bytes",
753
+ "internalType": "bytes"
754
+ }
755
+ ],
756
+ "outputs": [
757
+ {
758
+ "name": "index",
759
+ "type": "uint256",
760
+ "internalType": "uint256"
761
+ }
762
+ ],
763
+ "stateMutability": "nonpayable"
764
+ },
765
+ {
766
+ "type": "function",
767
+ "name": "record",
768
+ "inputs": [
769
+ {
770
+ "name": "owner",
771
+ "type": "address",
772
+ "internalType": "address"
773
+ },
774
+ {
775
+ "name": "index",
776
+ "type": "uint256",
777
+ "internalType": "uint256"
778
+ },
779
+ {
780
+ "name": "kind",
781
+ "type": "bytes32",
782
+ "internalType": "bytes32"
783
+ }
784
+ ],
785
+ "outputs": [
786
+ {
787
+ "name": "",
788
+ "type": "bytes",
789
+ "internalType": "bytes"
790
+ }
791
+ ],
792
+ "stateMutability": "view"
793
+ },
794
+ {
795
+ "type": "function",
796
+ "name": "revoke",
797
+ "inputs": [
798
+ {
799
+ "name": "index",
800
+ "type": "uint256",
801
+ "internalType": "uint256"
802
+ }
803
+ ],
804
+ "outputs": [],
805
+ "stateMutability": "nonpayable"
806
+ },
807
+ {
808
+ "type": "function",
809
+ "name": "revokeFor",
810
+ "inputs": [
811
+ {
812
+ "name": "owner",
813
+ "type": "address",
814
+ "internalType": "address"
815
+ },
816
+ {
817
+ "name": "index",
818
+ "type": "uint256",
819
+ "internalType": "uint256"
820
+ },
821
+ {
822
+ "name": "deadline",
823
+ "type": "uint256",
824
+ "internalType": "uint256"
825
+ },
826
+ {
827
+ "name": "signature",
828
+ "type": "bytes",
829
+ "internalType": "bytes"
830
+ }
831
+ ],
832
+ "outputs": [],
833
+ "stateMutability": "nonpayable"
834
+ },
835
+ {
836
+ "type": "function",
837
+ "name": "setRecord",
838
+ "inputs": [
839
+ {
840
+ "name": "index",
841
+ "type": "uint256",
842
+ "internalType": "uint256"
843
+ },
844
+ {
845
+ "name": "kind",
846
+ "type": "bytes32",
847
+ "internalType": "bytes32"
848
+ },
849
+ {
850
+ "name": "value",
851
+ "type": "bytes",
852
+ "internalType": "bytes"
853
+ }
854
+ ],
855
+ "outputs": [],
856
+ "stateMutability": "nonpayable"
857
+ },
858
+ {
859
+ "type": "function",
860
+ "name": "setRecordFor",
861
+ "inputs": [
862
+ {
863
+ "name": "owner",
864
+ "type": "address",
865
+ "internalType": "address"
866
+ },
867
+ {
868
+ "name": "index",
869
+ "type": "uint256",
870
+ "internalType": "uint256"
871
+ },
872
+ {
873
+ "name": "kind",
874
+ "type": "bytes32",
875
+ "internalType": "bytes32"
876
+ },
877
+ {
878
+ "name": "value",
879
+ "type": "bytes",
880
+ "internalType": "bytes"
881
+ },
882
+ {
883
+ "name": "deadline",
884
+ "type": "uint256",
885
+ "internalType": "uint256"
886
+ },
887
+ {
888
+ "name": "signature",
889
+ "type": "bytes",
890
+ "internalType": "bytes"
891
+ }
892
+ ],
893
+ "outputs": [],
894
+ "stateMutability": "nonpayable"
895
+ },
896
+ {
897
+ "type": "function",
898
+ "name": "updateKey",
899
+ "inputs": [
900
+ {
901
+ "name": "index",
902
+ "type": "uint256",
903
+ "internalType": "uint256"
904
+ },
905
+ {
906
+ "name": "pgpPublicKey",
907
+ "type": "bytes",
908
+ "internalType": "bytes"
909
+ }
910
+ ],
911
+ "outputs": [],
912
+ "stateMutability": "nonpayable"
913
+ },
914
+ {
915
+ "type": "function",
916
+ "name": "updateKeyFor",
917
+ "inputs": [
918
+ {
919
+ "name": "owner",
920
+ "type": "address",
921
+ "internalType": "address"
922
+ },
923
+ {
924
+ "name": "index",
925
+ "type": "uint256",
926
+ "internalType": "uint256"
927
+ },
928
+ {
929
+ "name": "pgpPublicKey",
930
+ "type": "bytes",
931
+ "internalType": "bytes"
932
+ },
933
+ {
934
+ "name": "deadline",
935
+ "type": "uint256",
936
+ "internalType": "uint256"
937
+ },
938
+ {
939
+ "name": "signature",
940
+ "type": "bytes",
941
+ "internalType": "bytes"
942
+ }
943
+ ],
944
+ "outputs": [],
945
+ "stateMutability": "nonpayable"
946
+ },
947
+ {
948
+ "type": "event",
949
+ "name": "Attested",
950
+ "inputs": [
951
+ {
952
+ "name": "owner",
953
+ "type": "address",
954
+ "indexed": true,
955
+ "internalType": "address"
956
+ },
957
+ {
958
+ "name": "fingerprintHash",
959
+ "type": "bytes32",
960
+ "indexed": true,
961
+ "internalType": "bytes32"
962
+ },
963
+ {
964
+ "name": "index",
965
+ "type": "uint256",
966
+ "indexed": true,
967
+ "internalType": "uint256"
968
+ },
969
+ {
970
+ "name": "fingerprint",
971
+ "type": "bytes",
972
+ "indexed": false,
973
+ "internalType": "bytes"
974
+ },
975
+ {
976
+ "name": "messageVersion",
977
+ "type": "uint8",
978
+ "indexed": false,
979
+ "internalType": "uint8"
980
+ },
981
+ {
982
+ "name": "keyPtr",
983
+ "type": "address",
984
+ "indexed": false,
985
+ "internalType": "address"
986
+ },
987
+ {
988
+ "name": "sigPtr",
989
+ "type": "address",
990
+ "indexed": false,
991
+ "internalType": "address"
992
+ },
993
+ {
994
+ "name": "submitter",
995
+ "type": "address",
996
+ "indexed": false,
997
+ "internalType": "address"
998
+ }
999
+ ],
1000
+ "anonymous": false
1001
+ },
1002
+ {
1003
+ "type": "event",
1004
+ "name": "KeyUpdated",
1005
+ "inputs": [
1006
+ {
1007
+ "name": "owner",
1008
+ "type": "address",
1009
+ "indexed": true,
1010
+ "internalType": "address"
1011
+ },
1012
+ {
1013
+ "name": "fingerprintHash",
1014
+ "type": "bytes32",
1015
+ "indexed": true,
1016
+ "internalType": "bytes32"
1017
+ },
1018
+ {
1019
+ "name": "index",
1020
+ "type": "uint256",
1021
+ "indexed": true,
1022
+ "internalType": "uint256"
1023
+ },
1024
+ {
1025
+ "name": "oldKeyPtr",
1026
+ "type": "address",
1027
+ "indexed": false,
1028
+ "internalType": "address"
1029
+ },
1030
+ {
1031
+ "name": "newKeyPtr",
1032
+ "type": "address",
1033
+ "indexed": false,
1034
+ "internalType": "address"
1035
+ },
1036
+ {
1037
+ "name": "submitter",
1038
+ "type": "address",
1039
+ "indexed": false,
1040
+ "internalType": "address"
1041
+ }
1042
+ ],
1043
+ "anonymous": false
1044
+ },
1045
+ {
1046
+ "type": "event",
1047
+ "name": "NonceUsed",
1048
+ "inputs": [
1049
+ {
1050
+ "name": "owner",
1051
+ "type": "address",
1052
+ "indexed": true,
1053
+ "internalType": "address"
1054
+ },
1055
+ {
1056
+ "name": "nonce",
1057
+ "type": "uint256",
1058
+ "indexed": false,
1059
+ "internalType": "uint256"
1060
+ }
1061
+ ],
1062
+ "anonymous": false
1063
+ },
1064
+ {
1065
+ "type": "event",
1066
+ "name": "RecordSet",
1067
+ "inputs": [
1068
+ {
1069
+ "name": "owner",
1070
+ "type": "address",
1071
+ "indexed": true,
1072
+ "internalType": "address"
1073
+ },
1074
+ {
1075
+ "name": "index",
1076
+ "type": "uint256",
1077
+ "indexed": true,
1078
+ "internalType": "uint256"
1079
+ },
1080
+ {
1081
+ "name": "kind",
1082
+ "type": "bytes32",
1083
+ "indexed": true,
1084
+ "internalType": "bytes32"
1085
+ },
1086
+ {
1087
+ "name": "submitter",
1088
+ "type": "address",
1089
+ "indexed": false,
1090
+ "internalType": "address"
1091
+ }
1092
+ ],
1093
+ "anonymous": false
1094
+ },
1095
+ {
1096
+ "type": "event",
1097
+ "name": "Revoked",
1098
+ "inputs": [
1099
+ {
1100
+ "name": "owner",
1101
+ "type": "address",
1102
+ "indexed": true,
1103
+ "internalType": "address"
1104
+ },
1105
+ {
1106
+ "name": "fingerprintHash",
1107
+ "type": "bytes32",
1108
+ "indexed": true,
1109
+ "internalType": "bytes32"
1110
+ },
1111
+ {
1112
+ "name": "index",
1113
+ "type": "uint256",
1114
+ "indexed": true,
1115
+ "internalType": "uint256"
1116
+ },
1117
+ {
1118
+ "name": "submitter",
1119
+ "type": "address",
1120
+ "indexed": false,
1121
+ "internalType": "address"
1122
+ }
1123
+ ],
1124
+ "anonymous": false
1125
+ },
1126
+ {
1127
+ "type": "error",
1128
+ "name": "AlreadyRevoked",
1129
+ "inputs": []
1130
+ },
1131
+ {
1132
+ "type": "error",
1133
+ "name": "AuthorizationExpired",
1134
+ "inputs": []
1135
+ },
1136
+ {
1137
+ "type": "error",
1138
+ "name": "DeploymentFailed",
1139
+ "inputs": []
1140
+ },
1141
+ {
1142
+ "type": "error",
1143
+ "name": "DuplicateActiveFingerprint",
1144
+ "inputs": []
1145
+ },
1146
+ {
1147
+ "type": "error",
1148
+ "name": "EmptyPublicKey",
1149
+ "inputs": []
1150
+ },
1151
+ {
1152
+ "type": "error",
1153
+ "name": "EmptySignature",
1154
+ "inputs": []
1155
+ },
1156
+ {
1157
+ "type": "error",
1158
+ "name": "IndexOutOfBounds",
1159
+ "inputs": []
1160
+ },
1161
+ {
1162
+ "type": "error",
1163
+ "name": "InvalidAuthorization",
1164
+ "inputs": []
1165
+ },
1166
+ {
1167
+ "type": "error",
1168
+ "name": "InvalidFingerprintLength",
1169
+ "inputs": []
1170
+ },
1171
+ {
1172
+ "type": "error",
1173
+ "name": "InvalidPointer",
1174
+ "inputs": []
1175
+ },
1176
+ {
1177
+ "type": "error",
1178
+ "name": "PublicKeyTooLarge",
1179
+ "inputs": []
1180
+ },
1181
+ {
1182
+ "type": "error",
1183
+ "name": "RecordTooLarge",
1184
+ "inputs": []
1185
+ },
1186
+ {
1187
+ "type": "error",
1188
+ "name": "SignatureTooLarge",
1189
+ "inputs": []
1190
+ }
1191
+ ];
1192
+
1193
+ // src/core/contract.ts
1194
+ var _chains = require('viem/chains');
1195
+ var REGISTRY_ADDRESS = "0x9302E02e2869e129aC8516fE5eFFd51EA3082c09";
1196
+ var NETWORKS = {
1197
+ mainnet: {
1198
+ chainId: 1,
1199
+ address: REGISTRY_ADDRESS,
1200
+ deployBlock: 25962908n,
1201
+ // 2026-09-12, tx 0xda4c3a19cae4e71ffb02559a048403f664d5a7967c19d42158c39600ec63bad8
1202
+ explorerUrl: "https://etherscan.io",
1203
+ defaultRpcUrl: "https://ethereum-rpc.publicnode.com"
1204
+ },
1205
+ sepolia: {
1206
+ chainId: 11155111,
1207
+ address: REGISTRY_ADDRESS,
1208
+ deployBlock: 11683667n,
1209
+ // 2026-09-11, tx 0x3e40e8f5b9fbf82a4b8943561bcc9b964b2987de10640ac8ff3a1b4ef0725322
1210
+ explorerUrl: "https://sepolia.etherscan.io",
1211
+ defaultRpcUrl: "https://ethereum-sepolia-rpc.publicnode.com"
1212
+ },
1213
+ /** A local anvil instance (`anvil`, chain id 31337). Deploy with pgp-registry's Deploy script. */
1214
+ local: {
1215
+ chainId: 31337,
1216
+ address: REGISTRY_ADDRESS,
1217
+ deployBlock: 0n,
1218
+ explorerUrl: "",
1219
+ defaultRpcUrl: "http://127.0.0.1:8545"
1220
+ }
1221
+ };
1222
+ function isNetworkName(value) {
1223
+ return value === "mainnet" || value === "sepolia" || value === "local";
1224
+ }
1225
+ function getRegistry(network = "mainnet", addressOverride) {
1226
+ const r = NETWORKS[network];
1227
+ if (!r) throw new Error(`Unknown network: ${network}`);
1228
+ if (addressOverride && /^0x[0-9a-fA-F]{40}$/.test(addressOverride)) {
1229
+ return { ...r, address: addressOverride };
1230
+ }
1231
+ return r;
1232
+ }
1233
+ function chainFor(network = "mainnet") {
1234
+ if (network === "sepolia") return _chains.sepolia;
1235
+ if (network === "local") return _chains.foundry;
1236
+ return _chains.mainnet;
1237
+ }
1238
+
1239
+ // src/core/fingerprint.ts
1240
+ var _viem = require('viem');
1241
+ var FINGERPRINT_HEX = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
1242
+ function normalizeFingerprint(input) {
1243
+ const hex = input.replace(/^0x/i, "").replace(/\s+/g, "").toLowerCase();
1244
+ return FINGERPRINT_HEX.test(hex) ? hex : null;
1245
+ }
1246
+ function fingerprintToBytes(fingerprint) {
1247
+ const hex = normalizeFingerprint(fingerprint);
1248
+ if (!hex) throw new Error(`Invalid PGP fingerprint: ${fingerprint}`);
1249
+ return `0x${hex}`;
1250
+ }
1251
+ function bytesToFingerprint(bytes) {
1252
+ return bytes.replace(/^0x/i, "").toLowerCase();
1253
+ }
1254
+ function fingerprintHash(fingerprint) {
1255
+ return _viem.keccak256.call(void 0, fingerprintToBytes(fingerprint));
1256
+ }
1257
+ function keyIdOf(fingerprint) {
1258
+ const hex = normalizeFingerprint(fingerprint);
1259
+ if (!hex) throw new Error(`Invalid PGP fingerprint: ${fingerprint}`);
1260
+ return `0x${keyIdHex(hex)}`;
1261
+ }
1262
+ function keyIdHex(normalizedFingerprint) {
1263
+ return normalizedFingerprint.length === 64 ? normalizedFingerprint.slice(0, 16) : normalizedFingerprint.slice(-16);
1264
+ }
1265
+ function keyIdToBytes(keyId) {
1266
+ const hex = keyId.replace(/^0x/i, "").replace(/\s+/g, "").toLowerCase();
1267
+ return /^[0-9a-f]{16}$/.test(hex) ? `0x${hex}` : null;
1268
+ }
1269
+
1270
+ // src/core/pgp.ts
1271
+ function pgpConfig(openpgp) {
1272
+ return { ...openpgp.config, rejectCurves: /* @__PURE__ */ new Set() };
1273
+ }
1274
+ function algorithmName(keyOrSubkey) {
1275
+ try {
1276
+ const info = keyOrSubkey.getAlgorithmInfo();
1277
+ const curve = (info.curve || "").toLowerCase();
1278
+ if (curve.startsWith("ed25519") || info.algorithm === "ed25519" || info.algorithm === "eddsaLegacy") return "Ed25519";
1279
+ if (curve.startsWith("curve25519") || info.algorithm === "x25519") return "Cv25519";
1280
+ if (curve.startsWith("ed448")) return "Ed448";
1281
+ if (curve.startsWith("curve448") || info.algorithm === "x448") return "X448";
1282
+ if (curve.startsWith("nistp") || curve.startsWith("p")) return `NIST P-${curve.replace(/\D/g, "")}`;
1283
+ if (curve.startsWith("secp")) return curve;
1284
+ if (curve.startsWith("brainpool")) return curve;
1285
+ if (info.algorithm.startsWith("rsa")) return info.bits ? `RSA ${info.bits}` : "RSA";
1286
+ if (info.algorithm.startsWith("dsa")) return info.bits ? `DSA ${info.bits}` : "DSA";
1287
+ if (info.algorithm.startsWith("elgamal")) return info.bits ? `ElGamal ${info.bits}` : "ElGamal";
1288
+ return info.curve || info.algorithm;
1289
+ } catch (e) {
1290
+ return String(_nullishCoalesce(_optionalChain([keyOrSubkey, 'access', _ => _.keyPacket, 'optionalAccess', _2 => _2.algorithm]), () => ( "unknown")));
1291
+ }
1292
+ }
1293
+ async function parsePgpKey(armoredKey) {
1294
+ try {
1295
+ const openpgp = await Promise.resolve().then(() => _interopRequireWildcard(require("openpgp")));
1296
+ const { readKey } = openpgp;
1297
+ const config = pgpConfig(openpgp);
1298
+ const key = await readKey({ armoredKey });
1299
+ const fingerprint = key.getFingerprint().toUpperCase();
1300
+ const algorithm = algorithmName(key);
1301
+ const created = _nullishCoalesce(_optionalChain([key, 'access', _3 => _3.keyPacket, 'access', _4 => _4.created, 'optionalAccess', _5 => _5.toISOString, 'call', _6 => _6()]), () => ( null));
1302
+ const expiration = await key.getExpirationTime();
1303
+ const expires = expiration && expiration !== Infinity ? new Date(expiration).toISOString() : null;
1304
+ const userIDs = [];
1305
+ const notations = [];
1306
+ const seen = /* @__PURE__ */ new Set();
1307
+ for (const user of key.users) {
1308
+ const certs = user.selfCertifications;
1309
+ if (!certs || certs.length === 0) continue;
1310
+ let userVerified = false;
1311
+ for (const cert of certs) {
1312
+ try {
1313
+ await cert.verify(
1314
+ key.keyPacket,
1315
+ cert.signatureType,
1316
+ { userID: user.userID, key: key.keyPacket },
1317
+ void 0,
1318
+ // date: now
1319
+ void 0,
1320
+ // detached
1321
+ config
1322
+ );
1323
+ } catch (e2) {
1324
+ continue;
1325
+ }
1326
+ userVerified = true;
1327
+ if (cert.rawNotations) {
1328
+ for (const n of cert.rawNotations) {
1329
+ const name = typeof n.name === "string" ? n.name : new TextDecoder().decode(n.name);
1330
+ const value = n.value instanceof Uint8Array ? new TextDecoder().decode(n.value) : typeof n.value === "string" ? n.value : null;
1331
+ if (value) {
1332
+ if (!seen.has(value)) {
1333
+ seen.add(value);
1334
+ notations.push({ name, value });
1335
+ }
1336
+ }
1337
+ }
1338
+ }
1339
+ }
1340
+ if (userVerified) {
1341
+ const uid = _optionalChain([user, 'access', _7 => _7.userID, 'optionalAccess', _8 => _8.userID]);
1342
+ if (uid) userIDs.push(uid);
1343
+ }
1344
+ }
1345
+ const subkeys = key.subkeys.map((sk) => ({
1346
+ algorithm: algorithmName(sk),
1347
+ created: _nullishCoalesce(_optionalChain([sk, 'access', _9 => _9.keyPacket, 'access', _10 => _10.created, 'optionalAccess', _11 => _11.toISOString, 'call', _12 => _12()]), () => ( null)),
1348
+ fingerprint: sk.getFingerprint().toUpperCase()
1349
+ }));
1350
+ return { fingerprint, userIDs, algorithm, created, expires, notations, subkeys };
1351
+ } catch (e3) {
1352
+ return null;
1353
+ }
1354
+ }
1355
+ async function verifyAttestation({
1356
+ pgpPublicKey,
1357
+ pgpSignature,
1358
+ fingerprint,
1359
+ ethAddress
1360
+ }) {
1361
+ try {
1362
+ if (!pgpPublicKey || !pgpSignature) {
1363
+ return { verified: false, reason: "Missing PGP data" };
1364
+ }
1365
+ const openpgp = await Promise.resolve().then(() => _interopRequireWildcard(require("openpgp")));
1366
+ const { readKey, readCleartextMessage, LiteralDataPacket } = openpgp;
1367
+ const config = pgpConfig(openpgp);
1368
+ const publicKey = await readKey({ armoredKey: pgpPublicKey });
1369
+ const keyFingerprint = publicKey.getFingerprint().toUpperCase();
1370
+ if (keyFingerprint !== fingerprint.toUpperCase()) {
1371
+ return { verified: false, reason: "Key fingerprint mismatch" };
1372
+ }
1373
+ const message = await readCleartextMessage({ cleartextMessage: pgpSignature });
1374
+ const msg = message;
1375
+ const now = /* @__PURE__ */ new Date();
1376
+ let signed = false;
1377
+ for (const sig of msg.signature.packets) {
1378
+ if (!publicKey.getKeys(sig.issuerKeyID).length) continue;
1379
+ const signingKey = await publicKey.getSigningKey(sig.issuerKeyID, now, void 0, config);
1380
+ const literal = new LiteralDataPacket();
1381
+ literal.setText(_nullishCoalesce(msg.text, () => ( message.getText().replace(/\r?\n/g, "\r\n"))));
1382
+ await sig.verify(signingKey.keyPacket, sig.signatureType, literal, now, true, config);
1383
+ signed = true;
1384
+ break;
1385
+ }
1386
+ if (!signed) return { verified: false, reason: "Message is not signed by this key" };
1387
+ const signedText = message.getText();
1388
+ if (!signedText.toLowerCase().includes(ethAddress.toLowerCase())) {
1389
+ return { verified: false, reason: "Signed message does not contain ETH address" };
1390
+ }
1391
+ return { verified: true };
1392
+ } catch (e4) {
1393
+ return { verified: false, reason: "Signature verification failed" };
1394
+ }
1395
+ }
1396
+ var EMAIL_UID = /@/;
1397
+ async function stripEmailUserIDs(armoredKey) {
1398
+ try {
1399
+ const { readKey } = await Promise.resolve().then(() => _interopRequireWildcard(require("openpgp")));
1400
+ const key = await readKey({ armoredKey });
1401
+ const kept = [];
1402
+ const removed = [];
1403
+ const users = key.users.filter((u) => {
1404
+ const uid = _optionalChain([u, 'access', _13 => _13.userID, 'optionalAccess', _14 => _14.userID]);
1405
+ if (!uid) return false;
1406
+ if (EMAIL_UID.test(uid)) {
1407
+ removed.push(uid);
1408
+ return false;
1409
+ }
1410
+ kept.push(uid);
1411
+ return true;
1412
+ });
1413
+ if (users.length === 0) return null;
1414
+ key.users = users;
1415
+ return { armored: key.armor(), kept, removed };
1416
+ } catch (e5) {
1417
+ return null;
1418
+ }
1419
+ }
1420
+ async function hasEmailUserID(armoredKey) {
1421
+ try {
1422
+ const { readKey } = await Promise.resolve().then(() => _interopRequireWildcard(require("openpgp")));
1423
+ const key = await readKey({ armoredKey });
1424
+ return key.users.some((u) => EMAIL_UID.test(_nullishCoalesce(_optionalChain([u, 'access', _15 => _15.userID, 'optionalAccess', _16 => _16.userID]), () => ( ""))));
1425
+ } catch (e6) {
1426
+ return false;
1427
+ }
1428
+ }
1429
+ var KEYSERVER_BASE = "https://keys.openpgp.org/vks/v1";
1430
+ async function fetchKeyByFingerprint(fingerprint) {
1431
+ try {
1432
+ const resp = await fetch(`${KEYSERVER_BASE}/by-fingerprint/${fingerprint}`);
1433
+ if (!resp.ok) return null;
1434
+ return await resp.text();
1435
+ } catch (e7) {
1436
+ return null;
1437
+ }
1438
+ }
1439
+ async function fetchKeyByKeyId(keyId) {
1440
+ try {
1441
+ const resp = await fetch(`${KEYSERVER_BASE}/by-keyid/${keyId}`);
1442
+ if (!resp.ok) return null;
1443
+ return await resp.text();
1444
+ } catch (e8) {
1445
+ return null;
1446
+ }
1447
+ }
1448
+
1449
+ // src/core/efp.ts
1450
+ var EFP_API = "https://api.ethfollow.xyz/api/v1";
1451
+ async function fetchEFPGraph(address) {
1452
+ try {
1453
+ const [statsResp, listsResp] = await Promise.all([
1454
+ fetch(`${EFP_API}/users/${address}/stats`),
1455
+ fetch(`${EFP_API}/users/${address}/lists`)
1456
+ ]);
1457
+ if (!statsResp.ok && !listsResp.ok) return null;
1458
+ const statsData = statsResp.ok ? await statsResp.json() : {};
1459
+ const listsData = listsResp.ok ? await listsResp.json() : {};
1460
+ const followers = parseInt(statsData.followers_count) || 0;
1461
+ const listId = listsData.primary_list;
1462
+ let following = 0;
1463
+ let top8 = [];
1464
+ if (listId) {
1465
+ const [followingResp, top8Resp] = await Promise.all([
1466
+ fetch(`${EFP_API}/lists/${listId}/following?limit=100`),
1467
+ fetch(`${EFP_API}/lists/${listId}/following?limit=8&tags=top8`)
1468
+ ]);
1469
+ const followingData = followingResp.ok ? await followingResp.json() : { following: [] };
1470
+ const top8Data = top8Resp.ok ? await top8Resp.json() : { following: [] };
1471
+ following = (followingData.following || []).length;
1472
+ top8 = (top8Data.following || []).map((f) => f.data);
1473
+ }
1474
+ return { followers, following, top8, hasEfp: !!listId || followers > 0 };
1475
+ } catch (e9) {
1476
+ return null;
1477
+ }
1478
+ }
1479
+
1480
+ // src/core/proofs.ts
1481
+ var PROVIDERS = [
1482
+ {
1483
+ provider: "github",
1484
+ label: "GitHub",
1485
+ pattern: /^https:\/\/gist\.github\.com\/([^/]+)\/([a-f0-9]+)$/i,
1486
+ parse: (m) => ({ user: m[1], gistId: m[2] })
1487
+ },
1488
+ {
1489
+ // A repository's description — the form an organisation can use, since
1490
+ // gists belong to user accounts only. Same shape as the Codeberg proof.
1491
+ provider: "github",
1492
+ label: "GitHub",
1493
+ pattern: /^https:\/\/github\.com\/([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+)$/i,
1494
+ parse: (m) => ({ user: m[1], repo: m[2] })
1495
+ },
1496
+ {
1497
+ provider: "dns",
1498
+ label: "DNS",
1499
+ // domain is restricted to a hostname (labels may include underscores for
1500
+ // records like _thurin.example.com); rejects slashes, userinfo, and spaces.
1501
+ pattern: /^dns:([a-z0-9._-]+)\?type=TXT$/i,
1502
+ parse: (m) => ({ domain: m[1] })
1503
+ },
1504
+ {
1505
+ provider: "farcaster",
1506
+ label: "Farcaster",
1507
+ pattern: /^https:\/\/farcaster\.xyz\/([^/]+)\/(0x[a-f0-9]+)$/i,
1508
+ parse: (m) => ({ user: m[1], castHash: m[2] })
1509
+ },
1510
+ {
1511
+ provider: "codeberg",
1512
+ label: "Codeberg",
1513
+ pattern: /^https:\/\/codeberg\.org\/([^/]+)\/([^/]+)$/i,
1514
+ parse: (m) => ({ user: m[1], repo: m[2] })
1515
+ },
1516
+ {
1517
+ provider: "mastodon",
1518
+ label: "Mastodon",
1519
+ // instance is restricted to a bare hostname (optional port) so a value
1520
+ // like "mastodon.social@evil.com" can't redirect the lookup elsewhere.
1521
+ pattern: /^https:\/\/([a-z0-9.-]+(?::\d+)?)\/@([^/@?#\s]+)$/i,
1522
+ parse: (m) => ({ instance: m[1], user: m[2] })
1523
+ }
1524
+ ];
1525
+ function identifyProof(notation) {
1526
+ if (notation.name !== "proof@thurin.id") return null;
1527
+ for (const { provider, label, pattern, parse } of PROVIDERS) {
1528
+ const m = notation.value.match(pattern);
1529
+ if (m) {
1530
+ return { provider, label, url: notation.value, ...parse(m) };
1531
+ }
1532
+ }
1533
+ return { provider: "unknown", label: "Unknown", url: notation.value };
1534
+ }
1535
+ function displayUrl(proof) {
1536
+ if (proof.provider === "dns") return proof.domain;
1537
+ if (proof.provider === "github") return proof.user;
1538
+ if (proof.provider === "farcaster") return `@${proof.user}`;
1539
+ if (proof.provider === "codeberg") return proof.user;
1540
+ if (proof.provider === "mastodon") return `@${proof.user}@${proof.instance}`;
1541
+ return proof.url;
1542
+ }
1543
+ function proofHref(proof) {
1544
+ if (proof.provider === "dns") return `https://${proof.domain}`;
1545
+ if (proof.provider === "github") return `https://github.com/${proof.user}`;
1546
+ if (proof.provider === "farcaster") return `https://farcaster.xyz/${proof.user}`;
1547
+ if (proof.provider === "codeberg") return `https://codeberg.org/${proof.user}`;
1548
+ if (proof.provider === "mastodon") return `https://${proof.instance}/@${proof.user}`;
1549
+ if (proof.url.startsWith("http")) return proof.url;
1550
+ return null;
1551
+ }
1552
+ function proofSecondaryHref(proof) {
1553
+ if (proof.provider === "github") return proof.url;
1554
+ if (proof.provider === "farcaster") return proof.url;
1555
+ if (proof.provider === "codeberg") return proof.url;
1556
+ if (proof.provider === "mastodon") return proof.url;
1557
+ return null;
1558
+ }
1559
+ var FPR_TOKEN = "OPENPGP4FPR:";
1560
+ function containsFingerprint(text, fingerprint) {
1561
+ return text.toUpperCase().includes(FPR_TOKEN + fingerprint.toUpperCase());
1562
+ }
1563
+ function containsFingerprintUrl(text, fingerprint) {
1564
+ return text.toUpperCase().includes(fingerprint.toUpperCase());
1565
+ }
1566
+ async function verifyGitHub(proof, fingerprint) {
1567
+ if (proof.repo) return verifyGitHubRepo(proof, fingerprint);
1568
+ try {
1569
+ const resp = await fetch(`https://api.github.com/gists/${proof.gistId}`);
1570
+ if (!resp.ok) return { verified: false, reason: `GitHub API returned ${resp.status}` };
1571
+ const data = await resp.json();
1572
+ if (_optionalChain([data, 'access', _17 => _17.owner, 'optionalAccess', _18 => _18.login, 'optionalAccess', _19 => _19.toLowerCase, 'call', _20 => _20()]) !== proof.user.toLowerCase()) {
1573
+ return { verified: false, reason: "Gist owner does not match claimed user" };
1574
+ }
1575
+ for (const file of Object.values(data.files || {})) {
1576
+ if (file.content && containsFingerprint(file.content, fingerprint)) {
1577
+ return { verified: true };
1578
+ }
1579
+ }
1580
+ return { verified: false, reason: "Fingerprint token not found in gist" };
1581
+ } catch (err) {
1582
+ return { verified: false, reason: `GitHub fetch failed: ${err.message}` };
1583
+ }
1584
+ }
1585
+ async function verifyGitHubRepo(proof, fingerprint) {
1586
+ try {
1587
+ const resp = await fetch(
1588
+ `https://api.github.com/repos/${encodeURIComponent(proof.user)}/${encodeURIComponent(proof.repo)}`
1589
+ );
1590
+ if (!resp.ok) return { verified: false, reason: `GitHub API returned ${resp.status}` };
1591
+ const data = await resp.json();
1592
+ if (_optionalChain([data, 'access', _21 => _21.owner, 'optionalAccess', _22 => _22.login, 'optionalAccess', _23 => _23.toLowerCase, 'call', _24 => _24()]) !== proof.user.toLowerCase()) {
1593
+ return { verified: false, reason: "Repository owner does not match claimed account" };
1594
+ }
1595
+ if (data.description && containsFingerprint(data.description, fingerprint)) {
1596
+ return { verified: true };
1597
+ }
1598
+ return { verified: false, reason: "Fingerprint token not found in repository description" };
1599
+ } catch (err) {
1600
+ return { verified: false, reason: `GitHub fetch failed: ${err.message}` };
1601
+ }
1602
+ }
1603
+ async function verifyDNS(proof, fingerprint) {
1604
+ try {
1605
+ const resp = await fetch(
1606
+ `https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(proof.domain)}&type=TXT`,
1607
+ { headers: { Accept: "application/dns-json" } }
1608
+ );
1609
+ if (!resp.ok) return { verified: false, reason: `DNS query returned ${resp.status}` };
1610
+ const data = await resp.json();
1611
+ for (const answer of data.Answer || []) {
1612
+ if (answer.type !== 16) continue;
1613
+ if (answer.data && containsFingerprint(answer.data, fingerprint)) {
1614
+ return { verified: true };
1615
+ }
1616
+ }
1617
+ return { verified: false, reason: "Fingerprint token not found in TXT records" };
1618
+ } catch (err) {
1619
+ return { verified: false, reason: `DNS fetch failed: ${err.message}` };
1620
+ }
1621
+ }
1622
+ var NEYNAR_HUB = "https://hub-api.neynar.com";
1623
+ async function resolveFid(username, apiKey) {
1624
+ const resp = await fetch(
1625
+ `${NEYNAR_HUB}/v1/userNameProofByName?name=${encodeURIComponent(username)}`,
1626
+ { headers: { "x-api-key": apiKey } }
1627
+ );
1628
+ if (!resp.ok) return null;
1629
+ const data = await resp.json();
1630
+ return _nullishCoalesce(data.fid, () => ( null));
1631
+ }
1632
+ async function verifyFarcaster(proof, fingerprint, neynarApiKey) {
1633
+ if (!neynarApiKey) {
1634
+ return { verified: false, reason: "Farcaster verification requires a Neynar API key" };
1635
+ }
1636
+ try {
1637
+ const fid = await resolveFid(proof.user, neynarApiKey);
1638
+ if (!fid) return { verified: false, reason: `Could not resolve Farcaster user "${proof.user}"` };
1639
+ const headers = { "x-api-key": neynarApiKey };
1640
+ let pageToken = "";
1641
+ for (let page = 0; page < 5; page++) {
1642
+ const url = `${NEYNAR_HUB}/v1/castsByFid?fid=${fid}&pageSize=100&reverse=true${pageToken ? `&pageToken=${pageToken}` : ""}`;
1643
+ const resp = await fetch(url, { headers });
1644
+ if (!resp.ok) return { verified: false, reason: `Farcaster Hub returned ${resp.status}` };
1645
+ const data = await resp.json();
1646
+ for (const msg of data.messages || []) {
1647
+ if (msg.hash && msg.hash.startsWith(proof.castHash)) {
1648
+ const text = _optionalChain([msg, 'access', _25 => _25.data, 'optionalAccess', _26 => _26.castAddBody, 'optionalAccess', _27 => _27.text]) || "";
1649
+ if (containsFingerprint(text, fingerprint)) {
1650
+ return { verified: true };
1651
+ }
1652
+ }
1653
+ }
1654
+ if (!data.nextPageToken) break;
1655
+ pageToken = data.nextPageToken;
1656
+ }
1657
+ return { verified: false, reason: "Cast not found" };
1658
+ } catch (err) {
1659
+ return { verified: false, reason: `Farcaster fetch failed: ${err.message}` };
1660
+ }
1661
+ }
1662
+ async function verifyCodeberg(proof, fingerprint) {
1663
+ try {
1664
+ const resp = await fetch(
1665
+ `https://codeberg.org/api/v1/repos/${encodeURIComponent(proof.user)}/${encodeURIComponent(proof.repo)}`
1666
+ );
1667
+ if (!resp.ok) return { verified: false, reason: `Codeberg API returned ${resp.status}` };
1668
+ const data = await resp.json();
1669
+ if (data.description && containsFingerprint(data.description, fingerprint)) {
1670
+ return { verified: true };
1671
+ }
1672
+ return { verified: false, reason: "Fingerprint token not found in repo description" };
1673
+ } catch (err) {
1674
+ return { verified: false, reason: `Codeberg fetch failed: ${err.message}` };
1675
+ }
1676
+ }
1677
+ async function verifyMastodon(proof, fingerprint) {
1678
+ try {
1679
+ if (!proof.instance || !/^[a-z0-9.-]+(?::\d+)?$/i.test(proof.instance)) {
1680
+ return { verified: false, reason: "Invalid Mastodon instance host" };
1681
+ }
1682
+ const resp = await fetch(
1683
+ `https://${proof.instance}/api/v1/accounts/lookup?acct=${encodeURIComponent(proof.user)}`
1684
+ );
1685
+ if (!resp.ok) return { verified: false, reason: `Mastodon API returned ${resp.status}` };
1686
+ const data = await resp.json();
1687
+ const keyId = keyIdHex(fingerprint.replace(/^0x/i, "").replace(/\s+/g, "").toLowerCase());
1688
+ for (const field of data.fields || []) {
1689
+ const text = field.value.replace(/<[^>]*>/g, "");
1690
+ if (containsFingerprintUrl(text, fingerprint) || containsFingerprintUrl(text, keyId)) {
1691
+ return { verified: true };
1692
+ }
1693
+ }
1694
+ if (data.note) {
1695
+ const text = data.note.replace(/<[^>]*>/g, "");
1696
+ if (containsFingerprintUrl(text, fingerprint) || containsFingerprintUrl(text, keyId)) {
1697
+ return { verified: true };
1698
+ }
1699
+ }
1700
+ return { verified: false, reason: "Fingerprint not found in profile fields or bio" };
1701
+ } catch (err) {
1702
+ return { verified: false, reason: `Mastodon fetch failed: ${err.message}` };
1703
+ }
1704
+ }
1705
+ var verifiers = {
1706
+ github: verifyGitHub,
1707
+ dns: verifyDNS,
1708
+ farcaster: verifyFarcaster,
1709
+ codeberg: verifyCodeberg,
1710
+ mastodon: verifyMastodon
1711
+ };
1712
+ async function verifyProof(proof, fingerprint, neynarApiKey) {
1713
+ const fn = verifiers[proof.provider];
1714
+ if (!fn) return { verified: false, reason: "Unknown provider" };
1715
+ return fn(proof, fingerprint, neynarApiKey);
1716
+ }
1717
+
1718
+ // src/core/authorization.ts
1719
+
1720
+ var EIP712_NAME = "Thurin PGPRegistry";
1721
+ var EIP712_VERSION = "2";
1722
+ function registryDomain(chainId, verifyingContract) {
1723
+ return { name: EIP712_NAME, version: EIP712_VERSION, chainId, verifyingContract };
1724
+ }
1725
+ var AUTHORIZATION_TYPES = {
1726
+ Attest: [
1727
+ { name: "owner", type: "address" },
1728
+ { name: "fingerprint", type: "bytes" },
1729
+ { name: "pgpSignature", type: "bytes" },
1730
+ { name: "pgpPublicKey", type: "bytes" },
1731
+ { name: "nonce", type: "uint256" },
1732
+ { name: "deadline", type: "uint256" }
1733
+ ],
1734
+ Reattest: [
1735
+ { name: "owner", type: "address" },
1736
+ { name: "revokeIndex", type: "uint256" },
1737
+ { name: "fingerprint", type: "bytes" },
1738
+ { name: "pgpSignature", type: "bytes" },
1739
+ { name: "pgpPublicKey", type: "bytes" },
1740
+ { name: "nonce", type: "uint256" },
1741
+ { name: "deadline", type: "uint256" }
1742
+ ],
1743
+ UpdateKey: [
1744
+ { name: "owner", type: "address" },
1745
+ { name: "index", type: "uint256" },
1746
+ { name: "pgpPublicKey", type: "bytes" },
1747
+ { name: "nonce", type: "uint256" },
1748
+ { name: "deadline", type: "uint256" }
1749
+ ],
1750
+ Revoke: [
1751
+ { name: "owner", type: "address" },
1752
+ { name: "index", type: "uint256" },
1753
+ { name: "nonce", type: "uint256" },
1754
+ { name: "deadline", type: "uint256" }
1755
+ ],
1756
+ SetRecord: [
1757
+ { name: "owner", type: "address" },
1758
+ { name: "index", type: "uint256" },
1759
+ { name: "kind", type: "bytes32" },
1760
+ { name: "value", type: "bytes" },
1761
+ { name: "nonce", type: "uint256" },
1762
+ { name: "deadline", type: "uint256" }
1763
+ ]
1764
+ };
1765
+ function attestTypedData(chainId, registry, a) {
1766
+ return {
1767
+ domain: registryDomain(chainId, registry),
1768
+ types: { Attest: AUTHORIZATION_TYPES.Attest },
1769
+ primaryType: "Attest",
1770
+ message: {
1771
+ owner: a.owner,
1772
+ fingerprint: fingerprintToBytes(a.fingerprint),
1773
+ pgpSignature: _viem.stringToHex.call(void 0, a.pgpSignature),
1774
+ pgpPublicKey: _viem.stringToHex.call(void 0, a.pgpPublicKey),
1775
+ nonce: a.nonce,
1776
+ deadline: a.deadline
1777
+ }
1778
+ };
1779
+ }
1780
+ function reattestTypedData(chainId, registry, a) {
1781
+ const base = attestTypedData(chainId, registry, a);
1782
+ return {
1783
+ domain: base.domain,
1784
+ types: { Reattest: AUTHORIZATION_TYPES.Reattest },
1785
+ primaryType: "Reattest",
1786
+ message: { ...base.message, revokeIndex: a.revokeIndex }
1787
+ };
1788
+ }
1789
+ function updateKeyTypedData(chainId, registry, a) {
1790
+ return {
1791
+ domain: registryDomain(chainId, registry),
1792
+ types: { UpdateKey: AUTHORIZATION_TYPES.UpdateKey },
1793
+ primaryType: "UpdateKey",
1794
+ message: { owner: a.owner, index: a.index, pgpPublicKey: _viem.stringToHex.call(void 0, a.pgpPublicKey), nonce: a.nonce, deadline: a.deadline }
1795
+ };
1796
+ }
1797
+ function revokeTypedData(chainId, registry, a) {
1798
+ return {
1799
+ domain: registryDomain(chainId, registry),
1800
+ types: { Revoke: AUTHORIZATION_TYPES.Revoke },
1801
+ primaryType: "Revoke",
1802
+ message: { owner: a.owner, index: a.index, nonce: a.nonce, deadline: a.deadline }
1803
+ };
1804
+ }
1805
+ function setRecordTypedData(chainId, registry, a) {
1806
+ return {
1807
+ domain: registryDomain(chainId, registry),
1808
+ types: { SetRecord: AUTHORIZATION_TYPES.SetRecord },
1809
+ primaryType: "SetRecord",
1810
+ message: { owner: a.owner, index: a.index, kind: a.kind, value: a.value, nonce: a.nonce, deadline: a.deadline }
1811
+ };
1812
+ }
1813
+ function authorizationDigest(typedData) {
1814
+ return _viem.hashTypedData.call(void 0, typedData);
1815
+ }
1816
+ function recordKind(name) {
1817
+ return _viem.keccak256.call(void 0, _viem.stringToHex.call(void 0, name));
1818
+ }
1819
+
1820
+
1821
+
1822
+
1823
+
1824
+
1825
+
1826
+
1827
+
1828
+
1829
+
1830
+
1831
+
1832
+
1833
+
1834
+
1835
+
1836
+
1837
+
1838
+
1839
+
1840
+
1841
+
1842
+
1843
+
1844
+
1845
+
1846
+
1847
+
1848
+
1849
+
1850
+
1851
+
1852
+
1853
+
1854
+
1855
+
1856
+ exports.REGISTRY_ABI = REGISTRY_ABI; exports.REGISTRY_ADDRESS = REGISTRY_ADDRESS; exports.NETWORKS = NETWORKS; exports.isNetworkName = isNetworkName; exports.getRegistry = getRegistry; exports.chainFor = chainFor; exports.normalizeFingerprint = normalizeFingerprint; exports.fingerprintToBytes = fingerprintToBytes; exports.bytesToFingerprint = bytesToFingerprint; exports.fingerprintHash = fingerprintHash; exports.keyIdOf = keyIdOf; exports.keyIdToBytes = keyIdToBytes; exports.parsePgpKey = parsePgpKey; exports.verifyAttestation = verifyAttestation; exports.stripEmailUserIDs = stripEmailUserIDs; exports.hasEmailUserID = hasEmailUserID; exports.fetchKeyByFingerprint = fetchKeyByFingerprint; exports.fetchKeyByKeyId = fetchKeyByKeyId; exports.fetchEFPGraph = fetchEFPGraph; exports.identifyProof = identifyProof; exports.displayUrl = displayUrl; exports.proofHref = proofHref; exports.proofSecondaryHref = proofSecondaryHref; exports.verifyProof = verifyProof; exports.EIP712_NAME = EIP712_NAME; exports.EIP712_VERSION = EIP712_VERSION; exports.registryDomain = registryDomain; exports.AUTHORIZATION_TYPES = AUTHORIZATION_TYPES; exports.attestTypedData = attestTypedData; exports.reattestTypedData = reattestTypedData; exports.updateKeyTypedData = updateKeyTypedData; exports.revokeTypedData = revokeTypedData; exports.setRecordTypedData = setRecordTypedData; exports.authorizationDigest = authorizationDigest; exports.recordKind = recordKind;
1857
+ //# sourceMappingURL=chunk-NL4LHKJX.cjs.map