@oma3/omatrust 0.1.0-alpha.2 → 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.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { i as identity } from './index-QZDExA4I.cjs';
2
- export { i as reputation } from './index-ChbJxwOA.cjs';
2
+ export { i as reputation } from './index-DP6IIpIh.cjs';
3
3
  export { i as appRegistry } from './index-_Bkhoj8k.cjs';
4
+ import './eip712-C4a-JGko.cjs';
4
5
 
5
6
  declare class OmaTrustError extends Error {
6
7
  code: string;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { i as identity } from './index-QZDExA4I.js';
2
- export { i as reputation } from './index-ChbJxwOA.js';
2
+ export { i as reputation } from './index-BDeQNCi_.js';
3
3
  export { i as appRegistry } from './index-_Bkhoj8k.js';
4
+ import './eip712-C4a-JGko.js';
4
5
 
5
6
  declare class OmaTrustError extends Error {
6
7
  code: string;
package/dist/index.js CHANGED
@@ -355,6 +355,7 @@ function hashCanonicalizedJson(obj, algorithm) {
355
355
  var reputation_exports = {};
356
356
  __export(reputation_exports, {
357
357
  buildDelegatedAttestationTypedData: () => buildDelegatedAttestationTypedData,
358
+ buildDelegatedTypedDataFromEncoded: () => buildDelegatedTypedDataFromEncoded,
358
359
  buildDnsTxtRecord: () => buildDnsTxtRecord,
359
360
  buildEip712Domain: () => buildEip712Domain,
360
361
  calculateAverageUserReviewRating: () => calculateAverageUserReviewRating,
@@ -567,14 +568,7 @@ async function submitAttestation(params) {
567
568
  throw new OmaTrustError("NETWORK_ERROR", "Failed to submit attestation", { err });
568
569
  }
569
570
  }
570
- function buildDelegatedAttestationTypedData(params) {
571
- const dataWithHash = withAutoSubjectDidHash(params.schema, params.data);
572
- const encodedData = encodeAttestationData(params.schema, dataWithHash);
573
- const recipient = resolveRecipientAddress(dataWithHash);
574
- const expiration = toBigIntOrDefault(
575
- params.expirationTime ?? extractExpirationTime(dataWithHash),
576
- 0n
577
- );
571
+ function buildDelegatedTypedData(params) {
578
572
  return {
579
573
  domain: {
580
574
  name: "EAS",
@@ -599,17 +593,52 @@ function buildDelegatedAttestationTypedData(params) {
599
593
  message: {
600
594
  attester: params.attester,
601
595
  schema: params.schemaUid,
602
- recipient,
603
- expirationTime: expiration,
596
+ recipient: params.recipient,
597
+ expirationTime: toBigIntOrDefault(params.expirationTime, 0n),
604
598
  revocable: params.revocable ?? true,
605
599
  refUID: params.refUid ?? ZERO_UID,
606
- data: encodedData,
600
+ data: params.encodedData,
607
601
  value: toBigIntOrDefault(params.value, 0n),
608
602
  nonce: toBigIntOrDefault(params.nonce, 0n),
609
603
  deadline: toBigIntOrDefault(params.deadline, BigInt(Math.floor(Date.now() / 1e3) + 600))
610
604
  }
611
605
  };
612
606
  }
607
+ function buildDelegatedAttestationTypedData(params) {
608
+ const dataWithHash = withAutoSubjectDidHash(params.schema, params.data);
609
+ const encodedData = encodeAttestationData(params.schema, dataWithHash);
610
+ const recipient = resolveRecipientAddress(dataWithHash);
611
+ return buildDelegatedTypedData({
612
+ chainId: params.chainId,
613
+ easContractAddress: params.easContractAddress,
614
+ schemaUid: params.schemaUid,
615
+ encodedData,
616
+ recipient,
617
+ attester: params.attester,
618
+ nonce: params.nonce,
619
+ revocable: params.revocable,
620
+ expirationTime: params.expirationTime ?? extractExpirationTime(dataWithHash),
621
+ refUid: params.refUid,
622
+ value: params.value,
623
+ deadline: params.deadline
624
+ });
625
+ }
626
+ function buildDelegatedTypedDataFromEncoded(params) {
627
+ return buildDelegatedTypedData({
628
+ chainId: params.chainId,
629
+ easContractAddress: params.easContractAddress,
630
+ schemaUid: params.schemaUid,
631
+ encodedData: params.encodedData,
632
+ recipient: params.recipient,
633
+ attester: params.attester,
634
+ nonce: params.nonce,
635
+ revocable: params.revocable,
636
+ expirationTime: params.expirationTime,
637
+ refUid: params.refUid,
638
+ value: params.value,
639
+ deadline: params.deadline
640
+ });
641
+ }
613
642
  function splitSignature(signature) {
614
643
  try {
615
644
  const parsed = Signature.from(signature);
@@ -1100,6 +1129,8 @@ function verifyEip712Signature(typedData, signature) {
1100
1129
  throw new OmaTrustError("INVALID_INPUT", "Failed to verify EIP-712 signature", { err });
1101
1130
  }
1102
1131
  }
1132
+
1133
+ // src/reputation/proof/dns-txt-record.ts
1103
1134
  function parseDnsTxtRecord(record) {
1104
1135
  if (!record || typeof record !== "string") {
1105
1136
  throw new OmaTrustError("INVALID_INPUT", "record must be a non-empty string", { record });
@@ -1127,27 +1158,6 @@ function buildDnsTxtRecord(controllerDid) {
1127
1158
  const normalized = normalizeDid(controllerDid);
1128
1159
  return `v=1;controller=${normalized}`;
1129
1160
  }
1130
- async function verifyDnsTxtControllerDid(domain, expectedControllerDid) {
1131
- if (!domain || typeof domain !== "string") {
1132
- throw new OmaTrustError("INVALID_INPUT", "domain must be a non-empty string", { domain });
1133
- }
1134
- const expected = normalizeDid(expectedControllerDid);
1135
- const host = `_omatrust.${domain.toLowerCase().replace(/\.$/, "")}`;
1136
- let records;
1137
- try {
1138
- records = await resolveTxt(host);
1139
- } catch (err) {
1140
- throw new OmaTrustError("NETWORK_ERROR", "Failed to resolve DNS TXT records", { domain, err });
1141
- }
1142
- for (const recordParts of records) {
1143
- const record = recordParts.join("");
1144
- const parsed = parseDnsTxtRecord(record);
1145
- if (parsed.version === "1" && parsed.controller && normalizeDid(parsed.controller) === expected) {
1146
- return { valid: true, record };
1147
- }
1148
- }
1149
- return { valid: false, reason: "No TXT record matched expected controller DID" };
1150
- }
1151
1161
 
1152
1162
  // src/reputation/verify.ts
1153
1163
  function parseChainId(input) {
@@ -1611,6 +1621,27 @@ function createEvidencePointerProof(url) {
1611
1621
  issuedAt: Math.floor(Date.now() / 1e3)
1612
1622
  };
1613
1623
  }
1624
+ async function verifyDnsTxtControllerDid(domain, expectedControllerDid) {
1625
+ if (!domain || typeof domain !== "string") {
1626
+ throw new OmaTrustError("INVALID_INPUT", "domain must be a non-empty string", { domain });
1627
+ }
1628
+ const expected = normalizeDid(expectedControllerDid);
1629
+ const host = `_omatrust.${domain.toLowerCase().replace(/\.$/, "")}`;
1630
+ let records;
1631
+ try {
1632
+ records = await resolveTxt(host);
1633
+ } catch (err) {
1634
+ throw new OmaTrustError("NETWORK_ERROR", "Failed to resolve DNS TXT records", { domain, err });
1635
+ }
1636
+ for (const recordParts of records) {
1637
+ const record = recordParts.join("");
1638
+ const parsed = parseDnsTxtRecord(record);
1639
+ if (parsed.version === "1" && parsed.controller && normalizeDid(parsed.controller) === expected) {
1640
+ return { valid: true, record };
1641
+ }
1642
+ }
1643
+ return { valid: false, reason: "No TXT record matched expected controller DID" };
1644
+ }
1614
1645
 
1615
1646
  // src/app-registry/index.ts
1616
1647
  var app_registry_exports = {};