@peac/protocol 0.13.1 → 0.13.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.mjs CHANGED
@@ -594,6 +594,14 @@ function pruneStale() {
594
594
  while (SHADOW_LOG.length > 0 && SHADOW_LOG[0].timestamp < cutoffIso) SHADOW_LOG.shift();
595
595
  }
596
596
 
597
+ // src/_internal/legacy-path.ts
598
+ function readLegacyPathFlag(options) {
599
+ if (options?._internal?.legacyPath === true) return true;
600
+ if (typeof process === "undefined" || process === null) return false;
601
+ const env = process.env;
602
+ return env?.PEAC_INTERNAL_LEGACY_PATH === "1";
603
+ }
604
+
597
605
  // src/_internal/shadow-observe.ts
598
606
  function realObservationForIssue() {
599
607
  return EMPTY_ACCEPTED;
@@ -804,6 +812,7 @@ async function issue(options) {
804
812
  return issueWire02(options);
805
813
  }
806
814
  async function issueWire02(options) {
815
+ void readLegacyPathFlag(options);
807
816
  if (!isCanonicalIss(options.iss)) {
808
817
  throw new IssueError({
809
818
  code: "E_ISS_NOT_CANONICAL",
@@ -879,8 +888,8 @@ function parseIssuerConfig(json) {
879
888
  }
880
889
  try {
881
890
  config = JSON.parse(json);
882
- } catch {
883
- throw new Error("Issuer config is not valid JSON");
891
+ } catch (err) {
892
+ throw new Error("Issuer config is not valid JSON", { cause: err });
884
893
  }
885
894
  } else {
886
895
  config = json;
@@ -903,8 +912,8 @@ function parseIssuerConfig(json) {
903
912
  }
904
913
  try {
905
914
  new URL(obj.jwks_uri);
906
- } catch {
907
- throw new Error("jwks_uri must be a valid URL");
915
+ } catch (err) {
916
+ throw new Error("jwks_uri must be a valid URL", { cause: err });
908
917
  }
909
918
  if (obj.verify_endpoint !== void 0) {
910
919
  if (typeof obj.verify_endpoint !== "string") {
@@ -997,8 +1006,8 @@ function parsePolicyManifest(text, contentType) {
997
1006
  if (isJsonContent(text, contentType)) {
998
1007
  try {
999
1008
  manifest = JSON.parse(text);
1000
- } catch {
1001
- throw new Error("Policy manifest is not valid JSON");
1009
+ } catch (err) {
1010
+ throw new Error("Policy manifest is not valid JSON", { cause: err });
1002
1011
  }
1003
1012
  } else {
1004
1013
  manifest = parseSimpleYaml(text);
@@ -1918,6 +1927,8 @@ function jwkToPublicKey(jwk) {
1918
1927
  return new Uint8Array(xBytes);
1919
1928
  }
1920
1929
  async function verifyReceipt(optionsOrJws) {
1930
+ const legacyPathOptions = typeof optionsOrJws === "string" ? void 0 : optionsOrJws;
1931
+ void readLegacyPathFlag(legacyPathOptions);
1921
1932
  const receiptJws = typeof optionsOrJws === "string" ? optionsOrJws : optionsOrJws.receiptJws;
1922
1933
  const inputSnapshot = typeof optionsOrJws === "string" ? void 0 : optionsOrJws.subject_snapshot;
1923
1934
  const telemetry = typeof optionsOrJws === "string" ? void 0 : optionsOrJws.telemetry;
@@ -2109,6 +2120,7 @@ function sanitizeParseIssues(issues) {
2109
2120
  }));
2110
2121
  }
2111
2122
  async function verifyLocal(jws, publicKey, options = {}) {
2123
+ void readLegacyPathFlag(options);
2112
2124
  const {
2113
2125
  issuer,
2114
2126
  subjectUri,