@learncard/network-plugin 2.14.0 → 2.14.1

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.
@@ -15126,14 +15126,22 @@ var UnsignedVCValidator = external_exports.object({
15126
15126
  }).catchall(external_exports.any());
15127
15127
  var ProofValidator = external_exports.object({
15128
15128
  type: external_exports.string(),
15129
- created: external_exports.string(),
15129
+ created: external_exports.string().optional(),
15130
15130
  challenge: external_exports.string().optional(),
15131
15131
  domain: external_exports.string().optional(),
15132
15132
  nonce: external_exports.string().optional(),
15133
15133
  proofPurpose: external_exports.string(),
15134
15134
  verificationMethod: external_exports.string(),
15135
15135
  jws: external_exports.string().optional()
15136
- }).catchall(external_exports.any());
15136
+ }).catchall(external_exports.any()).superRefine((proof, ctx) => {
15137
+ if (proof.created === void 0 && (proof.type !== "DataIntegrityProof" || proof.cryptosuite !== "ecdsa-rdfc-2019")) {
15138
+ ctx.addIssue({
15139
+ code: "custom",
15140
+ path: ["created"],
15141
+ message: "created is required for this proof suite"
15142
+ });
15143
+ }
15144
+ });
15137
15145
  var VCValidator = UnsignedVCValidator.extend({
15138
15146
  proof: ProofValidator.or(ProofValidator.array())
15139
15147
  });
@@ -16018,15 +16026,6 @@ var ConsentFlowContractDataValidator = external_exports.object({
16018
16026
  var PaginatedConsentFlowDataValidator = PaginationResponseValidator.extend({
16019
16027
  records: ConsentFlowContractDataValidator.array()
16020
16028
  });
16021
- var ConsentFlowContractDataForDidValidator = external_exports.object({
16022
- credentials: external_exports.object({ category: external_exports.string(), uri: external_exports.string() }).array(),
16023
- personal: external_exports.record(external_exports.string(), external_exports.string()).default({}),
16024
- date: external_exports.string(),
16025
- contractUri: external_exports.string()
16026
- });
16027
- var PaginatedConsentFlowDataForDidValidator = PaginationResponseValidator.extend({
16028
- records: ConsentFlowContractDataForDidValidator.array()
16029
- });
16030
16029
  var ConsentFlowTermValidator = external_exports.object({
16031
16030
  sharing: external_exports.boolean().optional(),
16032
16031
  shared: external_exports.string().array().optional(),
@@ -16060,6 +16059,34 @@ var PaginatedConsentFlowTermsValidator = PaginationResponseValidator.extend({
16060
16059
  status: ConsentFlowTermsStatusValidator
16061
16060
  }).array()
16062
16061
  });
16062
+ var ConsentFlowGuardianApprovalValidator = external_exports.object({
16063
+ guardianProfileId: external_exports.string(),
16064
+ guardianDid: external_exports.string(),
16065
+ approvedAt: external_exports.string().datetime(),
16066
+ contractUpdatedAt: external_exports.string()
16067
+ });
16068
+ var ConsentFlowContractDataForDidValidator = external_exports.object({
16069
+ credentials: external_exports.object({ category: external_exports.string(), uri: external_exports.string() }).array(),
16070
+ personal: external_exports.record(external_exports.string(), external_exports.string()).default({}),
16071
+ date: external_exports.string(),
16072
+ createdAt: external_exports.string().optional(),
16073
+ contractUpdatedAt: external_exports.string(),
16074
+ contractExpiresAt: external_exports.string().optional(),
16075
+ reasonForAccessing: external_exports.string().optional(),
16076
+ guardian: external_exports.object({
16077
+ required: external_exports.boolean(),
16078
+ approved: external_exports.boolean(),
16079
+ approval: ConsentFlowGuardianApprovalValidator.optional()
16080
+ }),
16081
+ contractUri: external_exports.string(),
16082
+ termsUri: external_exports.string(),
16083
+ status: ConsentFlowTermsStatusValidator,
16084
+ expiresAt: external_exports.string().optional(),
16085
+ terms: ConsentFlowTermsValidator
16086
+ });
16087
+ var PaginatedConsentFlowDataForDidValidator = PaginationResponseValidator.extend({
16088
+ records: ConsentFlowContractDataForDidValidator.array()
16089
+ });
16063
16090
  var ConsentFlowContractQueryValidator = external_exports.object({
16064
16091
  read: external_exports.object({
16065
16092
  anonymize: external_exports.boolean().optional(),
@@ -16120,6 +16147,7 @@ var ConsentFlowTransactionValidator = external_exports.object({
16120
16147
  expiresAt: external_exports.string().optional(),
16121
16148
  oneTime: external_exports.boolean().optional(),
16122
16149
  terms: ConsentFlowTermsValidator.optional(),
16150
+ guardianApproval: ConsentFlowGuardianApprovalValidator.optional(),
16123
16151
  id: external_exports.string(),
16124
16152
  action: ConsentFlowTransactionActionValidator,
16125
16153
  date: external_exports.string(),
@@ -19711,6 +19739,13 @@ var getVerifyBoostPlugin = /* @__PURE__ */ __name(async (learnCard, trustedBoost
19711
19739
  if (!issuerDID) return;
19712
19740
  return boostRegistry.find((o) => o.did === issuerDID);
19713
19741
  }, "getTrustedBoostVerifier");
19742
+ const getTrustedBoostNetwork = /* @__PURE__ */ __name((boostId) => {
19743
+ if (typeof boostId !== "string") return;
19744
+ const match = /^lc:network:([^?#\s]+)\/(?:trpc:)?boost:([^/?#\s]+)$/.exec(boostId);
19745
+ if (!match) return;
19746
+ const networkDid = `did:web:${match[1].replace(/\//g, ":")}`;
19747
+ return boostRegistry.find((entry) => entry.did === networkDid);
19748
+ }, "getTrustedBoostNetwork");
19714
19749
  return {
19715
19750
  name: "VerifyBoost",
19716
19751
  displayName: "Verify Boost Extension",
@@ -19721,18 +19756,20 @@ var getVerifyBoostPlugin = /* @__PURE__ */ __name(async (learnCard, trustedBoost
19721
19756
  credential,
19722
19757
  options
19723
19758
  );
19759
+ const hasOuterVerificationErrors = Boolean(verificationCheck.errors?.length);
19724
19760
  const boostCredential = credential?.boostCredential;
19725
19761
  try {
19726
- if (boostCredential) {
19727
- const verifyBoostCredential = await learnCard.invoke.verifyCredential(boostCredential);
19728
- const boostCredentialErrors = verifyBoostCredential.errors ?? [];
19729
- if (verifyBoostCredential.status?.length) {
19762
+ const boostId = boostCredential?.boostId ?? credential?.boostId;
19763
+ if (boostCredential || credential?.boostId || credential?.type?.includes("BoostCredential")) {
19764
+ const verifyBoostCredential = boostCredential ? await learnCard.invoke.verifyCredential(boostCredential) : verificationCheck;
19765
+ const boostCredentialErrors = boostCredential ? verifyBoostCredential.errors ?? [] : [];
19766
+ if (boostCredential && verifyBoostCredential.status?.length) {
19730
19767
  verificationCheck.status = [
19731
19768
  ...verificationCheck.status ?? [],
19732
19769
  ...verifyBoostCredential.status
19733
19770
  ];
19734
19771
  }
19735
- if (!boostCredential?.boostId && !credential?.boostId) {
19772
+ if (!boostId) {
19736
19773
  verificationCheck.warnings.push(
19737
19774
  "Boost Authenticity could not be verified: Boost ID metadata is missing."
19738
19775
  );
@@ -19750,21 +19787,26 @@ var getVerifyBoostPlugin = /* @__PURE__ */ __name(async (learnCard, trustedBoost
19750
19787
  ...verificationCheck.errors || [],
19751
19788
  "Boost Credential could not be verified."
19752
19789
  ];
19753
- } else if (boostCredential?.boostId !== credential?.boostId) {
19790
+ } else if (hasOuterVerificationErrors) {
19791
+ verificationCheck.warnings.push(
19792
+ "Boost Authenticity could not be verified: Credential verification failed."
19793
+ );
19794
+ } else if (!boostId) {
19795
+ } else if (boostCredential && boostCredential.boostId !== credential.boostId) {
19754
19796
  verificationCheck.errors.push(
19755
19797
  "Boost Authenticity could not be verified: Boost ID metadata is mismatched."
19756
19798
  );
19757
19799
  } else {
19758
- const trustedBoostIssuer = getTrustedBoostVerifier(credential?.issuer);
19800
+ const trustedBoostIssuer = boostCredential ? getTrustedBoostVerifier(credential?.issuer) : getTrustedBoostNetwork(boostId);
19759
19801
  if (trustedBoostIssuer) {
19760
19802
  verificationCheck.checks.push(
19761
19803
  `Boost is Authentic. Verified by ${trustedBoostIssuer.id}.`
19762
19804
  );
19763
19805
  } else {
19764
19806
  verificationCheck.warnings.push(
19765
- `Boost Authenticity could not be verified. Issuer is outside of trust network: ${getIssuerDID(
19807
+ boostCredential ? `Boost Authenticity could not be verified. Issuer is outside of trust network: ${getIssuerDID(
19766
19808
  credential?.issuer
19767
- )}`
19809
+ )}` : `Boost Authenticity could not be verified. Boost ID does not identify a trusted network: ${boostId}`
19768
19810
  );
19769
19811
  }
19770
19812
  }