@oma3/omatrust 0.1.0-alpha.1 → 0.1.0-alpha.3

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.
@@ -1 +1,2 @@
1
- export { A as AttestationQueryResult, C as CallControllerWitnessParams, a as CallControllerWitnessResult, b as ChainConstants, c as CreatePopEip712ProofParams, d as CreatePopJwsProofParams, D as Did, 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, j as ProofPurpose, k as ProofType, l as ProofWrapper, S as SchemaField, m as SubmitAttestationParams, n as SubmitAttestationResult, o as SubmitDelegatedAttestationParams, p as SubmitDelegatedAttestationResult, T as TxEncodedValueProof, q as TxInteractionProof, V as VerifyAttestationParams, r as VerifyAttestationResult, s as VerifyProofParams, t as VerifyProofResult, X as X402OfferProof, u as X402ReceiptProof, v as buildDelegatedAttestationTypedData, w as buildDnsTxtRecord, x as buildEip712Domain, y as calculateAverageUserReviewRating, z as calculateTransferAmount, B as calculateTransferAmountFromAddresses, F as callControllerWitness, I as constructSeed, J as createEvidencePointerProof, K as createPopEip712Proof, M as createPopJwsProof, N as createTxEncodedValueProof, O as createTxInteractionProof, Q as createX402OfferProof, R as createX402ReceiptProof, U as decodeAttestationData, W as deduplicateReviews, Y as encodeAttestationData, Z as extractAddressesFromDidDocument, _ as extractExpirationTime, $ as fetchDidDocument, a0 as formatSchemaUid, a1 as formatTransferAmount, a2 as getAttestation, a3 as getAttestationsForDid, a4 as getChainConstants, a5 as getExplorerAddressUrl, a6 as getExplorerTxUrl, a7 as getLatestAttestations, a8 as getMajorVersion, a9 as getOmaTrustProofEip712Types, aa as getSchemaDetails, ab as getSupportedChainIds, ac as hashSeed, ad as isChainSupported, ae as listAttestations, af as normalizeSchema, ag as parseDnsTxtRecord, ah as prepareDelegatedAttestation, ai as schemaToString, aj as splitSignature, ak as submitAttestation, al as submitDelegatedAttestation, am as verifyAttestation, an as verifyDidDocumentControllerDid, ao as verifyDnsTxtControllerDid, ap as verifyEip712Signature, aq as verifyProof, ar as verifySchemaExists } from '../index-ChbJxwOA.js';
1
+ export { A as AttestationQueryResult, B as BuildDelegatedTypedDataFromEncodedParams, C as CallControllerWitnessParams, a as CallControllerWitnessResult, b as ChainConstants, c as CreatePopEip712ProofParams, d as CreatePopJwsProofParams, D as Did, 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-C4a-JGko.js';
2
+ export { v as verifyDnsTxtControllerDid } from '../index-BDeQNCi_.js';
@@ -365,14 +365,7 @@ async function submitAttestation(params) {
365
365
  throw new OmaTrustError("NETWORK_ERROR", "Failed to submit attestation", { err });
366
366
  }
367
367
  }
368
- function buildDelegatedAttestationTypedData(params) {
369
- const dataWithHash = withAutoSubjectDidHash(params.schema, params.data);
370
- const encodedData = encodeAttestationData(params.schema, dataWithHash);
371
- const recipient = resolveRecipientAddress(dataWithHash);
372
- const expiration = toBigIntOrDefault(
373
- params.expirationTime ?? extractExpirationTime(dataWithHash),
374
- 0n
375
- );
368
+ function buildDelegatedTypedData(params) {
376
369
  return {
377
370
  domain: {
378
371
  name: "EAS",
@@ -397,17 +390,52 @@ function buildDelegatedAttestationTypedData(params) {
397
390
  message: {
398
391
  attester: params.attester,
399
392
  schema: params.schemaUid,
400
- recipient,
401
- expirationTime: expiration,
393
+ recipient: params.recipient,
394
+ expirationTime: toBigIntOrDefault(params.expirationTime, 0n),
402
395
  revocable: params.revocable ?? true,
403
396
  refUID: params.refUid ?? ZERO_UID,
404
- data: encodedData,
397
+ data: params.encodedData,
405
398
  value: toBigIntOrDefault(params.value, 0n),
406
399
  nonce: toBigIntOrDefault(params.nonce, 0n),
407
400
  deadline: toBigIntOrDefault(params.deadline, BigInt(Math.floor(Date.now() / 1e3) + 600))
408
401
  }
409
402
  };
410
403
  }
404
+ function buildDelegatedAttestationTypedData(params) {
405
+ const dataWithHash = withAutoSubjectDidHash(params.schema, params.data);
406
+ const encodedData = encodeAttestationData(params.schema, dataWithHash);
407
+ const recipient = resolveRecipientAddress(dataWithHash);
408
+ return buildDelegatedTypedData({
409
+ chainId: params.chainId,
410
+ easContractAddress: params.easContractAddress,
411
+ schemaUid: params.schemaUid,
412
+ encodedData,
413
+ recipient,
414
+ attester: params.attester,
415
+ nonce: params.nonce,
416
+ revocable: params.revocable,
417
+ expirationTime: params.expirationTime ?? extractExpirationTime(dataWithHash),
418
+ refUid: params.refUid,
419
+ value: params.value,
420
+ deadline: params.deadline
421
+ });
422
+ }
423
+ function buildDelegatedTypedDataFromEncoded(params) {
424
+ return buildDelegatedTypedData({
425
+ chainId: params.chainId,
426
+ easContractAddress: params.easContractAddress,
427
+ schemaUid: params.schemaUid,
428
+ encodedData: params.encodedData,
429
+ recipient: params.recipient,
430
+ attester: params.attester,
431
+ nonce: params.nonce,
432
+ revocable: params.revocable,
433
+ expirationTime: params.expirationTime,
434
+ refUid: params.refUid,
435
+ value: params.value,
436
+ deadline: params.deadline
437
+ });
438
+ }
411
439
  function splitSignature(signature) {
412
440
  try {
413
441
  const parsed = Signature.from(signature);
@@ -898,6 +926,8 @@ function verifyEip712Signature(typedData, signature) {
898
926
  throw new OmaTrustError("INVALID_INPUT", "Failed to verify EIP-712 signature", { err });
899
927
  }
900
928
  }
929
+
930
+ // src/reputation/proof/dns-txt-record.ts
901
931
  function parseDnsTxtRecord(record) {
902
932
  if (!record || typeof record !== "string") {
903
933
  throw new OmaTrustError("INVALID_INPUT", "record must be a non-empty string", { record });
@@ -925,27 +955,6 @@ function buildDnsTxtRecord(controllerDid) {
925
955
  const normalized = normalizeDid(controllerDid);
926
956
  return `v=1;controller=${normalized}`;
927
957
  }
928
- async function verifyDnsTxtControllerDid(domain, expectedControllerDid) {
929
- if (!domain || typeof domain !== "string") {
930
- throw new OmaTrustError("INVALID_INPUT", "domain must be a non-empty string", { domain });
931
- }
932
- const expected = normalizeDid(expectedControllerDid);
933
- const host = `_omatrust.${domain.toLowerCase().replace(/\.$/, "")}`;
934
- let records;
935
- try {
936
- records = await resolveTxt(host);
937
- } catch (err) {
938
- throw new OmaTrustError("NETWORK_ERROR", "Failed to resolve DNS TXT records", { domain, err });
939
- }
940
- for (const recordParts of records) {
941
- const record = recordParts.join("");
942
- const parsed = parseDnsTxtRecord(record);
943
- if (parsed.version === "1" && parsed.controller && normalizeDid(parsed.controller) === expected) {
944
- return { valid: true, record };
945
- }
946
- }
947
- return { valid: false, reason: "No TXT record matched expected controller DID" };
948
- }
949
958
 
950
959
  // src/reputation/verify.ts
951
960
  function parseChainId(input) {
@@ -1409,7 +1418,28 @@ function createEvidencePointerProof(url) {
1409
1418
  issuedAt: Math.floor(Date.now() / 1e3)
1410
1419
  };
1411
1420
  }
1421
+ async function verifyDnsTxtControllerDid(domain, expectedControllerDid) {
1422
+ if (!domain || typeof domain !== "string") {
1423
+ throw new OmaTrustError("INVALID_INPUT", "domain must be a non-empty string", { domain });
1424
+ }
1425
+ const expected = normalizeDid(expectedControllerDid);
1426
+ const host = `_omatrust.${domain.toLowerCase().replace(/\.$/, "")}`;
1427
+ let records;
1428
+ try {
1429
+ records = await resolveTxt(host);
1430
+ } catch (err) {
1431
+ throw new OmaTrustError("NETWORK_ERROR", "Failed to resolve DNS TXT records", { domain, err });
1432
+ }
1433
+ for (const recordParts of records) {
1434
+ const record = recordParts.join("");
1435
+ const parsed = parseDnsTxtRecord(record);
1436
+ if (parsed.version === "1" && parsed.controller && normalizeDid(parsed.controller) === expected) {
1437
+ return { valid: true, record };
1438
+ }
1439
+ }
1440
+ return { valid: false, reason: "No TXT record matched expected controller DID" };
1441
+ }
1412
1442
 
1413
- export { buildDelegatedAttestationTypedData, buildDnsTxtRecord, buildEip712Domain, calculateAverageUserReviewRating, calculateTransferAmount, calculateTransferAmountFromAddresses, callControllerWitness, constructSeed, createEvidencePointerProof, createPopEip712Proof, createPopJwsProof, createTxEncodedValueProof, createTxInteractionProof, createX402OfferProof, createX402ReceiptProof, decodeAttestationData, deduplicateReviews, encodeAttestationData, extractAddressesFromDidDocument, extractExpirationTime, fetchDidDocument, formatSchemaUid, formatTransferAmount, getAttestation, getAttestationsForDid, getChainConstants, getExplorerAddressUrl, getExplorerTxUrl, getLatestAttestations, getMajorVersion, getOmaTrustProofEip712Types, getSchemaDetails, getSupportedChainIds, hashSeed, isChainSupported, listAttestations, normalizeSchema, parseDnsTxtRecord, prepareDelegatedAttestation, schemaToString, splitSignature, submitAttestation, submitDelegatedAttestation, verifyAttestation, verifyDidDocumentControllerDid, verifyDnsTxtControllerDid, verifyEip712Signature, verifyProof, verifySchemaExists };
1443
+ export { buildDelegatedAttestationTypedData, buildDelegatedTypedDataFromEncoded, buildDnsTxtRecord, buildEip712Domain, calculateAverageUserReviewRating, calculateTransferAmount, calculateTransferAmountFromAddresses, callControllerWitness, constructSeed, createEvidencePointerProof, createPopEip712Proof, createPopJwsProof, createTxEncodedValueProof, createTxInteractionProof, createX402OfferProof, createX402ReceiptProof, decodeAttestationData, deduplicateReviews, encodeAttestationData, extractAddressesFromDidDocument, extractExpirationTime, fetchDidDocument, formatSchemaUid, formatTransferAmount, getAttestation, getAttestationsForDid, getChainConstants, getExplorerAddressUrl, getExplorerTxUrl, getLatestAttestations, getMajorVersion, getOmaTrustProofEip712Types, getSchemaDetails, getSupportedChainIds, hashSeed, isChainSupported, listAttestations, normalizeSchema, parseDnsTxtRecord, prepareDelegatedAttestation, schemaToString, splitSignature, submitAttestation, submitDelegatedAttestation, verifyAttestation, verifyDidDocumentControllerDid, verifyDnsTxtControllerDid, verifyEip712Signature, verifyProof, verifySchemaExists };
1414
1444
  //# sourceMappingURL=index.js.map
1415
1445
  //# sourceMappingURL=index.js.map