@learncard/helpers 1.7.3 → 1.8.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/dist/age-policy.d.ts +9 -0
- package/dist/age-policy.d.ts.map +1 -0
- package/dist/consent-flow-contract-updates.d.ts +29 -0
- package/dist/consent-flow-contract-updates.d.ts.map +1 -0
- package/dist/credential-refresh.d.ts +16 -1
- package/dist/credential-refresh.d.ts.map +1 -1
- package/dist/helpers.cjs.development.cjs +4953 -3773
- package/dist/helpers.cjs.development.cjs.map +4 -4
- package/dist/helpers.cjs.production.min.cjs +36 -36
- package/dist/helpers.cjs.production.min.cjs.map +4 -4
- package/dist/helpers.esm.js +1171 -59
- package/dist/helpers.esm.js.map +4 -4
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/age-policy.ts +88 -0
- package/src/consent-flow-contract-updates.ts +472 -0
- package/src/credential-refresh.ts +99 -2
- package/src/index.ts +18 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const GDPR_AGE_LIMIT: Record<string, number>;
|
|
2
|
+
export declare const DEFAULT_EU_AGE_LIMIT = 16;
|
|
3
|
+
export declare const GDPR_AGE_LIMIT_BY_CODE: Record<string, number>;
|
|
4
|
+
export declare const EU_COUNTRY_CODES: string[];
|
|
5
|
+
/** EU countries use the established GDPR threshold; other countries default to 18. */
|
|
6
|
+
export declare const getMinorAgeThreshold: (countryCode?: string) => number;
|
|
7
|
+
/** Returns completed years for a valid ISO date/timestamp, or NaN if invalid/future. */
|
|
8
|
+
export declare const calculateAgeFromISODate: (dob: string, now?: Date) => number;
|
|
9
|
+
//# sourceMappingURL=age-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"age-policy.d.ts","sourceRoot":"","sources":["../src/age-policy.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CASjD,CAAC;AAEF,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CASzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,UA4B5B,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,GAAI,cAAc,MAAM,KAAG,MAK3D,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,uBAAuB,GAAI,KAAK,MAAM,EAAE,MAAK,IAAiB,KAAG,MAsB7E,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ConsentFlowContract, ConsentFlowContractChangeKind, ConsentFlowContractDiff, ConsentFlowContractUpdatePreview } from '@learncard/types';
|
|
2
|
+
/** Whether a published optional-choice proposal window has not yet expired. */
|
|
3
|
+
export declare const hasOpenNewOptionsWindow: (newOptionsUntil: string | undefined, now?: number) => boolean;
|
|
4
|
+
export type ConsentFlowContractSnapshot = {
|
|
5
|
+
contract: ConsentFlowContract;
|
|
6
|
+
name: string;
|
|
7
|
+
subtitle?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
reasonForAccessing?: string;
|
|
10
|
+
image?: string;
|
|
11
|
+
needsGuardianConsent?: boolean;
|
|
12
|
+
redirectUrl?: string;
|
|
13
|
+
frontDoorBoostUri?: string;
|
|
14
|
+
expiresAt?: string;
|
|
15
|
+
/** Stable URI/id identity is preferred; URI/id-bearing objects are canonicalized. */
|
|
16
|
+
autoboosts?: unknown[];
|
|
17
|
+
writers?: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare const diffContractChange: (prev: ConsentFlowContractSnapshot, next: ConsentFlowContractSnapshot) => ConsentFlowContractDiff;
|
|
20
|
+
export declare const classifyContractChange: (prev: ConsentFlowContractSnapshot, next: ConsentFlowContractSnapshot) => ConsentFlowContractChangeKind;
|
|
21
|
+
export declare const buildContractUpdatePreview: ({ name, kind, diff, status, translate, }: {
|
|
22
|
+
name: string;
|
|
23
|
+
kind: ConsentFlowContractChangeKind;
|
|
24
|
+
diff: ConsentFlowContractDiff;
|
|
25
|
+
status?: string;
|
|
26
|
+
/** Clients localize structured changes; the API retains canonical English copy. */
|
|
27
|
+
translate?: (key: string, values?: Record<string, unknown>) => string;
|
|
28
|
+
}) => ConsentFlowContractUpdatePreview;
|
|
29
|
+
//# sourceMappingURL=consent-flow-contract-updates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent-flow-contract-updates.d.ts","sourceRoot":"","sources":["../src/consent-flow-contract-updates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,mBAAmB,EACnB,6BAA6B,EAE7B,uBAAuB,EAEvB,gCAAgC,EACnC,MAAM,kBAAkB,CAAC;AAE1B,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB,GAChC,iBAAiB,MAAM,GAAG,SAAS,EACnC,YAAgB,KACjB,OAAwE,CAAC;AAE5E,MAAM,MAAM,2BAA2B,GAAG;IACtC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qFAAqF;IACrF,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAgEF,eAAO,MAAM,kBAAkB,GAC3B,MAAM,2BAA2B,EACjC,MAAM,2BAA2B,KAClC,uBAqBF,CAAC;AA2BF,eAAO,MAAM,sBAAsB,GAC/B,MAAM,2BAA2B,EACjC,MAAM,2BAA2B,KAClC,6BAyBF,CAAC;AAyNF,eAAO,MAAM,0BAA0B,GAAI,0CAMxC;IACC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,6BAA6B,CAAC;IACpC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;CACzE,KAAG,gCAqEH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ManagedCredentialRefreshService, type SupportedCredentialRefreshService } from '@learncard/types';
|
|
1
|
+
import { type ManagedCredentialRefreshService, type SupportedCredentialRefreshService, type CredentialRefreshReceipt, type JWE } from '@learncard/types';
|
|
2
2
|
/**
|
|
3
3
|
* Canonical helpers for credential refresh (LC-2117, LC-2135, LC-2136).
|
|
4
4
|
*
|
|
@@ -47,6 +47,21 @@ 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
|
+
/** Structural recipient check only; decryption and credential verification remain mandatory. */
|
|
51
|
+
export declare const assertExactJweRecipients: (jwe: JWE, recipientKeyIds: string[]) => void;
|
|
52
|
+
/** Compares exact public bindings while ignoring JSON object-key order, never array order. */
|
|
53
|
+
export declare const credentialRefreshBindingsEqual: (credential: {
|
|
54
|
+
credentialStatus?: unknown;
|
|
55
|
+
refreshService?: unknown;
|
|
56
|
+
}, baseline: {
|
|
57
|
+
credentialStatus?: unknown;
|
|
58
|
+
refreshService?: unknown;
|
|
59
|
+
}) => boolean;
|
|
60
|
+
/** Checks signed identity and public bindings. Legacy managed-entry receipts bind only the
|
|
61
|
+
* unique managed service; exact receipts also bind additional services and array shape.
|
|
62
|
+
* This does not replace proof/status verification.
|
|
63
|
+
*/
|
|
64
|
+
export declare const assertManagedCredentialBinding: (credential: RefreshableCredential, receipt: CredentialRefreshReceipt) => void;
|
|
50
65
|
/** IRI the managed refresh service type term must resolve to. */
|
|
51
66
|
export declare const MANAGED_REFRESH_TYPE_IRI = "https://learncard.com/refresh#LearnCardCredentialRefresh2026";
|
|
52
67
|
/** OBv3-namespaced IRI for the authorization term of a managed refresh service. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-refresh.d.ts","sourceRoot":"","sources":["../src/credential-refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,+BAA+B,EACpC,KAAK,iCAAiC,
|
|
1
|
+
{"version":3,"file":"credential-refresh.d.ts","sourceRoot":"","sources":["../src/credential-refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,+BAA+B,EACpC,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,GAAG,EACX,MAAM,kBAAkB,CAAC;AAQ1B;;;;;;;GAOG;AAEH,KAAK,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACnD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG;QAAE,EAAE,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,GACnC,IAAI,qBAAqB,KAC1B,iCAAiC,GAAG,SActC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,IAAI,qBAAqB,KAAG,MAAM,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