@learncard/vc-plugin 1.6.0 → 1.6.2

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.
@@ -61,9 +61,9 @@ export declare const issueCredential: (initLearnCard: VCDependentLearnCard) => (
61
61
  proof: {
62
62
  [x: string]: any;
63
63
  type: string;
64
- created: string;
65
64
  proofPurpose: string;
66
65
  verificationMethod: string;
66
+ created?: string | undefined;
67
67
  challenge?: string | undefined;
68
68
  domain?: string | undefined;
69
69
  nonce?: string | undefined;
@@ -71,9 +71,9 @@ export declare const issueCredential: (initLearnCard: VCDependentLearnCard) => (
71
71
  } | {
72
72
  [x: string]: any;
73
73
  type: string;
74
- created: string;
75
74
  proofPurpose: string;
76
75
  verificationMethod: string;
76
+ created?: string | undefined;
77
77
  challenge?: string | undefined;
78
78
  domain?: string | undefined;
79
79
  nonce?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"issueCredential.d.ts","sourceRoot":"","sources":["../src/issueCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGpE,eAAO,MAAM,eAAe,GAAI,eAAe,oBAAoB,MAE3D,WAAW,mBAAmB,EAC9B,YAAY,UAAU,EACtB,iBAAgB,OAAO,CAAC,YAAY,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDjD,CAAC"}
1
+ {"version":3,"file":"issueCredential.d.ts","sourceRoot":"","sources":["../src/issueCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGpE,eAAO,MAAM,eAAe,GAAI,eAAe,oBAAoB,MAE3D,WAAW,mBAAmB,EAC9B,YAAY,UAAU,EACtB,iBAAgB,OAAO,CAAC,YAAY,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDjD,CAAC"}
@@ -8,9 +8,9 @@ export declare const issuePresentation: (initLearnCard: VCDependentLearnCard) =>
8
8
  proof: {
9
9
  [x: string]: any;
10
10
  type: string;
11
- created: string;
12
11
  proofPurpose: string;
13
12
  verificationMethod: string;
13
+ created?: string | undefined;
14
14
  challenge?: string | undefined;
15
15
  domain?: string | undefined;
16
16
  nonce?: string | undefined;
@@ -18,9 +18,9 @@ export declare const issuePresentation: (initLearnCard: VCDependentLearnCard) =>
18
18
  } | {
19
19
  [x: string]: any;
20
20
  type: string;
21
- created: string;
22
21
  proofPurpose: string;
23
22
  verificationMethod: string;
23
+ created?: string | undefined;
24
24
  challenge?: string | undefined;
25
25
  domain?: string | undefined;
26
26
  nonce?: string | undefined;
@@ -87,9 +87,9 @@ export declare const issuePresentation: (initLearnCard: VCDependentLearnCard) =>
87
87
  proof: {
88
88
  [x: string]: any;
89
89
  type: string;
90
- created: string;
91
90
  proofPurpose: string;
92
91
  verificationMethod: string;
92
+ created?: string | undefined;
93
93
  challenge?: string | undefined;
94
94
  domain?: string | undefined;
95
95
  nonce?: string | undefined;
@@ -97,9 +97,9 @@ export declare const issuePresentation: (initLearnCard: VCDependentLearnCard) =>
97
97
  } | {
98
98
  [x: string]: any;
99
99
  type: string;
100
- created: string;
101
100
  proofPurpose: string;
102
101
  verificationMethod: string;
102
+ created?: string | undefined;
103
103
  challenge?: string | undefined;
104
104
  domain?: string | undefined;
105
105
  nonce?: string | undefined;
@@ -253,9 +253,9 @@ export declare const issuePresentation: (initLearnCard: VCDependentLearnCard) =>
253
253
  proof: {
254
254
  [x: string]: any;
255
255
  type: string;
256
- created: string;
257
256
  proofPurpose: string;
258
257
  verificationMethod: string;
258
+ created?: string | undefined;
259
259
  challenge?: string | undefined;
260
260
  domain?: string | undefined;
261
261
  nonce?: string | undefined;
@@ -263,9 +263,9 @@ export declare const issuePresentation: (initLearnCard: VCDependentLearnCard) =>
263
263
  } | {
264
264
  [x: string]: any;
265
265
  type: string;
266
- created: string;
267
266
  proofPurpose: string;
268
267
  verificationMethod: string;
268
+ created?: string | undefined;
269
269
  challenge?: string | undefined;
270
270
  domain?: string | undefined;
271
271
  nonce?: string | undefined;
@@ -26,6 +26,9 @@ __export(index_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(index_exports);
28
28
 
29
+ // src/issueCredential.ts
30
+ var import_helpers = require("@learncard/helpers");
31
+
29
32
  // ../../../node_modules/multiformats/vendor/base-x.js
30
33
  function base(ALPHABET, name) {
31
34
  if (ALPHABET.length >= 255) {
@@ -468,7 +471,8 @@ var issueCredential = /* @__PURE__ */ __name((initLearnCard) => {
468
471
  return async (learnCard, credential, signingOptions = {}) => {
469
472
  const kp = learnCard.id.keypair();
470
473
  if (!kp) throw new Error("Cannot issue credential: Could not get subject keypair");
471
- const contexts = Array.isArray(credential["@context"]) ? credential["@context"] : [credential["@context"]];
474
+ const preparedCredential = (0, import_helpers.prepareManagedRefreshContext)(credential);
475
+ const contexts = Array.isArray(preparedCredential["@context"]) ? preparedCredential["@context"] : [preparedCredential["@context"]];
472
476
  const hasV2Context = contexts.some(
473
477
  (ctx) => typeof ctx === "string" && (ctx.includes("/ns/credentials/v2") || ctx.includes("/credentials/v2"))
474
478
  );
@@ -482,15 +486,15 @@ var issueCredential = /* @__PURE__ */ __name((initLearnCard) => {
482
486
  options.cryptosuite = "eddsa-rdfc-2022";
483
487
  }
484
488
  if (!("verificationMethod" in options)) {
485
- const issuerDid = typeof credential.issuer === "string" ? credential.issuer : credential.issuer.id;
489
+ const issuerDid = typeof preparedCredential.issuer === "string" ? preparedCredential.issuer : preparedCredential.issuer.id;
486
490
  options.verificationMethod = await getDefaultVerificationMethod(learnCard, issuerDid);
487
491
  }
488
492
  learnCard.debug?.("Signing with these options", {
489
- credential,
493
+ credential: preparedCredential,
490
494
  options,
491
495
  kp
492
496
  });
493
- return initLearnCard.invoke.issueCredential(credential, options, kp);
497
+ return initLearnCard.invoke.issueCredential(preparedCredential, options, kp);
494
498
  };
495
499
  }, "issueCredential");
496
500
 
@@ -540,7 +544,7 @@ var verifyPresentation = /* @__PURE__ */ __name((initLearnCard) => {
540
544
 
541
545
  // src/refreshCredential.ts
542
546
  var import_types = require("@learncard/types");
543
- var import_helpers3 = require("@learncard/helpers");
547
+ var import_helpers4 = require("@learncard/helpers");
544
548
 
545
549
  // src/refreshCredential.fetch.ts
546
550
  var isNodeRuntime = typeof process !== "undefined" && !!process.versions?.node;
@@ -1027,7 +1031,7 @@ var refreshCredential = /* @__PURE__ */ __name((_initLearnCard) => {
1027
1031
  allowPrivateAddresses: options.allowPrivateAddresses ?? false,
1028
1032
  resolveHost: options.resolveHost ?? (isNodeRuntime2 ? resolveHostnameWithNodeDns : void 0)
1029
1033
  };
1030
- const service = (0, import_helpers3.getSupportedRefreshService)(credential);
1034
+ const service = (0, import_helpers4.getSupportedRefreshService)(credential);
1031
1035
  if (!service) return { status: "unsupported" };
1032
1036
  try {
1033
1037
  const check = await _learnCard.invoke.verifyCredential(credential);
@@ -1140,16 +1144,16 @@ var refreshCredential = /* @__PURE__ */ __name((_initLearnCard) => {
1140
1144
  if (candidate.id !== credential.id) {
1141
1145
  return failed("ID_MISMATCH", false);
1142
1146
  }
1143
- if ((0, import_helpers3.getCredentialIssuerId)(candidate) !== (0, import_helpers3.getCredentialIssuerId)(credential)) {
1147
+ if ((0, import_helpers4.getCredentialIssuerId)(candidate) !== (0, import_helpers4.getCredentialIssuerId)(credential)) {
1144
1148
  return failed("ISSUER_MISMATCH", false);
1145
1149
  }
1146
1150
  if (!holdersEqual(credential, candidate)) return failed("ID_MISMATCH", false);
1147
- const currentTime = (0, import_helpers3.getCredentialEffectiveTime)(credential);
1148
- const candidateTime = (0, import_helpers3.getCredentialEffectiveTime)(candidate);
1151
+ const currentTime = (0, import_helpers4.getCredentialEffectiveTime)(credential);
1152
+ const candidateTime = (0, import_helpers4.getCredentialEffectiveTime)(candidate);
1149
1153
  if (currentTime !== void 0 && candidateTime !== void 0 && candidateTime < currentTime) {
1150
1154
  return failed("ROLLBACK", false);
1151
1155
  }
1152
- if ((0, import_helpers3.credentialContentsEqual)(credential, candidate)) {
1156
+ if ((0, import_helpers4.credentialContentsEqual)(credential, candidate)) {
1153
1157
  return { status: "unchanged", checkedAt: (/* @__PURE__ */ new Date()).toISOString(), etag: decoded.etag };
1154
1158
  }
1155
1159
  return {