@learncard/helpers 1.5.0 → 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.
@@ -1,4 +1,4 @@
1
- import { type SupportedCredentialRefreshService } from '@learncard/types';
1
+ import { type ManagedCredentialRefreshService, type SupportedCredentialRefreshService } from '@learncard/types';
2
2
  /**
3
3
  * Canonical helpers for credential refresh (LC-2117, LC-2135, LC-2136).
4
4
  *
@@ -47,6 +47,63 @@ export declare const getCredentialEffectiveTime: (vc: RefreshableCredential) =>
47
47
  export declare const canonicalizeCredentialContent: <T>(value: T) => T;
48
48
  /** Serializes a value to a deterministic canonical JSON string */
49
49
  export declare const canonicalizeCredentialJson: (value: unknown) => string;
50
+ /** IRI the managed refresh service type term must resolve to. */
51
+ export declare const MANAGED_REFRESH_TYPE_IRI = "https://learncard.com/refresh#LearnCardCredentialRefresh2026";
52
+ /** OBv3-namespaced IRI for the authorization term of a managed refresh service. */
53
+ export declare const MANAGED_REFRESH_AUTHORIZATION_IRI = "https://purl.imsglobal.org/spec/ob/v3p0#authorization";
54
+ /** IRI for the LearnCard DID-auth scheme of a managed refresh service. */
55
+ export declare const MANAGED_REFRESH_DID_AUTH_IRI = "https://docs.learncard.com/definitions#LearnCardDIDAuth";
56
+ /**
57
+ * Inline JSON-LD context fragment required to sign credentials carrying a
58
+ * LearnCard-managed `LearnCardCredentialRefresh2026` refresh service.
59
+ *
60
+ * Neither VCDM 1.1 (which defines only `ManualRefreshService2018`), VCDM 2.0, nor the
61
+ * live OBv3/CLR contexts define the term `LearnCardCredentialRefresh2026` (nor the
62
+ * LearnCard `authorization` / `LearnCardDIDAuth` extension terms), so DIDKit's
63
+ * data-loss detection refuses to sign unless issuers define these terms inline.
64
+ */
65
+ export declare const MANAGED_REFRESH_SERVICE_CONTEXT: {
66
+ readonly LearnCardCredentialRefresh2026: "https://learncard.com/refresh#LearnCardCredentialRefresh2026";
67
+ readonly authorization: {
68
+ readonly '@id': "https://purl.imsglobal.org/spec/ob/v3p0#authorization";
69
+ readonly '@context': {
70
+ readonly LearnCardDIDAuth: "https://docs.learncard.com/definitions#LearnCardDIDAuth";
71
+ };
72
+ };
73
+ };
74
+ type CredentialWithOptionalRefreshService = {
75
+ refreshService?: unknown;
76
+ };
77
+ /**
78
+ * Returns the LearnCard-managed refresh services carried by a credential.
79
+ *
80
+ * Accepts a single service object or an array; standard 1EdTech services and unknown
81
+ * entries are ignored.
82
+ */
83
+ export declare const getManagedRefreshServices: (vc: CredentialWithOptionalRefreshService) => ManagedCredentialRefreshService[];
84
+ /**
85
+ * Ensures a credential carrying a LearnCard-managed refresh service also carries the
86
+ * inline JSON-LD context needed to sign it.
87
+ *
88
+ * - Credentials without a managed service are returned **by reference**, untouched.
89
+ * - The input is never mutated; a shallow-extended copy is returned when a fragment
90
+ * must be appended.
91
+ * - Equivalent existing definitions are idempotent (no duplicate fragment).
92
+ * - Incomplete mappings are completed with only the missing terms.
93
+ * - Conflicting definitions (same term, different IRI) throw a clear error instead of
94
+ * silently signing an unexpected expansion.
95
+ */
96
+ export declare const prepareManagedRefreshContext: <T>(credential: T) => T;
97
+ /**
98
+ * Injects an allocated managed refresh service into an unsigned credential so the
99
+ * service becomes part of the signed payload.
100
+ *
101
+ * The managed service is made primary: any existing refresh services (for example a
102
+ * standard `1EdTechCredentialRefresh` service) are kept unchanged after it. Injecting
103
+ * a second, different managed service is rejected. The required inline context is
104
+ * prepared via {@link prepareManagedRefreshContext}.
105
+ */
106
+ export declare const injectManagedRefreshService: <T>(credential: T, refreshService: ManagedCredentialRefreshService) => T;
50
107
  /**
51
108
  * Proof-insensitive content comparison for refresh changed-content detection.
52
109
  *
@@ -1 +1 @@
1
- {"version":3,"file":"credential-refresh.d.ts","sourceRoot":"","sources":["../src/credential-refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,iCAAiC,EACzC,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;GAOG;AAEH,KAAK,qBAAqB,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