@oma3/omatrust 0.1.0-alpha.3 → 0.1.0-alpha.5
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/{eip712-C4a-JGko.d.cts → eip712-Dx9kvqtn.d.cts} +1 -0
- package/dist/{eip712-C4a-JGko.d.ts → eip712-Dx9kvqtn.d.ts} +1 -0
- package/dist/{index-BDeQNCi_.d.ts → index-BUWbuvqZ.d.ts} +1 -1
- package/dist/{index-DP6IIpIh.d.cts → index-ByNU5VpJ.d.cts} +1 -1
- package/dist/index.cjs +64 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +64 -6
- package/dist/index.js.map +1 -1
- package/dist/reputation/index.browser.cjs +64 -6
- package/dist/reputation/index.browser.cjs.map +1 -1
- package/dist/reputation/index.browser.d.cts +2 -2
- package/dist/reputation/index.browser.d.ts +2 -2
- package/dist/reputation/index.browser.js +64 -6
- package/dist/reputation/index.browser.js.map +1 -1
- package/dist/reputation/index.cjs +64 -6
- package/dist/reputation/index.cjs.map +1 -1
- package/dist/reputation/index.d.cts +2 -2
- package/dist/reputation/index.d.ts +2 -2
- package/dist/reputation/index.js +64 -6
- package/dist/reputation/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as Did } from '../eip712-
|
|
2
|
-
export { A as AttestationQueryResult, B as BuildDelegatedTypedDataFromEncodedParams, C as CallControllerWitnessParams, a as CallControllerWitnessResult, b as ChainConstants, c as CreatePopEip712ProofParams, d as CreatePopJwsProofParams, E as EvidencePointerProof, G as GetAttestationParams, e as GetLatestAttestationsParams, H as Hex, L as ListAttestationsParams, P as PopEip712Proof, f as PopJwsProof, g as PrepareDelegatedAttestationParams, h as PrepareDelegatedAttestationResult, i as ProofPurpose, j as ProofType, k as ProofWrapper, S as SchemaField, l as SubmitAttestationParams, m as SubmitAttestationResult, n as SubmitDelegatedAttestationParams, o as SubmitDelegatedAttestationResult, T as TxEncodedValueProof, p as TxInteractionProof, V as VerifyAttestationParams, q as VerifyAttestationResult, r as VerifyProofParams, s as VerifyProofResult, X as X402OfferProof, t as X402ReceiptProof, u as buildDelegatedAttestationTypedData, v as buildDelegatedTypedDataFromEncoded, w as buildDnsTxtRecord, x as buildEip712Domain, y as calculateAverageUserReviewRating, z as calculateTransferAmount, F as calculateTransferAmountFromAddresses, I as callControllerWitness, J as constructSeed, K as createEvidencePointerProof, M as createPopEip712Proof, N as createPopJwsProof, O as createTxEncodedValueProof, Q as createTxInteractionProof, R as createX402OfferProof, U as createX402ReceiptProof, W as decodeAttestationData, Y as deduplicateReviews, Z as encodeAttestationData, _ as extractAddressesFromDidDocument, $ as extractExpirationTime, a0 as fetchDidDocument, a1 as formatSchemaUid, a2 as formatTransferAmount, a3 as getAttestation, a4 as getAttestationsForDid, a5 as getChainConstants, a6 as getExplorerAddressUrl, a7 as getExplorerTxUrl, a8 as getLatestAttestations, a9 as getMajorVersion, aa as getOmaTrustProofEip712Types, ab as getSchemaDetails, ac as getSupportedChainIds, ad as hashSeed, ae as isChainSupported, af as listAttestations, ag as normalizeSchema, ah as parseDnsTxtRecord, ai as prepareDelegatedAttestation, aj as schemaToString, ak as splitSignature, al as submitAttestation, am as submitDelegatedAttestation, an as verifyAttestation, ao as verifyDidDocumentControllerDid, ap as verifyEip712Signature, aq as verifyProof, ar as verifySchemaExists } from '../eip712-
|
|
1
|
+
import { D as Did } from '../eip712-Dx9kvqtn.js';
|
|
2
|
+
export { A as AttestationQueryResult, B as BuildDelegatedTypedDataFromEncodedParams, C as CallControllerWitnessParams, a as CallControllerWitnessResult, b as ChainConstants, c as CreatePopEip712ProofParams, d as CreatePopJwsProofParams, E as EvidencePointerProof, G as GetAttestationParams, e as GetLatestAttestationsParams, H as Hex, L as ListAttestationsParams, P as PopEip712Proof, f as PopJwsProof, g as PrepareDelegatedAttestationParams, h as PrepareDelegatedAttestationResult, i as ProofPurpose, j as ProofType, k as ProofWrapper, S as SchemaField, l as SubmitAttestationParams, m as SubmitAttestationResult, n as SubmitDelegatedAttestationParams, o as SubmitDelegatedAttestationResult, T as TxEncodedValueProof, p as TxInteractionProof, V as VerifyAttestationParams, q as VerifyAttestationResult, r as VerifyProofParams, s as VerifyProofResult, X as X402OfferProof, t as X402ReceiptProof, u as buildDelegatedAttestationTypedData, v as buildDelegatedTypedDataFromEncoded, w as buildDnsTxtRecord, x as buildEip712Domain, y as calculateAverageUserReviewRating, z as calculateTransferAmount, F as calculateTransferAmountFromAddresses, I as callControllerWitness, J as constructSeed, K as createEvidencePointerProof, M as createPopEip712Proof, N as createPopJwsProof, O as createTxEncodedValueProof, Q as createTxInteractionProof, R as createX402OfferProof, U as createX402ReceiptProof, W as decodeAttestationData, Y as deduplicateReviews, Z as encodeAttestationData, _ as extractAddressesFromDidDocument, $ as extractExpirationTime, a0 as fetchDidDocument, a1 as formatSchemaUid, a2 as formatTransferAmount, a3 as getAttestation, a4 as getAttestationsForDid, a5 as getChainConstants, a6 as getExplorerAddressUrl, a7 as getExplorerTxUrl, a8 as getLatestAttestations, a9 as getMajorVersion, aa as getOmaTrustProofEip712Types, ab as getSchemaDetails, ac as getSupportedChainIds, ad as hashSeed, ae as isChainSupported, af as listAttestations, ag as normalizeSchema, ah as parseDnsTxtRecord, ai as prepareDelegatedAttestation, aj as schemaToString, ak as splitSignature, al as submitAttestation, am as submitDelegatedAttestation, an as verifyAttestation, ao as verifyDidDocumentControllerDid, ap as verifyEip712Signature, aq as verifyProof, ar as verifySchemaExists } from '../eip712-Dx9kvqtn.js';
|
|
3
3
|
|
|
4
4
|
declare function verifyDnsTxtControllerDid(domain: string, expectedControllerDid: Did): Promise<{
|
|
5
5
|
valid: boolean;
|
|
@@ -323,6 +323,53 @@ function resolveRecipientAddress(data) {
|
|
|
323
323
|
return ZeroAddress;
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
// src/reputation/eas-adapter.ts
|
|
327
|
+
function isRecord(value) {
|
|
328
|
+
return Boolean(value) && typeof value === "object";
|
|
329
|
+
}
|
|
330
|
+
function isHex32(value) {
|
|
331
|
+
return typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value);
|
|
332
|
+
}
|
|
333
|
+
function getEasTransactionReceipt(tx) {
|
|
334
|
+
if (!isRecord(tx)) {
|
|
335
|
+
return void 0;
|
|
336
|
+
}
|
|
337
|
+
const candidates = [tx.receipt, tx.tx, tx.transaction];
|
|
338
|
+
for (const candidate of candidates) {
|
|
339
|
+
if (isRecord(candidate)) {
|
|
340
|
+
return candidate;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return void 0;
|
|
344
|
+
}
|
|
345
|
+
function getEasTransactionHash(tx) {
|
|
346
|
+
const receipt = getEasTransactionReceipt(tx);
|
|
347
|
+
if (receipt) {
|
|
348
|
+
const receiptHash = receipt.hash;
|
|
349
|
+
if (isHex32(receiptHash)) {
|
|
350
|
+
return receiptHash;
|
|
351
|
+
}
|
|
352
|
+
const transactionHash = receipt.transactionHash;
|
|
353
|
+
if (isHex32(transactionHash)) {
|
|
354
|
+
return transactionHash;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (isRecord(tx) && isHex32(tx.hash)) {
|
|
358
|
+
return tx.hash;
|
|
359
|
+
}
|
|
360
|
+
return void 0;
|
|
361
|
+
}
|
|
362
|
+
function isEasSchemaNotFoundError(err) {
|
|
363
|
+
if (!isRecord(err)) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
const message = err.message;
|
|
367
|
+
if (typeof message !== "string" || message.length === 0) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
return /schema not found/i.test(message);
|
|
371
|
+
}
|
|
372
|
+
|
|
326
373
|
// src/reputation/submit.ts
|
|
327
374
|
async function submitAttestation(params) {
|
|
328
375
|
if (!params || typeof params !== "object") {
|
|
@@ -353,12 +400,12 @@ async function submitAttestation(params) {
|
|
|
353
400
|
}
|
|
354
401
|
});
|
|
355
402
|
const uid = await tx.wait();
|
|
356
|
-
const
|
|
357
|
-
const
|
|
403
|
+
const txHash = getEasTransactionHash(tx) ?? ZERO_UID;
|
|
404
|
+
const receipt = getEasTransactionReceipt(tx);
|
|
358
405
|
return {
|
|
359
406
|
uid,
|
|
360
407
|
txHash,
|
|
361
|
-
receipt
|
|
408
|
+
receipt
|
|
362
409
|
};
|
|
363
410
|
} catch (err) {
|
|
364
411
|
throw new OmaTrustError("NETWORK_ERROR", "Failed to submit attestation", { err });
|
|
@@ -511,7 +558,14 @@ async function submitDelegatedAttestation(params) {
|
|
|
511
558
|
var EAS_EVENT_ABI = [
|
|
512
559
|
"event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schemaUID)"
|
|
513
560
|
];
|
|
514
|
-
function
|
|
561
|
+
function parseEventTxHash(event) {
|
|
562
|
+
const txHash = event.transactionHash;
|
|
563
|
+
if (typeof txHash !== "string") {
|
|
564
|
+
return void 0;
|
|
565
|
+
}
|
|
566
|
+
return /^0x[0-9a-fA-F]{64}$/.test(txHash) ? txHash : void 0;
|
|
567
|
+
}
|
|
568
|
+
function parseAttestation(attestation, schema, txHash) {
|
|
515
569
|
const rawData = attestation.data ?? "0x";
|
|
516
570
|
const decoded = schema ? decodeAttestationData(schema, rawData) : {};
|
|
517
571
|
const toBigIntSafe = (value) => {
|
|
@@ -531,6 +585,7 @@ function parseAttestation(attestation, schema) {
|
|
|
531
585
|
schema: attestation.schema,
|
|
532
586
|
attester: attestation.attester,
|
|
533
587
|
recipient: attestation.recipient,
|
|
588
|
+
txHash,
|
|
534
589
|
revocable: Boolean(attestation.revocable),
|
|
535
590
|
revocationTime: toBigIntSafe(attestation.revocationTime),
|
|
536
591
|
expirationTime: toBigIntSafe(attestation.expirationTime),
|
|
@@ -589,7 +644,7 @@ async function getAttestationsForDid(params) {
|
|
|
589
644
|
if (!attestation || !attestation.uid) {
|
|
590
645
|
continue;
|
|
591
646
|
}
|
|
592
|
-
results.push(parseAttestation(attestation));
|
|
647
|
+
results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
|
|
593
648
|
}
|
|
594
649
|
results.sort((a, b) => Number(b.time - a.time));
|
|
595
650
|
return results;
|
|
@@ -629,7 +684,7 @@ async function getLatestAttestations(params) {
|
|
|
629
684
|
if (!attestation || !attestation.uid) {
|
|
630
685
|
continue;
|
|
631
686
|
}
|
|
632
|
-
results.push(parseAttestation(attestation));
|
|
687
|
+
results.push(parseAttestation(attestation, void 0, parseEventTxHash(event)));
|
|
633
688
|
}
|
|
634
689
|
results.sort((a, b) => Number(b.time - a.time));
|
|
635
690
|
return results.slice(0, params.limit ?? 20);
|
|
@@ -1234,6 +1289,9 @@ async function getSchemaDetails(schemaRegistry, schemaUid) {
|
|
|
1234
1289
|
revocable: Boolean(details.revocable)
|
|
1235
1290
|
};
|
|
1236
1291
|
} catch (err) {
|
|
1292
|
+
if (isEasSchemaNotFoundError(err)) {
|
|
1293
|
+
throw new OmaTrustError("SCHEMA_NOT_FOUND", "Schema was not found", { schemaUid });
|
|
1294
|
+
}
|
|
1237
1295
|
if (err instanceof OmaTrustError) {
|
|
1238
1296
|
throw err;
|
|
1239
1297
|
}
|