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