@thurinlabs/identity-kit 1.2.0 → 1.3.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/README.md +21 -1
- package/dist/{chunk-Y4E5MMGR.js → chunk-4H57JHDJ.js} +133 -23
- package/dist/chunk-4H57JHDJ.js.map +1 -0
- package/dist/{chunk-JBWSRWL5.cjs → chunk-MYKKWPBY.cjs} +132 -22
- package/dist/chunk-MYKKWPBY.cjs.map +1 -0
- package/dist/core.cjs +20 -2
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +156 -61
- package/dist/core.d.ts +156 -61
- package/dist/core.js +23 -5
- package/dist/embed.global.js.map +1 -1
- package/dist/index.cjs +65 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +50 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-JBWSRWL5.cjs.map +0 -1
- package/dist/chunk-Y4E5MMGR.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,16 @@
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
var _chunkMYKKWPBYcjs = require('./chunk-MYKKWPBY.cjs');
|
|
44
53
|
|
|
45
54
|
// src/provider.tsx
|
|
46
55
|
var _react = require('react');
|
|
@@ -70,7 +79,7 @@ var defaultQueryClient = new (0, _reactquery.QueryClient)({
|
|
|
70
79
|
}
|
|
71
80
|
});
|
|
72
81
|
function createDefaultWagmiConfig(rpcUrl, network) {
|
|
73
|
-
const url = rpcUrl ||
|
|
82
|
+
const url = rpcUrl || _chunkMYKKWPBYcjs.getRegistry.call(void 0, network).defaultRpcUrl;
|
|
74
83
|
if (network === "sepolia") return _wagmi.createConfig.call(void 0, { chains: [_chains.sepolia], transports: { [_chains.sepolia.id]: _wagmi.http.call(void 0, url) } });
|
|
75
84
|
if (network === "local") return _wagmi.createConfig.call(void 0, { chains: [_chains.foundry], transports: { [_chains.foundry.id]: _wagmi.http.call(void 0, url) } });
|
|
76
85
|
return _wagmi.createConfig.call(void 0, { chains: [_chains.mainnet], transports: { [_chains.mainnet.id]: _wagmi.http.call(void 0, url) } });
|
|
@@ -113,12 +122,12 @@ var _ens = require('viem/ens');
|
|
|
113
122
|
var _viem = require('viem');
|
|
114
123
|
function useAttestations(address) {
|
|
115
124
|
const config = useIdentityKitConfig();
|
|
116
|
-
const registry =
|
|
117
|
-
const chain =
|
|
125
|
+
const registry = _chunkMYKKWPBYcjs.getRegistry.call(void 0, config.network, config.registryAddress);
|
|
126
|
+
const chain = _chunkMYKKWPBYcjs.chainFor.call(void 0, config.network);
|
|
118
127
|
const owner = address;
|
|
119
128
|
const { data: rows, isLoading: rowsLoading } = _wagmi.useReadContract.call(void 0, {
|
|
120
129
|
address: registry.address,
|
|
121
|
-
abi:
|
|
130
|
+
abi: _chunkMYKKWPBYcjs.REGISTRY_ABI,
|
|
122
131
|
functionName: "attestationsOf",
|
|
123
132
|
args: owner ? [owner] : void 0,
|
|
124
133
|
chainId: chain.id,
|
|
@@ -127,7 +136,7 @@ function useAttestations(address) {
|
|
|
127
136
|
const count = _nullishCoalesce(_optionalChain([rows, 'optionalAccess', _2 => _2.length]), () => ( 0));
|
|
128
137
|
const contracts = owner && rows ? rows.map((_, i) => ({
|
|
129
138
|
address: registry.address,
|
|
130
|
-
abi:
|
|
139
|
+
abi: _chunkMYKKWPBYcjs.REGISTRY_ABI,
|
|
131
140
|
functionName: "getPayload",
|
|
132
141
|
args: [owner, BigInt(i)],
|
|
133
142
|
chainId: chain.id
|
|
@@ -152,8 +161,8 @@ function useAttestations(address) {
|
|
|
152
161
|
pgpSignature = _viem.hexToString.call(void 0, sigHex);
|
|
153
162
|
pgpPublicKey = _viem.hexToString.call(void 0, keyHex);
|
|
154
163
|
}
|
|
155
|
-
const fingerprint =
|
|
156
|
-
const verification = pgpPublicKey && pgpSignature ? await
|
|
164
|
+
const fingerprint = _chunkMYKKWPBYcjs.bytesToFingerprint.call(void 0, row.fingerprint);
|
|
165
|
+
const verification = pgpPublicKey && pgpSignature ? await _chunkMYKKWPBYcjs.verifyAttestation.call(void 0, { pgpPublicKey, pgpSignature, fingerprint, ethAddress: address }) : null;
|
|
157
166
|
const revokedAt = Number(row.revokedAt);
|
|
158
167
|
results.push({
|
|
159
168
|
index: i,
|
|
@@ -190,7 +199,7 @@ function useAttestations(address) {
|
|
|
190
199
|
function useEFPGraph(address) {
|
|
191
200
|
const { data, isLoading } = _reactquery.useQuery.call(void 0, {
|
|
192
201
|
queryKey: ["efp-graph", address],
|
|
193
|
-
queryFn: () =>
|
|
202
|
+
queryFn: () => _chunkMYKKWPBYcjs.fetchEFPGraph.call(void 0, address),
|
|
194
203
|
enabled: !!address,
|
|
195
204
|
staleTime: 3e5
|
|
196
205
|
});
|
|
@@ -210,19 +219,19 @@ function usePGPProofs(fingerprint, armoredKey) {
|
|
|
210
219
|
queryKey: ["pgp-proofs", fingerprint, _nullishCoalesce(_optionalChain([armoredKey, 'optionalAccess', _6 => _6.length]), () => ( 0))],
|
|
211
220
|
queryFn: async () => {
|
|
212
221
|
if (!fingerprint || !armoredKey) return { keyInfo: null, proofs: [] };
|
|
213
|
-
const keyInfo = await
|
|
222
|
+
const keyInfo = await _chunkMYKKWPBYcjs.parsePgpKey.call(void 0, armoredKey);
|
|
214
223
|
if (!keyInfo) return { keyInfo: null, proofs: [] };
|
|
215
|
-
const identified = keyInfo.notations.map((n) =>
|
|
224
|
+
const identified = keyInfo.notations.map((n) => _chunkMYKKWPBYcjs.identifyProof.call(void 0, n)).filter((p) => p !== null && p.provider !== "unknown");
|
|
216
225
|
const proofs = await Promise.all(
|
|
217
226
|
identified.map(async (proof) => {
|
|
218
|
-
const result = await
|
|
227
|
+
const result = await _chunkMYKKWPBYcjs.verifyProof.call(void 0, proof, fingerprint, config.neynarApiKey);
|
|
219
228
|
return {
|
|
220
229
|
provider: proof.provider,
|
|
221
230
|
label: proof.label,
|
|
222
231
|
url: proof.url,
|
|
223
|
-
displayUrl:
|
|
224
|
-
href:
|
|
225
|
-
secondaryHref:
|
|
232
|
+
displayUrl: _chunkMYKKWPBYcjs.displayUrl.call(void 0, proof),
|
|
233
|
+
href: _chunkMYKKWPBYcjs.proofHref.call(void 0, proof),
|
|
234
|
+
secondaryHref: _chunkMYKKWPBYcjs.proofSecondaryHref.call(void 0, proof),
|
|
226
235
|
status: result.verified ? "verified" : "unverified",
|
|
227
236
|
reason: result.reason
|
|
228
237
|
};
|
|
@@ -264,7 +273,7 @@ function safeNormalize(name) {
|
|
|
264
273
|
}
|
|
265
274
|
}
|
|
266
275
|
function useThurinIdentity(ensOrAddress) {
|
|
267
|
-
const chain =
|
|
276
|
+
const chain = _chunkMYKKWPBYcjs.chainFor.call(void 0, useIdentityKitConfig().network);
|
|
268
277
|
const isAddr = ensOrAddress ? isAddress(ensOrAddress) : false;
|
|
269
278
|
const ensInput = ensOrAddress && !isAddr ? safeNormalize(ensOrAddress) : void 0;
|
|
270
279
|
const { data: resolvedAddress } = _wagmi.useEnsAddress.call(void 0, {
|
|
@@ -403,15 +412,41 @@ function safeNormalize2(name) {
|
|
|
403
412
|
}
|
|
404
413
|
}
|
|
405
414
|
function useEnsHint(name, verifiedFingerprint) {
|
|
406
|
-
const chain =
|
|
415
|
+
const chain = _chunkMYKKWPBYcjs.chainFor.call(void 0, useIdentityKitConfig().network);
|
|
407
416
|
const ensName = name ? safeNormalize2(name) : void 0;
|
|
408
417
|
const { data, isLoading, refetch } = _wagmi.useEnsText.call(void 0, {
|
|
409
418
|
name: ensName,
|
|
410
|
-
key:
|
|
419
|
+
key: _chunkMYKKWPBYcjs.ENS_HINT_KEY,
|
|
411
420
|
chainId: chain.id,
|
|
412
421
|
query: { enabled: !!ensName }
|
|
413
422
|
});
|
|
414
|
-
return { ...
|
|
423
|
+
return { ..._chunkMYKKWPBYcjs.ensHintFor.call(void 0, _nullishCoalesce(data, () => ( null)), verifiedFingerprint), isLoading: !!ensName && isLoading, refetch: () => {
|
|
424
|
+
void refetch();
|
|
425
|
+
} };
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// src/hooks/useRecords.ts
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
function useRecords(address, index, kinds = _chunkMYKKWPBYcjs.IDENTITY_KINDS) {
|
|
432
|
+
const config = useIdentityKitConfig();
|
|
433
|
+
const registry = _chunkMYKKWPBYcjs.getRegistry.call(void 0, config.network, config.registryAddress);
|
|
434
|
+
const chain = _chunkMYKKWPBYcjs.chainFor.call(void 0, config.network);
|
|
435
|
+
const owner = address;
|
|
436
|
+
const enabled = !!owner && index !== void 0 && index !== null;
|
|
437
|
+
const contracts = enabled ? kinds.map((kind) => ({ address: registry.address, abi: _chunkMYKKWPBYcjs.REGISTRY_ABI, functionName: "record", args: [owner, BigInt(index), _chunkMYKKWPBYcjs.recordKind.call(void 0, kind)], chainId: chain.id })) : [];
|
|
438
|
+
const { data: raw, isLoading: readLoading, refetch } = _wagmi.useReadContracts.call(void 0, { contracts, query: { enabled: contracts.length > 0 } });
|
|
439
|
+
const texts = (_nullishCoalesce(raw, () => ( []))).map((r) => r.status === "success" ? _chunkMYKKWPBYcjs.decodeRecord.call(void 0, r.result) : "");
|
|
440
|
+
const { data: records, isLoading: parseLoading } = _reactquery.useQuery.call(void 0, {
|
|
441
|
+
queryKey: ["records", config.network, registry.address, address, index, kinds.join(","), texts.join(" ")],
|
|
442
|
+
queryFn: async () => {
|
|
443
|
+
const out = [];
|
|
444
|
+
for (let i = 0; i < kinds.length; i++) if (texts[i]) out.push(await _chunkMYKKWPBYcjs.parseRecord.call(void 0, kinds[i], texts[i]));
|
|
445
|
+
return out;
|
|
446
|
+
},
|
|
447
|
+
enabled: enabled && raw !== void 0
|
|
448
|
+
});
|
|
449
|
+
return { records: _nullishCoalesce(records, () => ( [])), isLoading: enabled && (readLoading || parseLoading), refetch: () => {
|
|
415
450
|
void refetch();
|
|
416
451
|
} };
|
|
417
452
|
}
|
|
@@ -464,5 +499,15 @@ function useEnsHint(name, verifiedFingerprint) {
|
|
|
464
499
|
|
|
465
500
|
|
|
466
501
|
|
|
467
|
-
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
exports.AUTHORIZATION_TYPES = _chunkMYKKWPBYcjs.AUTHORIZATION_TYPES; exports.EIP712_NAME = _chunkMYKKWPBYcjs.EIP712_NAME; exports.EIP712_VERSION = _chunkMYKKWPBYcjs.EIP712_VERSION; exports.ENS_HINT_KEY = _chunkMYKKWPBYcjs.ENS_HINT_KEY; exports.ENS_TEXT_RESOLVER_ABI = _chunkMYKKWPBYcjs.ENS_TEXT_RESOLVER_ABI; exports.IDENTITY_KINDS = _chunkMYKKWPBYcjs.IDENTITY_KINDS; exports.IdentityKitProvider = IdentityKitProvider; exports.KNOWN_KINDS = _chunkMYKKWPBYcjs.KNOWN_KINDS; exports.MAX_RECORD_BYTES = _chunkMYKKWPBYcjs.MAX_RECORD_BYTES; exports.NETWORKS = _chunkMYKKWPBYcjs.NETWORKS; exports.REGISTRY_ABI = _chunkMYKKWPBYcjs.REGISTRY_ABI; exports.REGISTRY_ADDRESS = _chunkMYKKWPBYcjs.REGISTRY_ADDRESS; exports.ThurinCard = ThurinCard; exports.addPointer = _chunkMYKKWPBYcjs.addPointer; exports.attestTypedData = _chunkMYKKWPBYcjs.attestTypedData; exports.authorizationDigest = _chunkMYKKWPBYcjs.authorizationDigest; exports.bytesToFingerprint = _chunkMYKKWPBYcjs.bytesToFingerprint; exports.chainFor = _chunkMYKKWPBYcjs.chainFor; exports.decodeRecord = _chunkMYKKWPBYcjs.decodeRecord; exports.displayUrl = _chunkMYKKWPBYcjs.displayUrl; exports.encodeRecord = _chunkMYKKWPBYcjs.encodeRecord; exports.ensHintFor = _chunkMYKKWPBYcjs.ensHintFor; exports.ensHintValue = _chunkMYKKWPBYcjs.ensHintValue; exports.ensHintWrite = _chunkMYKKWPBYcjs.ensHintWrite; exports.fetchEFPGraph = _chunkMYKKWPBYcjs.fetchEFPGraph; exports.fetchEnsHint = _chunkMYKKWPBYcjs.fetchEnsHint; exports.fetchRecords = _chunkMYKKWPBYcjs.fetchRecords; exports.fingerprintHash = _chunkMYKKWPBYcjs.fingerprintHash; exports.fingerprintToBytes = _chunkMYKKWPBYcjs.fingerprintToBytes; exports.getRegistry = _chunkMYKKWPBYcjs.getRegistry; exports.hasEmailUserID = _chunkMYKKWPBYcjs.hasEmailUserID; exports.identifyProof = _chunkMYKKWPBYcjs.identifyProof; exports.isNetworkName = _chunkMYKKWPBYcjs.isNetworkName; exports.keyIdOf = _chunkMYKKWPBYcjs.keyIdOf; exports.keyIdToBytes = _chunkMYKKWPBYcjs.keyIdToBytes; exports.kindName = _chunkMYKKWPBYcjs.kindName; exports.normalizeFingerprint = _chunkMYKKWPBYcjs.normalizeFingerprint; exports.parsePgpKey = _chunkMYKKWPBYcjs.parsePgpKey; exports.parsePointer = _chunkMYKKWPBYcjs.parsePointer; exports.parseRecord = _chunkMYKKWPBYcjs.parseRecord; exports.proofHref = _chunkMYKKWPBYcjs.proofHref; exports.proofSecondaryHref = _chunkMYKKWPBYcjs.proofSecondaryHref; exports.reattestTypedData = _chunkMYKKWPBYcjs.reattestTypedData; exports.recordKind = _chunkMYKKWPBYcjs.recordKind; exports.registryDomain = _chunkMYKKWPBYcjs.registryDomain; exports.renderPointer = _chunkMYKKWPBYcjs.renderPointer; exports.revokeTypedData = _chunkMYKKWPBYcjs.revokeTypedData; exports.setRecordTypedData = _chunkMYKKWPBYcjs.setRecordTypedData; exports.stripEmailUserIDs = _chunkMYKKWPBYcjs.stripEmailUserIDs; exports.updateKeyTypedData = _chunkMYKKWPBYcjs.updateKeyTypedData; exports.useAttestations = useAttestations; exports.useEFPGraph = useEFPGraph; exports.useEnsHint = useEnsHint; exports.usePGPProofs = usePGPProofs; exports.useRecords = useRecords; exports.useThurinIdentity = useThurinIdentity; exports.verifyAttestation = _chunkMYKKWPBYcjs.verifyAttestation; exports.verifyProof = _chunkMYKKWPBYcjs.verifyProof;
|
|
468
513
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/ben/code/thurinlabs/identity-kit/dist/index.cjs","../src/provider.tsx","../src/context.ts","../src/hooks/useThurinIdentity.ts","../src/hooks/useAttestations.ts","../src/hooks/useEFPGraph.ts","../src/hooks/usePGPProofs.ts","../src/components/ThurinCard/ThurinCard.tsx","../src/hooks/useEnsHint.ts"],"names":["useQuery","jsx","safeNormalize","normalize"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC5CA,8BAAwC;AACxC,8BAA6D;AAC7D,sCAA0C;AAG1C,mDAAiD;AD4CjD;AACA;AElDA;AAGA,IAAM,cAAA,EAAmC;AAAA,EACvC,OAAA,EAAS,mBAAA;AAAA,EACT,OAAA,EAAS;AACX,CAAA;AAEO,IAAM,mBAAA,EAAqB,kCAAA,aAA8C,CAAA;AAEzE,SAAS,oBAAA,CAAA,EAA0C;AACxD,EAAA,OAAO,+BAAA,kBAA6B,CAAA;AACtC;AFgDA;AACA;ACpBW,+CAAA;AAhCX,IAAM,mBAAA,EAAqB,IAAI,4BAAA,CAAY;AAAA,EACzC,cAAA,EAAgB;AAAA,IACd,OAAA,EAAS;AAAA,MACP,SAA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AAA;AAASC,IAAAA;AAAwB,EAAA;AAAS,IAAA;AAAU,EAAA;AAC1D;AAO2B;AACX,EAAA;AACE,EAAA;AACF,EAAA;AACN,IAAA;AACD,IAAA;AACU,IAAA;AACN,IAAA;AACV,EAAA;AACW,EAAA;AAAgH,IAAA;AAAI,EAAA;AAClI;ARwYqB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/ben/code/thurinlabs/identity-kit/dist/index.cjs","sourcesContent":[null,"import { type ReactNode, useMemo } from 'react'\nimport { WagmiProvider, createConfig, http, useConfig } from 'wagmi'\nimport { mainnet, sepolia, foundry } from 'wagmi/chains'\nimport { getRegistry } from './core/contract'\nimport type { NetworkName } from './core/contract'\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query'\nimport { IdentityKitContext } from './context'\nimport type { IdentityKitConfig } from './core/types'\n\nconst defaultQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60_000,\n retry: 1,\n },\n },\n})\n\nexport { chainFor } from './core/contract'\n\nfunction createDefaultWagmiConfig(rpcUrl: string | undefined, network: NetworkName) {\n const url = rpcUrl || getRegistry(network).defaultRpcUrl\n // Spelled out per network: wagmi types `transports` by the exact chain ids.\n if (network === 'sepolia') return createConfig({ chains: [sepolia], transports: { [sepolia.id]: http(url) } })\n if (network === 'local') return createConfig({ chains: [foundry], transports: { [foundry.id]: http(url) } })\n return createConfig({ chains: [mainnet], transports: { [mainnet.id]: http(url) } })\n}\n\nfunction WagmiDetector({ children, rpcUrl, network }: { children: ReactNode; rpcUrl?: string; network: NetworkName }) {\n // Try to use existing wagmi config\n let hasWagmi = false\n try {\n useConfig()\n hasWagmi = true\n } catch {\n // No WagmiProvider above us\n }\n\n const wagmiConfig = useMemo(() => createDefaultWagmiConfig(rpcUrl, network), [rpcUrl, network])\n\n if (hasWagmi) {\n return <>{children}</>\n }\n\n return (\n <WagmiProvider config={wagmiConfig}>\n <QueryClientProvider client={defaultQueryClient}>\n {children}\n </QueryClientProvider>\n </WagmiProvider>\n )\n}\n\nexport interface IdentityKitProviderProps extends IdentityKitConfig {\n children: ReactNode\n}\n\nexport function IdentityKitProvider({\n children,\n rpcUrl,\n neynarApiKey,\n baseUrl = 'https://thurin.id',\n network = 'mainnet',\n registryAddress,\n}: IdentityKitProviderProps) {\n const config = useMemo(\n () => ({ rpcUrl, neynarApiKey, baseUrl, network, registryAddress }),\n [rpcUrl, neynarApiKey, baseUrl, network, registryAddress],\n )\n\n return (\n <IdentityKitContext.Provider value={config}>\n <WagmiDetector rpcUrl={rpcUrl} network={network}>\n {children}\n </WagmiDetector>\n </IdentityKitContext.Provider>\n )\n}\n","import { createContext, useContext } from 'react'\nimport type { IdentityKitConfig } from './core/types'\n\nconst defaultConfig: IdentityKitConfig = {\n baseUrl: 'https://thurin.id',\n network: 'mainnet',\n}\n\nexport const IdentityKitContext = createContext<IdentityKitConfig>(defaultConfig)\n\nexport function useIdentityKitConfig(): IdentityKitConfig {\n return useContext(IdentityKitContext)\n}\n","import { useEnsAddress, useEnsName, useEnsAvatar } from 'wagmi'\nimport { useIdentityKitConfig } from '../context'\nimport { chainFor } from '../provider'\nimport { normalize } from 'viem/ens'\nimport { useAttestations } from './useAttestations'\nimport { useEFPGraph } from './useEFPGraph'\nimport { usePGPProofs } from './usePGPProofs'\nimport type { ThurinIdentity } from '../core/types'\n\nfunction isAddress(value: string): boolean {\n return /^0x[0-9a-fA-F]{40}$/.test(value)\n}\n\nfunction safeNormalize(name: string): string | undefined {\n try {\n return normalize(name)\n } catch {\n return undefined\n }\n}\n\nexport function useThurinIdentity(ensOrAddress: string | undefined | null): ThurinIdentity {\n const chain = chainFor(useIdentityKitConfig().network)\n const isAddr = ensOrAddress ? isAddress(ensOrAddress) : false\n const ensInput = ensOrAddress && !isAddr ? safeNormalize(ensOrAddress) : undefined\n\n // Resolve ENS → address\n const { data: resolvedAddress } = useEnsAddress({\n name: ensInput,\n chainId: chain.id,\n query: { enabled: !!ensInput },\n })\n\n const address = isAddr ? ensOrAddress! : resolvedAddress ?? null\n\n // Reverse resolve address → ENS\n const { data: ensName } = useEnsName({\n address: address as `0x${string}` | undefined,\n chainId: chain.id,\n query: { enabled: !!address },\n })\n\n const displayName = ensInput || ensName || null\n\n const { data: ensAvatar } = useEnsAvatar({\n name: displayName ? safeNormalize(displayName) : undefined,\n chainId: chain.id,\n query: { enabled: !!displayName },\n })\n\n // On-chain attestations\n const {\n claims,\n totalClaims,\n activeClaims,\n currentFingerprint,\n isLoading: claimsLoading,\n } = useAttestations(address)\n\n // PGP proofs come from the key stored in the current attestation — the\n // latest claim that is active and whose signature verified (the same rule\n // useAttestations uses to pick currentFingerprint).\n const currentClaim = [...claims].reverse().find(\n (c) => !c.revoked && c.verification?.verified && c.fingerprint === currentFingerprint,\n )\n const {\n keyInfo: pgpKeyInfo,\n proofs,\n isLoading: proofsLoading,\n } = usePGPProofs(currentFingerprint, currentClaim?.pgpPublicKey ?? null)\n\n // EFP social graph\n const { efp, isLoading: efpLoading } = useEFPGraph(address)\n\n return {\n address,\n ensName: displayName,\n ensAvatar: ensAvatar ?? null,\n claims,\n totalClaims,\n activeClaims,\n currentFingerprint,\n pgpKeyInfo,\n proofs,\n efp,\n isLoading: claimsLoading || proofsLoading || efpLoading,\n error: null,\n }\n}\n","import { useReadContract, useReadContracts } from 'wagmi'\nimport { useQuery } from '@tanstack/react-query'\nimport { hexToString } from 'viem'\nimport { REGISTRY_ABI, getRegistry } from '../core/contract'\nimport { bytesToFingerprint } from '../core/fingerprint'\nimport { chainFor } from '../provider'\nimport { verifyAttestation } from '../core/pgp'\nimport { useIdentityKitConfig } from '../context'\nimport type { Attestation } from '../core/types'\n\n/**\n * On-chain attestations for an address, read straight from the v2 registry:\n * `attestationsOf` for the history, `getPayload` for each stored signature + key.\n * No event logs, so any RPC works. Each claim is verified off-chain.\n */\nexport function useAttestations(address: string | undefined | null) {\n const config = useIdentityKitConfig()\n const registry = getRegistry(config.network, config.registryAddress)\n const chain = chainFor(config.network)\n const owner = address as `0x${string}` | undefined\n\n const { data: rows, isLoading: rowsLoading } = useReadContract({\n address: registry.address,\n abi: REGISTRY_ABI,\n functionName: 'attestationsOf',\n args: owner ? [owner] : undefined,\n chainId: chain.id,\n query: { enabled: !!owner },\n })\n\n const count = rows?.length ?? 0\n\n const contracts = owner && rows\n ? rows.map((_, i) => ({\n address: registry.address,\n abi: REGISTRY_ABI,\n functionName: 'getPayload' as const,\n args: [owner, BigInt(i)] as const,\n chainId: chain.id,\n }))\n : []\n\n const { data: payloads, isLoading: payloadsLoading } = useReadContracts({\n contracts,\n query: { enabled: contracts.length > 0 },\n })\n\n const payloadsReady = count === 0 || (payloads !== undefined && payloads.length === count)\n\n const { data: claims, isLoading: verifyLoading } = useQuery({\n queryKey: ['attestations', config.network, registry.address, address, count, payloadsReady],\n queryFn: async (): Promise<Attestation[]> => {\n if (!rows || !address) return []\n const results: Attestation[] = []\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i]\n const payload = payloads?.[i]\n let pgpSignature: string | null = null\n let pgpPublicKey: string | null = null\n if (payload && payload.status === 'success') {\n const [sigHex, keyHex] = payload.result as readonly [`0x${string}`, `0x${string}`]\n pgpSignature = hexToString(sigHex)\n pgpPublicKey = hexToString(keyHex)\n }\n\n const fingerprint = bytesToFingerprint(row.fingerprint)\n const verification = pgpPublicKey && pgpSignature\n ? await verifyAttestation({ pgpPublicKey, pgpSignature, fingerprint, ethAddress: address })\n : null\n\n const revokedAt = Number(row.revokedAt)\n results.push({\n index: i,\n fingerprint,\n createdAt: Number(row.createdAt),\n revoked: revokedAt !== 0,\n revokedAt: revokedAt === 0 ? null : revokedAt,\n messageVersion: Number(row.messageVersion),\n pgpSignature,\n pgpPublicKey,\n verification,\n })\n }\n return results\n },\n enabled: !!rows && payloadsReady,\n staleTime: 300_000,\n })\n\n const isLoading = rowsLoading || payloadsLoading || verifyLoading || (!!owner && rows !== undefined && !payloadsReady)\n\n const activeClaims = (claims || []).filter((c) => !c.revoked)\n // The current identity is the latest claim that is both active and has a\n // verified signature binding the key to this address. A claim whose signature\n // has not verified must not surface the key's proofs or user data.\n const verifiedClaims = activeClaims.filter((c) => c.verification?.verified)\n const currentFingerprint = verifiedClaims.length > 0\n ? verifiedClaims[verifiedClaims.length - 1].fingerprint\n : null\n\n return {\n claims: claims || [],\n totalClaims: count,\n activeClaims: activeClaims.length,\n currentFingerprint,\n isLoading,\n }\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { fetchEFPGraph } from '../core/efp'\nimport type { EFPGraph } from '../core/types'\n\nexport function useEFPGraph(address: string | undefined | null) {\n const { data, isLoading } = useQuery<EFPGraph | null>({\n queryKey: ['efp-graph', address],\n queryFn: () => fetchEFPGraph(address!),\n enabled: !!address,\n staleTime: 300_000,\n })\n\n return {\n efp: data ?? null,\n isLoading,\n }\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { parsePgpKey } from '../core/pgp'\nimport { identifyProof, verifyProof, displayUrl, proofHref, proofSecondaryHref } from '../core/proofs'\nimport { useIdentityKitConfig } from '../context'\nimport type { PGPKeyInfo, ProofResult } from '../core/types'\n\n/**\n * Proofs for an identity, read from the PGP key stored in its on-chain\n * attestation. No keyserver is consulted: keys.openpgp.org only serves user\n * IDs whose email is verified and drops non-email user IDs entirely, so it can\n * never carry the published (non-email) identity that holds the notations.\n *\n * @param fingerprint the attested fingerprint (proofs must name it)\n * @param armoredKey the attestation's `pgpPublicKey`\n */\nexport function usePGPProofs(fingerprint: string | undefined | null, armoredKey: string | undefined | null) {\n const config = useIdentityKitConfig()\n\n const { data } = useQuery({\n // The key is large; key the query on its length + fingerprint, which\n // changes whenever a different attestation's key is supplied.\n queryKey: ['pgp-proofs', fingerprint, armoredKey?.length ?? 0],\n queryFn: async (): Promise<{ keyInfo: PGPKeyInfo | null; proofs: ProofResult[] }> => {\n if (!fingerprint || !armoredKey) return { keyInfo: null, proofs: [] }\n\n const keyInfo = await parsePgpKey(armoredKey)\n if (!keyInfo) return { keyInfo: null, proofs: [] }\n\n // Identify proofs from notations. Drop unrecognized targets (provider\n // 'unknown') so the card doesn't render \"Unknown\" badges for platforms\n // Thurin has no verifier for — matching the explorer's behavior.\n const identified = keyInfo.notations\n .map((n) => identifyProof(n))\n .filter((p): p is NonNullable<typeof p> => p !== null && p.provider !== 'unknown')\n\n // Verify all proofs in parallel\n const proofs: ProofResult[] = await Promise.all(\n identified.map(async (proof) => {\n const result = await verifyProof(proof, fingerprint, config.neynarApiKey)\n return {\n provider: proof.provider,\n label: proof.label,\n url: proof.url,\n displayUrl: displayUrl(proof),\n href: proofHref(proof),\n secondaryHref: proofSecondaryHref(proof),\n status: result.verified ? 'verified' as const : 'unverified' as const,\n reason: result.reason,\n }\n }),\n )\n\n // Collapse proofs that resolve to the same account — the same target is\n // often listed under both proof@thurin.id and proof@ariadne.id (and can\n // be reached via more than one proof URL). Key by provider + display\n // identity, preferring a verified result.\n const byAccount = new Map<string, ProofResult>()\n for (const p of proofs) {\n const key = `${p.provider}:${p.displayUrl}`\n const prev = byAccount.get(key)\n if (!prev || (p.status === 'verified' && prev.status !== 'verified')) {\n byAccount.set(key, p)\n }\n }\n\n return { keyInfo, proofs: [...byAccount.values()] }\n },\n enabled: !!fingerprint && !!armoredKey,\n staleTime: 300_000,\n })\n\n return {\n keyInfo: data?.keyInfo ?? null,\n proofs: data?.proofs ?? [],\n // Report loading whenever a fingerprint is set but its proofs haven't\n // resolved yet. Using react-query's own isLoading leaves a gap while the\n // query is enabling (fingerprint just became known), during which the card\n // would briefly paint without proof badges and then pop them in.\n isLoading: !!fingerprint && !!armoredKey && data === undefined,\n }\n}\n","import { useThurinIdentity } from '../../hooks/useThurinIdentity'\nimport { useIdentityKitConfig } from '../../context'\nimport type { Theme } from '../../core/types'\nimport '../../themes/index.css'\nimport './ThurinCard.css'\n\nfunction ThurinLogo() {\n return (\n <svg className=\"thurin-card-avatar-placeholder\" viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"50\" cy=\"50\" r=\"50\" fill=\"var(--thurin-surface-deep)\" />\n <path d=\"M25 80 Q25 25 50 25 Q75 25 75 50\" fill=\"none\" stroke=\"#7c9a3e\" strokeWidth=\"4\" strokeLinecap=\"round\"/>\n <path d=\"M33 75 Q33 35 50 35 Q67 35 67 52\" fill=\"none\" stroke=\"#7c9a3e\" strokeWidth=\"4\" strokeLinecap=\"round\"/>\n <path d=\"M41 70 Q41 45 50 45 Q59 45 59 55\" fill=\"none\" stroke=\"#c9a227\" strokeWidth=\"4\" strokeLinecap=\"round\"/>\n <path d=\"M50 65 L50 53\" fill=\"none\" stroke=\"#c9a227\" strokeWidth=\"4\" strokeLinecap=\"round\"/>\n </svg>\n )\n}\n\nexport interface ThurinCardProps {\n ens?: string\n address?: string\n theme?: Theme\n}\n\nexport function ThurinCard({ ens, address, theme = 'thurin' }: ThurinCardProps) {\n const input = ens || address\n const identity = useThurinIdentity(input)\n const config = useIdentityKitConfig()\n\n const profileUrl = identity.address\n ? `${config.baseUrl}/eth/${identity.address}`\n : ens\n ? `${config.baseUrl}/ens/${ens}`\n : null\n\n if (identity.isLoading) {\n return (\n <div className=\"thurin-card\" data-thurin-theme={theme}>\n <div className=\"thurin-card-loading\">Loading identity...</div>\n </div>\n )\n }\n\n const displayAddress = identity.address || null\n\n const verifiedProofs = identity.proofs.filter((p) => p.status === 'verified').length\n const hasVerifiedPgp = identity.claims.some((c) => c.verification?.verified && !c.revoked)\n\n return (\n <div className=\"thurin-card\" data-thurin-theme={theme}>\n <a className=\"thurin-card-header\" href={profileUrl || undefined} target=\"_blank\" rel=\"noopener noreferrer\">\n {identity.ensAvatar ? (\n <img\n className=\"thurin-card-avatar\"\n src={identity.ensAvatar}\n alt={identity.ensName || ''}\n />\n ) : (\n <ThurinLogo />\n )}\n <div>\n {identity.ensName && (\n <div className=\"thurin-card-name\">{identity.ensName}</div>\n )}\n {displayAddress && (\n <div className=\"thurin-card-address\">{displayAddress}</div>\n )}\n </div>\n </a>\n\n <div className=\"thurin-card-stats\">\n <div className=\"thurin-card-stat\">\n <span className=\"thurin-card-stat-value\">{identity.activeClaims}</span>\n <span className=\"thurin-card-stat-label\">Attestations</span>\n </div>\n <div className=\"thurin-card-stat\">\n <span className=\"thurin-card-stat-value\">{verifiedProofs}</span>\n <span className=\"thurin-card-stat-label\">Proofs</span>\n </div>\n <div className=\"thurin-card-stat\">\n <span className=\"thurin-card-stat-value\">\n {identity.efp?.followers ?? 0}\n </span>\n <span className=\"thurin-card-stat-label\">Followers</span>\n </div>\n </div>\n\n <div className=\"thurin-card-badges\">\n {hasVerifiedPgp && (\n <span className=\"thurin-card-badge thurin-card-badge--verified\">PGP Verified</span>\n )}\n {identity.efp?.hasEfp && (\n <span className=\"thurin-card-badge thurin-card-badge--verified\">EFP</span>\n )}\n {identity.proofs.map((p, i) => (\n <span\n key={i}\n className={`thurin-card-badge thurin-card-badge--${p.status === 'verified' ? 'verified' : 'unverified'}`}\n >\n {p.label}\n </span>\n ))}\n </div>\n\n {profileUrl && (\n <a\n className=\"thurin-card-link\"\n href={profileUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n View on Thurin\n </a>\n )}\n </div>\n )\n}\n","import { useEnsText } from 'wagmi'\nimport { normalize } from 'viem/ens'\nimport { useIdentityKitConfig } from '../context'\nimport { chainFor } from '../provider'\nimport { ENS_HINT_KEY, ensHintFor, type EnsHint } from '../core/ensHint'\n\nfunction safeNormalize(name: string): string | undefined {\n try { return normalize(name) } catch { return undefined }\n}\n\n/**\n * A name's `id.thurin` record against the fingerprint the registry verifies for its\n * address. `state` is `match`, `unset`, or `mismatch`; the last one is the signal worth\n * showing — a name advertising a key its address has not claimed.\n */\nexport function useEnsHint(name: string | undefined | null, verifiedFingerprint: string | null | undefined): EnsHint & { isLoading: boolean; refetch: () => void } {\n const chain = chainFor(useIdentityKitConfig().network)\n const ensName = name ? safeNormalize(name) : undefined\n const { data, isLoading, refetch } = useEnsText({\n name: ensName,\n key: ENS_HINT_KEY,\n chainId: chain.id,\n query: { enabled: !!ensName },\n })\n return { ...ensHintFor(data ?? null, verifiedFingerprint), isLoading: !!ensName && isLoading, refetch: () => { void refetch() } }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/ben/code/thurinlabs/identity-kit/dist/index.cjs","../src/provider.tsx","../src/context.ts","../src/hooks/useThurinIdentity.ts","../src/hooks/useAttestations.ts","../src/hooks/useEFPGraph.ts","../src/hooks/usePGPProofs.ts","../src/components/ThurinCard/ThurinCard.tsx","../src/hooks/useEnsHint.ts","../src/hooks/useRecords.ts"],"names":["useQuery","jsx","safeNormalize","normalize"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACrDA,8BAAwC;AACxC,8BAA6D;AAC7D,sCAA0C;AAG1C,mDAAiD;ADqDjD;AACA;AE3DA;AAGA,IAAM,cAAA,EAAmC;AAAA,EACvC,OAAA,EAAS,mBAAA;AAAA,EACT,OAAA,EAAS;AACX,CAAA;AAEO,IAAM,mBAAA,EAAqB,kCAAA,aAA8C,CAAA;AAEzE,SAAS,oBAAA,CAAA,EAA0C;AACxD,EAAA,OAAO,+BAAA,kBAA6B,CAAA;AACtC;AFyDA;AACA;AC7BW,+CAAA;AAhCX,IAAM,mBAAA,EAAqB,IAAI,4BAAA,CAAY;AAAA,EACz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AA;AAEJ;AP8RqB;AACA;AQnZZ;AACA;AAKAC;AACH,EAAA;AAASC,IAAAA;AAAwB,EAAA;AAAS,IAAA;AAAU,EAAA;AAC1D;AAO2B;AACX,EAAA;AACE,EAAA;AACF,EAAA;AACN,IAAA;AACD,IAAA;AACU,IAAA;AACN,IAAA;AACV,EAAA;AACW,EAAA;AAAgH,IAAA;AAAI,EAAA;AAClI;ARiZqB;AACA;AS3aZ;AACAH;AAUkB;AACV,EAAA;AACE,EAAA;AACH,EAAA;AACA,EAAA;AACI,EAAA;AAEA,EAAA;AAGC,EAAA;AAEJ,EAAA;AACD,EAAA;AACD,IAAA;AACF,IAAA;AACsB,MAAA;AAChB,MAAA;AACN,MAAA;AACT,IAAA;AACS,IAAA;AACV,EAAA;AAEiB,EAAA;AAAkG,IAAA;AAAI,EAAA;AAC1H;ATiaqB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/ben/code/thurinlabs/identity-kit/dist/index.cjs","sourcesContent":[null,"import { type ReactNode, useMemo } from 'react'\nimport { WagmiProvider, createConfig, http, useConfig } from 'wagmi'\nimport { mainnet, sepolia, foundry } from 'wagmi/chains'\nimport { getRegistry } from './core/contract'\nimport type { NetworkName } from './core/contract'\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query'\nimport { IdentityKitContext } from './context'\nimport type { IdentityKitConfig } from './core/types'\n\nconst defaultQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60_000,\n retry: 1,\n },\n },\n})\n\nexport { chainFor } from './core/contract'\n\nfunction createDefaultWagmiConfig(rpcUrl: string | undefined, network: NetworkName) {\n const url = rpcUrl || getRegistry(network).defaultRpcUrl\n // Spelled out per network: wagmi types `transports` by the exact chain ids.\n if (network === 'sepolia') return createConfig({ chains: [sepolia], transports: { [sepolia.id]: http(url) } })\n if (network === 'local') return createConfig({ chains: [foundry], transports: { [foundry.id]: http(url) } })\n return createConfig({ chains: [mainnet], transports: { [mainnet.id]: http(url) } })\n}\n\nfunction WagmiDetector({ children, rpcUrl, network }: { children: ReactNode; rpcUrl?: string; network: NetworkName }) {\n // Try to use existing wagmi config\n let hasWagmi = false\n try {\n useConfig()\n hasWagmi = true\n } catch {\n // No WagmiProvider above us\n }\n\n const wagmiConfig = useMemo(() => createDefaultWagmiConfig(rpcUrl, network), [rpcUrl, network])\n\n if (hasWagmi) {\n return <>{children}</>\n }\n\n return (\n <WagmiProvider config={wagmiConfig}>\n <QueryClientProvider client={defaultQueryClient}>\n {children}\n </QueryClientProvider>\n </WagmiProvider>\n )\n}\n\nexport interface IdentityKitProviderProps extends IdentityKitConfig {\n children: ReactNode\n}\n\nexport function IdentityKitProvider({\n children,\n rpcUrl,\n neynarApiKey,\n baseUrl = 'https://thurin.id',\n network = 'mainnet',\n registryAddress,\n}: IdentityKitProviderProps) {\n const config = useMemo(\n () => ({ rpcUrl, neynarApiKey, baseUrl, network, registryAddress }),\n [rpcUrl, neynarApiKey, baseUrl, network, registryAddress],\n )\n\n return (\n <IdentityKitContext.Provider value={config}>\n <WagmiDetector rpcUrl={rpcUrl} network={network}>\n {children}\n </WagmiDetector>\n </IdentityKitContext.Provider>\n )\n}\n","import { createContext, useContext } from 'react'\nimport type { IdentityKitConfig } from './core/types'\n\nconst defaultConfig: IdentityKitConfig = {\n baseUrl: 'https://thurin.id',\n network: 'mainnet',\n}\n\nexport const IdentityKitContext = createContext<IdentityKitConfig>(defaultConfig)\n\nexport function useIdentityKitConfig(): IdentityKitConfig {\n return useContext(IdentityKitContext)\n}\n","import { useEnsAddress, useEnsName, useEnsAvatar } from 'wagmi'\nimport { useIdentityKitConfig } from '../context'\nimport { chainFor } from '../provider'\nimport { normalize } from 'viem/ens'\nimport { useAttestations } from './useAttestations'\nimport { useEFPGraph } from './useEFPGraph'\nimport { usePGPProofs } from './usePGPProofs'\nimport type { ThurinIdentity } from '../core/types'\n\nfunction isAddress(value: string): boolean {\n return /^0x[0-9a-fA-F]{40}$/.test(value)\n}\n\nfunction safeNormalize(name: string): string | undefined {\n try {\n return normalize(name)\n } catch {\n return undefined\n }\n}\n\nexport function useThurinIdentity(ensOrAddress: string | undefined | null): ThurinIdentity {\n const chain = chainFor(useIdentityKitConfig().network)\n const isAddr = ensOrAddress ? isAddress(ensOrAddress) : false\n const ensInput = ensOrAddress && !isAddr ? safeNormalize(ensOrAddress) : undefined\n\n // Resolve ENS → address\n const { data: resolvedAddress } = useEnsAddress({\n name: ensInput,\n chainId: chain.id,\n query: { enabled: !!ensInput },\n })\n\n const address = isAddr ? ensOrAddress! : resolvedAddress ?? null\n\n // Reverse resolve address → ENS\n const { data: ensName } = useEnsName({\n address: address as `0x${string}` | undefined,\n chainId: chain.id,\n query: { enabled: !!address },\n })\n\n const displayName = ensInput || ensName || null\n\n const { data: ensAvatar } = useEnsAvatar({\n name: displayName ? safeNormalize(displayName) : undefined,\n chainId: chain.id,\n query: { enabled: !!displayName },\n })\n\n // On-chain attestations\n const {\n claims,\n totalClaims,\n activeClaims,\n currentFingerprint,\n isLoading: claimsLoading,\n } = useAttestations(address)\n\n // PGP proofs come from the key stored in the current attestation — the\n // latest claim that is active and whose signature verified (the same rule\n // useAttestations uses to pick currentFingerprint).\n const currentClaim = [...claims].reverse().find(\n (c) => !c.revoked && c.verification?.verified && c.fingerprint === currentFingerprint,\n )\n const {\n keyInfo: pgpKeyInfo,\n proofs,\n isLoading: proofsLoading,\n } = usePGPProofs(currentFingerprint, currentClaim?.pgpPublicKey ?? null)\n\n // EFP social graph\n const { efp, isLoading: efpLoading } = useEFPGraph(address)\n\n return {\n address,\n ensName: displayName,\n ensAvatar: ensAvatar ?? null,\n claims,\n totalClaims,\n activeClaims,\n currentFingerprint,\n pgpKeyInfo,\n proofs,\n efp,\n isLoading: claimsLoading || proofsLoading || efpLoading,\n error: null,\n }\n}\n","import { useReadContract, useReadContracts } from 'wagmi'\nimport { useQuery } from '@tanstack/react-query'\nimport { hexToString } from 'viem'\nimport { REGISTRY_ABI, getRegistry } from '../core/contract'\nimport { bytesToFingerprint } from '../core/fingerprint'\nimport { chainFor } from '../provider'\nimport { verifyAttestation } from '../core/pgp'\nimport { useIdentityKitConfig } from '../context'\nimport type { Attestation } from '../core/types'\n\n/**\n * On-chain attestations for an address, read straight from the v2 registry:\n * `attestationsOf` for the history, `getPayload` for each stored signature + key.\n * No event logs, so any RPC works. Each claim is verified off-chain.\n */\nexport function useAttestations(address: string | undefined | null) {\n const config = useIdentityKitConfig()\n const registry = getRegistry(config.network, config.registryAddress)\n const chain = chainFor(config.network)\n const owner = address as `0x${string}` | undefined\n\n const { data: rows, isLoading: rowsLoading } = useReadContract({\n address: registry.address,\n abi: REGISTRY_ABI,\n functionName: 'attestationsOf',\n args: owner ? [owner] : undefined,\n chainId: chain.id,\n query: { enabled: !!owner },\n })\n\n const count = rows?.length ?? 0\n\n const contracts = owner && rows\n ? rows.map((_, i) => ({\n address: registry.address,\n abi: REGISTRY_ABI,\n functionName: 'getPayload' as const,\n args: [owner, BigInt(i)] as const,\n chainId: chain.id,\n }))\n : []\n\n const { data: payloads, isLoading: payloadsLoading } = useReadContracts({\n contracts,\n query: { enabled: contracts.length > 0 },\n })\n\n const payloadsReady = count === 0 || (payloads !== undefined && payloads.length === count)\n\n const { data: claims, isLoading: verifyLoading } = useQuery({\n queryKey: ['attestations', config.network, registry.address, address, count, payloadsReady],\n queryFn: async (): Promise<Attestation[]> => {\n if (!rows || !address) return []\n const results: Attestation[] = []\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i]\n const payload = payloads?.[i]\n let pgpSignature: string | null = null\n let pgpPublicKey: string | null = null\n if (payload && payload.status === 'success') {\n const [sigHex, keyHex] = payload.result as readonly [`0x${string}`, `0x${string}`]\n pgpSignature = hexToString(sigHex)\n pgpPublicKey = hexToString(keyHex)\n }\n\n const fingerprint = bytesToFingerprint(row.fingerprint)\n const verification = pgpPublicKey && pgpSignature\n ? await verifyAttestation({ pgpPublicKey, pgpSignature, fingerprint, ethAddress: address })\n : null\n\n const revokedAt = Number(row.revokedAt)\n results.push({\n index: i,\n fingerprint,\n createdAt: Number(row.createdAt),\n revoked: revokedAt !== 0,\n revokedAt: revokedAt === 0 ? null : revokedAt,\n messageVersion: Number(row.messageVersion),\n pgpSignature,\n pgpPublicKey,\n verification,\n })\n }\n return results\n },\n enabled: !!rows && payloadsReady,\n staleTime: 300_000,\n })\n\n const isLoading = rowsLoading || payloadsLoading || verifyLoading || (!!owner && rows !== undefined && !payloadsReady)\n\n const activeClaims = (claims || []).filter((c) => !c.revoked)\n // The current identity is the latest claim that is both active and has a\n // verified signature binding the key to this address. A claim whose signature\n // has not verified must not surface the key's proofs or user data.\n const verifiedClaims = activeClaims.filter((c) => c.verification?.verified)\n const currentFingerprint = verifiedClaims.length > 0\n ? verifiedClaims[verifiedClaims.length - 1].fingerprint\n : null\n\n return {\n claims: claims || [],\n totalClaims: count,\n activeClaims: activeClaims.length,\n currentFingerprint,\n isLoading,\n }\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { fetchEFPGraph } from '../core/efp'\nimport type { EFPGraph } from '../core/types'\n\nexport function useEFPGraph(address: string | undefined | null) {\n const { data, isLoading } = useQuery<EFPGraph | null>({\n queryKey: ['efp-graph', address],\n queryFn: () => fetchEFPGraph(address!),\n enabled: !!address,\n staleTime: 300_000,\n })\n\n return {\n efp: data ?? null,\n isLoading,\n }\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { parsePgpKey } from '../core/pgp'\nimport { identifyProof, verifyProof, displayUrl, proofHref, proofSecondaryHref } from '../core/proofs'\nimport { useIdentityKitConfig } from '../context'\nimport type { PGPKeyInfo, ProofResult } from '../core/types'\n\n/**\n * Proofs for an identity, read from the PGP key stored in its on-chain\n * attestation. No keyserver is consulted: keys.openpgp.org only serves user\n * IDs whose email is verified and drops non-email user IDs entirely, so it can\n * never carry the published (non-email) identity that holds the notations.\n *\n * @param fingerprint the attested fingerprint (proofs must name it)\n * @param armoredKey the attestation's `pgpPublicKey`\n */\nexport function usePGPProofs(fingerprint: string | undefined | null, armoredKey: string | undefined | null) {\n const config = useIdentityKitConfig()\n\n const { data } = useQuery({\n // The key is large; key the query on its length + fingerprint, which\n // changes whenever a different attestation's key is supplied.\n queryKey: ['pgp-proofs', fingerprint, armoredKey?.length ?? 0],\n queryFn: async (): Promise<{ keyInfo: PGPKeyInfo | null; proofs: ProofResult[] }> => {\n if (!fingerprint || !armoredKey) return { keyInfo: null, proofs: [] }\n\n const keyInfo = await parsePgpKey(armoredKey)\n if (!keyInfo) return { keyInfo: null, proofs: [] }\n\n // Identify proofs from notations. Drop unrecognized targets (provider\n // 'unknown') so the card doesn't render \"Unknown\" badges for platforms\n // Thurin has no verifier for — matching the explorer's behavior.\n const identified = keyInfo.notations\n .map((n) => identifyProof(n))\n .filter((p): p is NonNullable<typeof p> => p !== null && p.provider !== 'unknown')\n\n // Verify all proofs in parallel\n const proofs: ProofResult[] = await Promise.all(\n identified.map(async (proof) => {\n const result = await verifyProof(proof, fingerprint, config.neynarApiKey)\n return {\n provider: proof.provider,\n label: proof.label,\n url: proof.url,\n displayUrl: displayUrl(proof),\n href: proofHref(proof),\n secondaryHref: proofSecondaryHref(proof),\n status: result.verified ? 'verified' as const : 'unverified' as const,\n reason: result.reason,\n }\n }),\n )\n\n // Collapse proofs that resolve to the same account — the same target is\n // often listed under both proof@thurin.id and proof@ariadne.id (and can\n // be reached via more than one proof URL). Key by provider + display\n // identity, preferring a verified result.\n const byAccount = new Map<string, ProofResult>()\n for (const p of proofs) {\n const key = `${p.provider}:${p.displayUrl}`\n const prev = byAccount.get(key)\n if (!prev || (p.status === 'verified' && prev.status !== 'verified')) {\n byAccount.set(key, p)\n }\n }\n\n return { keyInfo, proofs: [...byAccount.values()] }\n },\n enabled: !!fingerprint && !!armoredKey,\n staleTime: 300_000,\n })\n\n return {\n keyInfo: data?.keyInfo ?? null,\n proofs: data?.proofs ?? [],\n // Report loading whenever a fingerprint is set but its proofs haven't\n // resolved yet. Using react-query's own isLoading leaves a gap while the\n // query is enabling (fingerprint just became known), during which the card\n // would briefly paint without proof badges and then pop them in.\n isLoading: !!fingerprint && !!armoredKey && data === undefined,\n }\n}\n","import { useThurinIdentity } from '../../hooks/useThurinIdentity'\nimport { useIdentityKitConfig } from '../../context'\nimport type { Theme } from '../../core/types'\nimport '../../themes/index.css'\nimport './ThurinCard.css'\n\nfunction ThurinLogo() {\n return (\n <svg className=\"thurin-card-avatar-placeholder\" viewBox=\"0 0 100 100\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"50\" cy=\"50\" r=\"50\" fill=\"var(--thurin-surface-deep)\" />\n <path d=\"M25 80 Q25 25 50 25 Q75 25 75 50\" fill=\"none\" stroke=\"#7c9a3e\" strokeWidth=\"4\" strokeLinecap=\"round\"/>\n <path d=\"M33 75 Q33 35 50 35 Q67 35 67 52\" fill=\"none\" stroke=\"#7c9a3e\" strokeWidth=\"4\" strokeLinecap=\"round\"/>\n <path d=\"M41 70 Q41 45 50 45 Q59 45 59 55\" fill=\"none\" stroke=\"#c9a227\" strokeWidth=\"4\" strokeLinecap=\"round\"/>\n <path d=\"M50 65 L50 53\" fill=\"none\" stroke=\"#c9a227\" strokeWidth=\"4\" strokeLinecap=\"round\"/>\n </svg>\n )\n}\n\nexport interface ThurinCardProps {\n ens?: string\n address?: string\n theme?: Theme\n}\n\nexport function ThurinCard({ ens, address, theme = 'thurin' }: ThurinCardProps) {\n const input = ens || address\n const identity = useThurinIdentity(input)\n const config = useIdentityKitConfig()\n\n const profileUrl = identity.address\n ? `${config.baseUrl}/eth/${identity.address}`\n : ens\n ? `${config.baseUrl}/ens/${ens}`\n : null\n\n if (identity.isLoading) {\n return (\n <div className=\"thurin-card\" data-thurin-theme={theme}>\n <div className=\"thurin-card-loading\">Loading identity...</div>\n </div>\n )\n }\n\n const displayAddress = identity.address || null\n\n const verifiedProofs = identity.proofs.filter((p) => p.status === 'verified').length\n const hasVerifiedPgp = identity.claims.some((c) => c.verification?.verified && !c.revoked)\n\n return (\n <div className=\"thurin-card\" data-thurin-theme={theme}>\n <a className=\"thurin-card-header\" href={profileUrl || undefined} target=\"_blank\" rel=\"noopener noreferrer\">\n {identity.ensAvatar ? (\n <img\n className=\"thurin-card-avatar\"\n src={identity.ensAvatar}\n alt={identity.ensName || ''}\n />\n ) : (\n <ThurinLogo />\n )}\n <div>\n {identity.ensName && (\n <div className=\"thurin-card-name\">{identity.ensName}</div>\n )}\n {displayAddress && (\n <div className=\"thurin-card-address\">{displayAddress}</div>\n )}\n </div>\n </a>\n\n <div className=\"thurin-card-stats\">\n <div className=\"thurin-card-stat\">\n <span className=\"thurin-card-stat-value\">{identity.activeClaims}</span>\n <span className=\"thurin-card-stat-label\">Attestations</span>\n </div>\n <div className=\"thurin-card-stat\">\n <span className=\"thurin-card-stat-value\">{verifiedProofs}</span>\n <span className=\"thurin-card-stat-label\">Proofs</span>\n </div>\n <div className=\"thurin-card-stat\">\n <span className=\"thurin-card-stat-value\">\n {identity.efp?.followers ?? 0}\n </span>\n <span className=\"thurin-card-stat-label\">Followers</span>\n </div>\n </div>\n\n <div className=\"thurin-card-badges\">\n {hasVerifiedPgp && (\n <span className=\"thurin-card-badge thurin-card-badge--verified\">PGP Verified</span>\n )}\n {identity.efp?.hasEfp && (\n <span className=\"thurin-card-badge thurin-card-badge--verified\">EFP</span>\n )}\n {identity.proofs.map((p, i) => (\n <span\n key={i}\n className={`thurin-card-badge thurin-card-badge--${p.status === 'verified' ? 'verified' : 'unverified'}`}\n >\n {p.label}\n </span>\n ))}\n </div>\n\n {profileUrl && (\n <a\n className=\"thurin-card-link\"\n href={profileUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n View on Thurin\n </a>\n )}\n </div>\n )\n}\n","import { useEnsText } from 'wagmi'\nimport { normalize } from 'viem/ens'\nimport { useIdentityKitConfig } from '../context'\nimport { chainFor } from '../provider'\nimport { ENS_HINT_KEY, ensHintFor, type EnsHint } from '../core/ensHint'\n\nfunction safeNormalize(name: string): string | undefined {\n try { return normalize(name) } catch { return undefined }\n}\n\n/**\n * A name's `id.thurin` record against the fingerprint the registry verifies for its\n * address. `state` is `match`, `unset`, or `mismatch`; the last one is the signal worth\n * showing — a name advertising a key its address has not claimed.\n */\nexport function useEnsHint(name: string | undefined | null, verifiedFingerprint: string | null | undefined): EnsHint & { isLoading: boolean; refetch: () => void } {\n const chain = chainFor(useIdentityKitConfig().network)\n const ensName = name ? safeNormalize(name) : undefined\n const { data, isLoading, refetch } = useEnsText({\n name: ensName,\n key: ENS_HINT_KEY,\n chainId: chain.id,\n query: { enabled: !!ensName },\n })\n return { ...ensHintFor(data ?? null, verifiedFingerprint), isLoading: !!ensName && isLoading, refetch: () => { void refetch() } }\n}\n","import { useReadContracts } from 'wagmi'\nimport { useQuery } from '@tanstack/react-query'\nimport { REGISTRY_ABI, getRegistry } from '../core/contract'\nimport { chainFor } from '../provider'\nimport { useIdentityKitConfig } from '../context'\nimport { IDENTITY_KINDS, decodeRecord, parseRecord, recordKind, type ParsedRecord } from '../core/records'\n\n/**\n * The records on one claim, for the kinds given (default: the kinds an identity page shows),\n * read in one multicall and parsed. Kinds with no record are left out.\n */\nexport function useRecords(address: string | undefined | null, index: number | undefined | null, kinds: readonly string[] = IDENTITY_KINDS) {\n const config = useIdentityKitConfig()\n const registry = getRegistry(config.network, config.registryAddress)\n const chain = chainFor(config.network)\n const owner = address as `0x${string}` | undefined\n const enabled = !!owner && index !== undefined && index !== null\n\n const contracts = enabled\n ? kinds.map(kind => ({ address: registry.address, abi: REGISTRY_ABI, functionName: 'record' as const, args: [owner!, BigInt(index!), recordKind(kind)] as const, chainId: chain.id }))\n : []\n const { data: raw, isLoading: readLoading, refetch } = useReadContracts({ contracts, query: { enabled: contracts.length > 0 } })\n\n const texts = (raw ?? []).map(r => (r.status === 'success' ? decodeRecord(r.result as `0x${string}`) : ''))\n const { data: records, isLoading: parseLoading } = useQuery({\n queryKey: ['records', config.network, registry.address, address, index, kinds.join(','), texts.join(' ')],\n queryFn: async (): Promise<ParsedRecord[]> => {\n const out: ParsedRecord[] = []\n for (let i = 0; i < kinds.length; i++) if (texts[i]) out.push(await parseRecord(kinds[i], texts[i]))\n return out\n },\n enabled: enabled && raw !== undefined,\n })\n\n return { records: records ?? [], isLoading: enabled && (readLoading || parseLoading), refetch: () => { void refetch() } }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { IdentityKitConfig, Theme, ThurinIdentity, Attestation, EFPGraph, PGPKeyInfo, ProofResult, EnsHint } from './core.cjs';
|
|
4
|
-
export { AUTHORIZATION_TYPES, AttestAuthorization, AuthorizationAction, EIP712_NAME, EIP712_VERSION, ENS_HINT_KEY, ENS_TEXT_RESOLVER_ABI, EnsHintState, EnsTextReader, NETWORKS, NetworkName, Notation, PGPVerification, Proof, REGISTRY_ABI, REGISTRY_ADDRESS, ReattestAuthorization, RegistryDeployment, RevokeAuthorization, SetRecordAuthorization, StrippedKey, SubkeyInfo, UpdateKeyAuthorization, attestTypedData, authorizationDigest, bytesToFingerprint, chainFor, displayUrl, ensHintFor, ensHintValue, ensHintWrite, fetchEFPGraph, fetchEnsHint,
|
|
3
|
+
import { IdentityKitConfig, Theme, ThurinIdentity, Attestation, EFPGraph, PGPKeyInfo, ProofResult, EnsHint, ParsedRecord } from './core.cjs';
|
|
4
|
+
export { AUTHORIZATION_TYPES, AttestAuthorization, AuthorizationAction, EIP712_NAME, EIP712_VERSION, ENS_HINT_KEY, ENS_TEXT_RESOLVER_ABI, EnsHintState, EnsTextReader, IDENTITY_KINDS, KNOWN_KINDS, KnownKind, MAX_RECORD_BYTES, NETWORKS, NetworkName, Notation, PGPVerification, PointerEntry, PointerRecord, Proof, REGISTRY_ABI, REGISTRY_ADDRESS, ReattestAuthorization, RecordData, RecordReader, RegistryDeployment, RevokeAuthorization, SetRecordAuthorization, StrippedKey, SubkeyInfo, UpdateKeyAuthorization, addPointer, attestTypedData, authorizationDigest, bytesToFingerprint, chainFor, decodeRecord, displayUrl, encodeRecord, ensHintFor, ensHintValue, ensHintWrite, fetchEFPGraph, fetchEnsHint, fetchRecords, fingerprintHash, fingerprintToBytes, getRegistry, hasEmailUserID, identifyProof, isNetworkName, keyIdOf, keyIdToBytes, kindName, normalizeFingerprint, parsePgpKey, parsePointer, parseRecord, proofHref, proofSecondaryHref, reattestTypedData, recordKind, registryDomain, renderPointer, revokeTypedData, setRecordTypedData, stripEmailUserIDs, updateKeyTypedData, verifyAttestation, verifyProof } from './core.cjs';
|
|
5
5
|
import 'viem';
|
|
6
6
|
|
|
7
7
|
interface IdentityKitProviderProps extends IdentityKitConfig {
|
|
@@ -61,4 +61,14 @@ declare function useEnsHint(name: string | undefined | null, verifiedFingerprint
|
|
|
61
61
|
refetch: () => void;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The records on one claim, for the kinds given (default: the kinds an identity page shows),
|
|
66
|
+
* read in one multicall and parsed. Kinds with no record are left out.
|
|
67
|
+
*/
|
|
68
|
+
declare function useRecords(address: string | undefined | null, index: number | undefined | null, kinds?: readonly string[]): {
|
|
69
|
+
records: ParsedRecord[];
|
|
70
|
+
isLoading: boolean;
|
|
71
|
+
refetch: () => void;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { Attestation, EFPGraph, EnsHint, IdentityKitConfig, IdentityKitProvider, type IdentityKitProviderProps, PGPKeyInfo, ParsedRecord, ProofResult, Theme, ThurinCard, type ThurinCardProps, ThurinIdentity, useAttestations, useEFPGraph, useEnsHint, usePGPProofs, useRecords, useThurinIdentity };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { IdentityKitConfig, Theme, ThurinIdentity, Attestation, EFPGraph, PGPKeyInfo, ProofResult, EnsHint } from './core.js';
|
|
4
|
-
export { AUTHORIZATION_TYPES, AttestAuthorization, AuthorizationAction, EIP712_NAME, EIP712_VERSION, ENS_HINT_KEY, ENS_TEXT_RESOLVER_ABI, EnsHintState, EnsTextReader, NETWORKS, NetworkName, Notation, PGPVerification, Proof, REGISTRY_ABI, REGISTRY_ADDRESS, ReattestAuthorization, RegistryDeployment, RevokeAuthorization, SetRecordAuthorization, StrippedKey, SubkeyInfo, UpdateKeyAuthorization, attestTypedData, authorizationDigest, bytesToFingerprint, chainFor, displayUrl, ensHintFor, ensHintValue, ensHintWrite, fetchEFPGraph, fetchEnsHint,
|
|
3
|
+
import { IdentityKitConfig, Theme, ThurinIdentity, Attestation, EFPGraph, PGPKeyInfo, ProofResult, EnsHint, ParsedRecord } from './core.js';
|
|
4
|
+
export { AUTHORIZATION_TYPES, AttestAuthorization, AuthorizationAction, EIP712_NAME, EIP712_VERSION, ENS_HINT_KEY, ENS_TEXT_RESOLVER_ABI, EnsHintState, EnsTextReader, IDENTITY_KINDS, KNOWN_KINDS, KnownKind, MAX_RECORD_BYTES, NETWORKS, NetworkName, Notation, PGPVerification, PointerEntry, PointerRecord, Proof, REGISTRY_ABI, REGISTRY_ADDRESS, ReattestAuthorization, RecordData, RecordReader, RegistryDeployment, RevokeAuthorization, SetRecordAuthorization, StrippedKey, SubkeyInfo, UpdateKeyAuthorization, addPointer, attestTypedData, authorizationDigest, bytesToFingerprint, chainFor, decodeRecord, displayUrl, encodeRecord, ensHintFor, ensHintValue, ensHintWrite, fetchEFPGraph, fetchEnsHint, fetchRecords, fingerprintHash, fingerprintToBytes, getRegistry, hasEmailUserID, identifyProof, isNetworkName, keyIdOf, keyIdToBytes, kindName, normalizeFingerprint, parsePgpKey, parsePointer, parseRecord, proofHref, proofSecondaryHref, reattestTypedData, recordKind, registryDomain, renderPointer, revokeTypedData, setRecordTypedData, stripEmailUserIDs, updateKeyTypedData, verifyAttestation, verifyProof } from './core.js';
|
|
5
5
|
import 'viem';
|
|
6
6
|
|
|
7
7
|
interface IdentityKitProviderProps extends IdentityKitConfig {
|
|
@@ -61,4 +61,14 @@ declare function useEnsHint(name: string | undefined | null, verifiedFingerprint
|
|
|
61
61
|
refetch: () => void;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The records on one claim, for the kinds given (default: the kinds an identity page shows),
|
|
66
|
+
* read in one multicall and parsed. Kinds with no record are left out.
|
|
67
|
+
*/
|
|
68
|
+
declare function useRecords(address: string | undefined | null, index: number | undefined | null, kinds?: readonly string[]): {
|
|
69
|
+
records: ParsedRecord[];
|
|
70
|
+
isLoading: boolean;
|
|
71
|
+
refetch: () => void;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { Attestation, EFPGraph, EnsHint, IdentityKitConfig, IdentityKitProvider, type IdentityKitProviderProps, PGPKeyInfo, ParsedRecord, ProofResult, Theme, ThurinCard, type ThurinCardProps, ThurinIdentity, useAttestations, useEFPGraph, useEnsHint, usePGPProofs, useRecords, useThurinIdentity };
|
package/dist/index.js
CHANGED
|
@@ -4,21 +4,26 @@ import {
|
|
|
4
4
|
EIP712_VERSION,
|
|
5
5
|
ENS_HINT_KEY,
|
|
6
6
|
ENS_TEXT_RESOLVER_ABI,
|
|
7
|
+
IDENTITY_KINDS,
|
|
8
|
+
KNOWN_KINDS,
|
|
9
|
+
MAX_RECORD_BYTES,
|
|
7
10
|
NETWORKS,
|
|
8
11
|
REGISTRY_ABI,
|
|
9
12
|
REGISTRY_ADDRESS,
|
|
13
|
+
addPointer,
|
|
10
14
|
attestTypedData,
|
|
11
15
|
authorizationDigest,
|
|
12
16
|
bytesToFingerprint,
|
|
13
17
|
chainFor,
|
|
18
|
+
decodeRecord,
|
|
14
19
|
displayUrl,
|
|
20
|
+
encodeRecord,
|
|
15
21
|
ensHintFor,
|
|
16
22
|
ensHintValue,
|
|
17
23
|
ensHintWrite,
|
|
18
24
|
fetchEFPGraph,
|
|
19
25
|
fetchEnsHint,
|
|
20
|
-
|
|
21
|
-
fetchKeyByKeyId,
|
|
26
|
+
fetchRecords,
|
|
22
27
|
fingerprintHash,
|
|
23
28
|
fingerprintToBytes,
|
|
24
29
|
getRegistry,
|
|
@@ -27,20 +32,24 @@ import {
|
|
|
27
32
|
isNetworkName,
|
|
28
33
|
keyIdOf,
|
|
29
34
|
keyIdToBytes,
|
|
35
|
+
kindName,
|
|
30
36
|
normalizeFingerprint,
|
|
31
37
|
parsePgpKey,
|
|
38
|
+
parsePointer,
|
|
39
|
+
parseRecord,
|
|
32
40
|
proofHref,
|
|
33
41
|
proofSecondaryHref,
|
|
34
42
|
reattestTypedData,
|
|
35
43
|
recordKind,
|
|
36
44
|
registryDomain,
|
|
45
|
+
renderPointer,
|
|
37
46
|
revokeTypedData,
|
|
38
47
|
setRecordTypedData,
|
|
39
48
|
stripEmailUserIDs,
|
|
40
49
|
updateKeyTypedData,
|
|
41
50
|
verifyAttestation,
|
|
42
51
|
verifyProof
|
|
43
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-4H57JHDJ.js";
|
|
44
53
|
|
|
45
54
|
// src/provider.tsx
|
|
46
55
|
import { useMemo } from "react";
|
|
@@ -415,29 +424,60 @@ function useEnsHint(name, verifiedFingerprint) {
|
|
|
415
424
|
void refetch();
|
|
416
425
|
} };
|
|
417
426
|
}
|
|
427
|
+
|
|
428
|
+
// src/hooks/useRecords.ts
|
|
429
|
+
import { useReadContracts as useReadContracts2 } from "wagmi";
|
|
430
|
+
import { useQuery as useQuery4 } from "@tanstack/react-query";
|
|
431
|
+
function useRecords(address, index, kinds = IDENTITY_KINDS) {
|
|
432
|
+
const config = useIdentityKitConfig();
|
|
433
|
+
const registry = getRegistry(config.network, config.registryAddress);
|
|
434
|
+
const chain = chainFor(config.network);
|
|
435
|
+
const owner = address;
|
|
436
|
+
const enabled = !!owner && index !== void 0 && index !== null;
|
|
437
|
+
const contracts = enabled ? kinds.map((kind) => ({ address: registry.address, abi: REGISTRY_ABI, functionName: "record", args: [owner, BigInt(index), recordKind(kind)], chainId: chain.id })) : [];
|
|
438
|
+
const { data: raw, isLoading: readLoading, refetch } = useReadContracts2({ contracts, query: { enabled: contracts.length > 0 } });
|
|
439
|
+
const texts = (raw ?? []).map((r) => r.status === "success" ? decodeRecord(r.result) : "");
|
|
440
|
+
const { data: records, isLoading: parseLoading } = useQuery4({
|
|
441
|
+
queryKey: ["records", config.network, registry.address, address, index, kinds.join(","), texts.join(" ")],
|
|
442
|
+
queryFn: async () => {
|
|
443
|
+
const out = [];
|
|
444
|
+
for (let i = 0; i < kinds.length; i++) if (texts[i]) out.push(await parseRecord(kinds[i], texts[i]));
|
|
445
|
+
return out;
|
|
446
|
+
},
|
|
447
|
+
enabled: enabled && raw !== void 0
|
|
448
|
+
});
|
|
449
|
+
return { records: records ?? [], isLoading: enabled && (readLoading || parseLoading), refetch: () => {
|
|
450
|
+
void refetch();
|
|
451
|
+
} };
|
|
452
|
+
}
|
|
418
453
|
export {
|
|
419
454
|
AUTHORIZATION_TYPES,
|
|
420
455
|
EIP712_NAME,
|
|
421
456
|
EIP712_VERSION,
|
|
422
457
|
ENS_HINT_KEY,
|
|
423
458
|
ENS_TEXT_RESOLVER_ABI,
|
|
459
|
+
IDENTITY_KINDS,
|
|
424
460
|
IdentityKitProvider,
|
|
461
|
+
KNOWN_KINDS,
|
|
462
|
+
MAX_RECORD_BYTES,
|
|
425
463
|
NETWORKS,
|
|
426
464
|
REGISTRY_ABI,
|
|
427
465
|
REGISTRY_ADDRESS,
|
|
428
466
|
ThurinCard,
|
|
467
|
+
addPointer,
|
|
429
468
|
attestTypedData,
|
|
430
469
|
authorizationDigest,
|
|
431
470
|
bytesToFingerprint,
|
|
432
471
|
chainFor,
|
|
472
|
+
decodeRecord,
|
|
433
473
|
displayUrl,
|
|
474
|
+
encodeRecord,
|
|
434
475
|
ensHintFor,
|
|
435
476
|
ensHintValue,
|
|
436
477
|
ensHintWrite,
|
|
437
478
|
fetchEFPGraph,
|
|
438
479
|
fetchEnsHint,
|
|
439
|
-
|
|
440
|
-
fetchKeyByKeyId,
|
|
480
|
+
fetchRecords,
|
|
441
481
|
fingerprintHash,
|
|
442
482
|
fingerprintToBytes,
|
|
443
483
|
getRegistry,
|
|
@@ -446,13 +486,17 @@ export {
|
|
|
446
486
|
isNetworkName,
|
|
447
487
|
keyIdOf,
|
|
448
488
|
keyIdToBytes,
|
|
489
|
+
kindName,
|
|
449
490
|
normalizeFingerprint,
|
|
450
491
|
parsePgpKey,
|
|
492
|
+
parsePointer,
|
|
493
|
+
parseRecord,
|
|
451
494
|
proofHref,
|
|
452
495
|
proofSecondaryHref,
|
|
453
496
|
reattestTypedData,
|
|
454
497
|
recordKind,
|
|
455
498
|
registryDomain,
|
|
499
|
+
renderPointer,
|
|
456
500
|
revokeTypedData,
|
|
457
501
|
setRecordTypedData,
|
|
458
502
|
stripEmailUserIDs,
|
|
@@ -461,6 +505,7 @@ export {
|
|
|
461
505
|
useEFPGraph,
|
|
462
506
|
useEnsHint,
|
|
463
507
|
usePGPProofs,
|
|
508
|
+
useRecords,
|
|
464
509
|
useThurinIdentity,
|
|
465
510
|
verifyAttestation,
|
|
466
511
|
verifyProof
|