@learncard/vc-plugin 1.5.12 → 1.6.0

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/src/types.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  VerificationCheck,
7
7
  DidDocument,
8
8
  JWKWithPrivateKey,
9
+ CredentialRefreshResult,
9
10
  } from '@learncard/types';
10
11
  import { Plugin, LearnCard } from '@learncard/core';
11
12
  import { ProofOptions, InputMetadata } from '@learncard/didkit-plugin';
@@ -53,6 +54,41 @@ export type VCPluginMethods = {
53
54
  getTestVc: (subject?: string) => UnsignedVC;
54
55
  getTestVp: (credential?: VC) => Promise<UnsignedVP>;
55
56
  getDidAuthVp: (options?: ProofOptions) => Promise<VP | string>;
57
+ refreshCredential: (
58
+ credential: VC,
59
+ options?: RefreshCredentialOptions
60
+ ) => Promise<CredentialRefreshResult>;
61
+ };
62
+
63
+ /**
64
+ * Options for the generic holder-side credential refresh primitive.
65
+ *
66
+ * @group VC Plugin
67
+ */
68
+ export type RefreshCredentialOptions = {
69
+ /** Previously seen ETag validator for the credential; sent as `If-None-Match` */
70
+ etag?: string;
71
+ /** Per-request timeout in milliseconds (default 10_000) */
72
+ timeoutMs?: number;
73
+ /** Maximum number of followed redirects (default 3) */
74
+ maxRedirects?: number;
75
+ /** Maximum accepted response size in bytes (default 1 MiB) */
76
+ maxResponseBytes?: number;
77
+ /**
78
+ * Explicit local-development opt-in allowing plain-HTTP endpoints. HTTPS is required
79
+ * unless this is set.
80
+ */
81
+ allowInsecureHttp?: boolean;
82
+ /**
83
+ * Explicit local-development opt-in allowing private, loopback, or link-local
84
+ * endpoint addresses. Never enable this for credentials from untrusted issuers.
85
+ */
86
+ allowPrivateAddresses?: boolean;
87
+ /**
88
+ * Hostname resolution override used for SSRF checks. Defaults to Node's DNS resolver
89
+ * in Node runtimes; browsers skip DNS resolution and reject only unsafe host literals.
90
+ */
91
+ resolveHost?: (hostname: string) => Promise<string[]>;
56
92
  };
57
93
 
58
94
  /** @group VC Plugin */
package/src/vc.ts CHANGED
@@ -2,6 +2,7 @@ import { issueCredential } from './issueCredential';
2
2
  import { verifyCredential } from './verifyCredential';
3
3
  import { issuePresentation } from './issuePresentation';
4
4
  import { verifyPresentation } from './verifyPresentation';
5
+ import { refreshCredential } from './refreshCredential';
5
6
 
6
7
  import { VCDependentLearnCard, VCPlugin } from './types';
7
8
  import { UnsignedVP } from '@learncard/types';
@@ -20,6 +21,7 @@ export const getVCPlugin = (learnCard: VCDependentLearnCard): VCPlugin => {
20
21
  verifyCredential: verifyCredential(learnCard),
21
22
  issuePresentation: issuePresentation(learnCard),
22
23
  verifyPresentation: verifyPresentation(learnCard),
24
+ refreshCredential: refreshCredential(learnCard),
23
25
  getTestVc: (_learnCard, subject = 'did:example:d23dd687a7dc6787646f2eb98d0') => {
24
26
  const did = _learnCard.id.did();
25
27