@learncard/ler-rs-plugin 0.1.27 → 0.1.29
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/ler-rs-plugin.cjs.development.cjs +16 -7
- package/dist/ler-rs-plugin.cjs.development.cjs.map +2 -2
- package/dist/ler-rs-plugin.cjs.production.min.cjs +1 -1
- package/dist/ler-rs-plugin.cjs.production.min.cjs.map +2 -2
- package/dist/ler-rs-plugin.esm.js +16 -7
- package/dist/ler-rs-plugin.esm.js.map +2 -2
- package/dist/ler-rs.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ler-rs.ts +19 -7
|
@@ -53,7 +53,10 @@ var toArray = /* @__PURE__ */ __name((maybe) => maybe == null ? [] : Array.isArr
|
|
|
53
53
|
var inlineLerRsContext = {
|
|
54
54
|
"@version": 1.1,
|
|
55
55
|
hrrec: "http://schema.hropenstandards.org/recruiting/",
|
|
56
|
-
"@vocab": "http://schema.hropenstandards.org/recruiting/"
|
|
56
|
+
"@vocab": "http://schema.hropenstandards.org/recruiting/",
|
|
57
|
+
// Bind complete source credentials as JSON without inheriting the wrapper's
|
|
58
|
+
// protected VC v2 terms into older VC v1 contexts or altering issuer proofs.
|
|
59
|
+
verifications: { "@id": "hrrec:verifications", "@type": "@json" }
|
|
57
60
|
};
|
|
58
61
|
var credentialHasLerRsType = /* @__PURE__ */ __name((credential) => {
|
|
59
62
|
const typeList = Array.isArray(credential.type) ? credential.type : [credential.type];
|
|
@@ -98,7 +101,8 @@ var buildEmploymentHistories = /* @__PURE__ */ __name((items) => {
|
|
|
98
101
|
container.positionHistories = [ph];
|
|
99
102
|
}
|
|
100
103
|
if (narrative) container.narrative = narrative;
|
|
101
|
-
if (descriptions?.length && !container.positionHistories)
|
|
104
|
+
if (descriptions?.length && !container.positionHistories)
|
|
105
|
+
container.descriptions = descriptions;
|
|
102
106
|
const containerVerifications = getItemVerifications({
|
|
103
107
|
verifiableCredential,
|
|
104
108
|
verifications
|
|
@@ -217,7 +221,12 @@ var getLerRsPlugin = /* @__PURE__ */ __name((initLearnCard) => {
|
|
|
217
221
|
const communication = params.person.email || params.person.phone || hasAddress || webEntries.length > 0 || socialEntries.length > 0 ? {
|
|
218
222
|
...params.person.email ? { email: [{ address: params.person.email }] } : {},
|
|
219
223
|
...params.person.phone ? { phone: [{ formattedNumber: params.person.phone }] } : {},
|
|
220
|
-
...webEntries.length ? {
|
|
224
|
+
...webEntries.length ? {
|
|
225
|
+
web: webEntries.map((entry) => ({
|
|
226
|
+
url: entry.url,
|
|
227
|
+
name: entry.name
|
|
228
|
+
}))
|
|
229
|
+
} : {},
|
|
221
230
|
...socialEntries.length ? {
|
|
222
231
|
social: socialEntries.map((entry) => ({
|
|
223
232
|
uri: entry.uri,
|
|
@@ -232,7 +241,9 @@ var getLerRsPlugin = /* @__PURE__ */ __name((initLearnCard) => {
|
|
|
232
241
|
} : {},
|
|
233
242
|
...params.person.address?.line ? { line: params.person.address.line } : {},
|
|
234
243
|
...params.person.address?.city ? { city: params.person.address.city } : {},
|
|
235
|
-
...params.person.address?.postalCode ? {
|
|
244
|
+
...params.person.address?.postalCode ? {
|
|
245
|
+
postalCode: params.person.address.postalCode
|
|
246
|
+
} : {},
|
|
236
247
|
...params.person.address?.countryCode ? {
|
|
237
248
|
countryCode: params.person.address.countryCode
|
|
238
249
|
} : {}
|
|
@@ -320,9 +331,7 @@ var getLerRsPlugin = /* @__PURE__ */ __name((initLearnCard) => {
|
|
|
320
331
|
);
|
|
321
332
|
for (const credential of vcs) {
|
|
322
333
|
try {
|
|
323
|
-
const credCheck = await initLearnCard.invoke.verifyCredential(
|
|
324
|
-
credential
|
|
325
|
-
);
|
|
334
|
+
const credCheck = await initLearnCard.invoke.verifyCredential(credential);
|
|
326
335
|
const issuerDid = typeof credential.issuer === "string" ? credential.issuer : credential.issuer?.id;
|
|
327
336
|
const isSelfIssued = credentialHasLerRsType(credential) || !!holder && !!issuerDid && issuerDid === holder;
|
|
328
337
|
credentialResults.push({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/types.ts", "../src/ler-rs.ts"],
|
|
4
|
-
"sourcesContent": ["export { getLerRsPlugin } from './ler-rs';\nexport * from './types';\n", "import { Plugin, LearnCard } from '@learncard/core';\nimport {\n VC as VerifiableCredential,\n VP as VerifiablePresentation,\n UnsignedVC,\n UnsignedVP,\n VerificationCheck,\n} from '@learncard/types';\nimport type { VCPluginMethods, VCPluginDependentMethods } from '@learncard/vc-plugin';\n\n/**\n * Legacy W3C VC v1 context kept for interop with previously issued records.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V1 = 'https://www.w3.org/2018/credentials/v1';\n/**\n * Base W3C VC v2 context used by newly issued LER-RS credentials and presentations.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V2 = 'https://www.w3.org/ns/credentials/v2';\n/**\n * HR Open Standards VC wrapper context for LER-RS v4.5.\n */\nexport const LER_RS_VC_CONTEXT_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/VerifiableCredentialLER-RSType.json';\n/**\n * Canonical LER-RS type URI for v4.5.\n */\nexport const LER_RS_TYPE_URI_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/LER-RSType.json';\n/**\n * Legacy LER-RS type URI for v4.4 interop.\n */\nexport const LEGACY_LER_RS_TYPE_URI_V44 =\n 'http://schema.hropenstandards.org/4.4/recruiting/json/ler-rs/LER-RSType.json';\n/**\n * Legacy short type token used by older issuers.\n */\nexport const LEGACY_LER_RS_TYPE_TOKEN = 'LERRS';\n/**\n * Hosted TCP JSON-LD context URL.\n *\n * Note: current local wrapper issuance can inline context during local testing.\n */\nexport const TCP_CONTEXT_V1 = 'https://ctx.learncard.com/tcp/1.0.0.json';\n/**\n * LearnCard-defined wrapper VC type for TCP resume package artifacts.\n *\n * This is intentionally NOT a canonical HR Open Standards LER-RS type;\n * it is a custom wrapper used to bind PDF URL/hash + included credential refs.\n */\nexport const TCP_WRAPPER_TYPE = 'TrustedCareerProfile';\n\n/**\n * Identity details used to populate `credentialSubject.person`.\n */\nexport interface PersonProfile {\n /** Subject DID for the issued LER-RS record. */\n id: string;\n /** Given/first name. */\n givenName: string;\n /** Family/last name. */\n familyName: string;\n /** Optional display name override. */\n formattedName?: string;\n /** Optional contact email to include in communication block. */\n email?: string;\n /** Optional contact phone to include in communication block. */\n phone?: string;\n /** Optional physical/mailing address to include in communication block. */\n address?: {\n formattedAddress?: string;\n line?: string;\n city?: string;\n postalCode?: string;\n countryCode?: string;\n };\n /** Optional website URLs to include in communication block. */\n web?: Array<{ url: string; name?: string }>;\n /** Optional social profile URLs to include in communication block. */\n social?: Array<{ uri: string; name?: string }>;\n}\n\n/**\n * Skill item structure used inside generated LER-RS records.\n */\nexport interface LerSkill {\n name: string;\n comments?: string[];\n description?: string;\n yearsOfExperience?: number;\n endorsers?: Array<{\n person?: { name?: { formattedName?: string } };\n organization?: { name?: string };\n }>;\n}\n\n/**\n * Source work history entry. Can be self-asserted fields and/or third-party verification VCs.\n */\nexport interface WorkHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n // Common self-asserted fields\n position?: string;\n employer?: string;\n start?: string;\n end?: string;\n current?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * Source education entry. Can include freeform fields and optional verification VCs.\n */\nexport interface EducationHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n institution?: string;\n start?: string;\n end?: string;\n current?: boolean;\n degree?: string;\n specializations?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Source certification entry for `credentialSubject.certifications`.\n */\nexport interface CertificationItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n name?: string;\n issuingAuthority?: string | Record<string, unknown>;\n status?: string;\n start?: string;\n end?: string;\n effectiveTimePeriod?: { validFrom?: string; validTo?: string };\n [key: string]: unknown;\n}\n\n/**\n * Narrative section block supported by LER-RS schema.\n */\nexport interface LerNarrative {\n name: string;\n texts: Array<{\n name: string;\n lines: string[];\n }>;\n}\n\n/**\n * Typed shape of the LER-RS object embedded into `credentialSubject`.\n */\nexport interface LerRsRecord {\n type: string;\n documentId?: { value: string };\n person: {\n name: {\n given: string;\n family: string;\n formattedName?: string;\n };\n };\n communication?: {\n email?: { address: string }[];\n web?: { url: string; name?: string }[];\n phone?: Array<Record<string, unknown>>;\n address?: Array<Record<string, unknown>>;\n social?: Array<Record<string, unknown>>;\n };\n skills?: LerSkill[];\n narratives?: LerNarrative[];\n educationAndLearnings?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n employmentHistories?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n licenses?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n certifications?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n employmentPreferences?: Array<Record<string, unknown>>;\n positionPreferences?: Array<Record<string, unknown>>;\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a signed LER-RS VC from normalized source data.\n */\nexport interface CreateLerRecordParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n person: PersonProfile;\n workHistory?: WorkHistoryItem[];\n educationHistory?: EducationHistoryItem[];\n certifications?: CertificationItem[];\n skills?: string[];\n narratives?: LerNarrative[];\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a VP that packages one or more credentials including at least one LER-RS credential.\n */\nexport interface CreateLerPresentationParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n credentials: VerifiableCredential[];\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Parameters for verifying a LER-focused VP and nested credentials.\n */\nexport interface VerifyLerPresentationParams {\n presentation: VerifiablePresentation | string;\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Credential reference stored in TCP wrapper VC.\n */\nexport interface TcpIncludedCredentialRef {\n /** Resolved VC id when available; falls back to URI if id is unavailable. */\n id: string;\n /** Category label used for UI grouping and downstream filtering. */\n category: string;\n}\n\n/**\n * Parameters for issuing TrustedCareerProfile wrapper VCs.\n */\nexport interface CreateTcpWrapperVcParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n wrapperId: string;\n subjectDid?: string;\n pdfUrl: string;\n pdfHash: string;\n includedCredentials: TcpIncludedCredentialRef[];\n generatedAt?: string;\n /** Timestamp used as the issued credential's `validFrom` value. */\n issuanceDate?: string;\n coSignerDid?: string;\n enableCoSign?: boolean;\n}\n\n/**\n * Structured verification output for LER presentation verification.\n */\nexport interface VerificationResult {\n verified: boolean; // Overall status\n presentationResult: {\n verified: boolean;\n errors?: string[];\n };\n credentialResults: {\n credential: VerifiableCredential;\n verified: boolean;\n isSelfIssued: boolean;\n errors?: string[];\n }[];\n}\n\n/**\n * LearnCard dependency contract required by this plugin.\n */\nexport type LERRSDependentLearnCard = LearnCard<\n any,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n\n/**\n * Public invoke methods exposed by the LER-RS plugin.\n */\nexport type LERRSPluginMethods = {\n createLerRecord: (params: CreateLerRecordParams) => Promise<VerifiableCredential>;\n createLerPresentation: (params: CreateLerPresentationParams) => Promise<VerifiablePresentation>;\n verifyLerPresentation: (params: VerifyLerPresentationParams) => Promise<VerificationResult>;\n createTcpWrapperVc: (params: CreateTcpWrapperVcParams) => Promise<VerifiableCredential>;\n};\n\n/**\n * Plugin type definition for registration in LearnCard.\n */\nexport type LERRSPlugin = Plugin<\n 'LER-RS',\n never,\n LERRSPluginMethods,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n", "import {\n VC as VerifiableCredential,\n UnsignedVC,\n VP as VerifiablePresentation,\n UnsignedVP,\n} from '@learncard/types';\nimport {\n LERRSDependentLearnCard,\n LERRSPlugin,\n CreateLerRecordParams,\n CreateLerPresentationParams,\n VerifyLerPresentationParams,\n VerificationResult,\n LerRsRecord,\n LER_RS_CREDENTIAL_CONTEXT_V2,\n LER_RS_TYPE_URI_V45,\n LEGACY_LER_RS_TYPE_URI_V44,\n LEGACY_LER_RS_TYPE_TOKEN,\n TCP_WRAPPER_TYPE,\n} from './types';\n\n/**\n * Normalizes verification containers from either:\n * - `verifications: VC[]`\n * - `verifiableCredential: VC`\n */\nconst getItemVerifications = (item: {\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n}): VerifiableCredential[] => {\n if (item.verifications?.length) return item.verifications;\n if (item.verifiableCredential) return [item.verifiableCredential];\n return [];\n};\n\n/**\n * Converts scalar-or-array values into a normalized array.\n */\nconst toArray = <T>(maybe: T | T[] | undefined): T[] =>\n maybe == null ? [] : Array.isArray(maybe) ? maybe : [maybe];\n\n/**\n * Inline LER-RS JSON-LD context used for signing stability.\n *\n * The published HR Open URL is schema-oriented and can trigger additional remote\n * context resolution during expansion. Inlining this base context avoids network\n * dependency at issue time while preserving deterministic term expansion.\n */\nconst inlineLerRsContext = {\n '@version': 1.1,\n hrrec: 'http://schema.hropenstandards.org/recruiting/',\n '@vocab': 'http://schema.hropenstandards.org/recruiting/',\n};\n\n/**\n * Determines whether a VC represents a LER-RS credential (legacy and current forms).\n *\n * Checks:\n * - VC `type` array/token values\n * - `credentialSubject.type`\n * - nested `credentialSubject.lerrsType.type`\n */\nconst credentialHasLerRsType = (credential: VerifiableCredential): boolean => {\n const typeList = Array.isArray(credential.type) ? credential.type : [credential.type];\n if (\n typeList.some(type =>\n [LEGACY_LER_RS_TYPE_TOKEN, LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(\n type\n )\n )\n )\n return true;\n\n const credentialSubject = credential.credentialSubject as Record<string, unknown> | undefined;\n if (!credentialSubject) return false;\n\n const inlineType = credentialSubject.type;\n if (\n typeof inlineType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(inlineType)\n )\n return true;\n\n const nestedType = (credentialSubject.lerrsType as Record<string, unknown> | undefined)?.type;\n return (\n typeof nestedType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(nestedType)\n );\n};\n\n/**\n * Maps application work history items to LER-RS `employmentHistories` shape.\n */\nconst buildEmploymentHistories = (\n items: NonNullable<CreateLerRecordParams['workHistory']>\n): LerRsRecord['employmentHistories'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n position,\n employer,\n start,\n end,\n current,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (typeof current === 'boolean') container.current = current;\n\n if (employer) container.organization = { tradeName: employer };\n if (position || start || end || typeof current === 'boolean') {\n const ph: Record<string, unknown> = {};\n if (position) ph.title = position;\n if (start) ph.start = start;\n if (end) ph.end = end;\n if (typeof current === 'boolean') ph.current = current;\n if (descriptions?.length) ph.descriptions = descriptions;\n container.positionHistories = [ph];\n }\n if (narrative) container.narrative = narrative;\n if (descriptions?.length && !container.positionHistories) container.descriptions = descriptions;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps education source items into LER-RS `educationAndLearnings`.\n */\nconst buildEducationAndLearnings = (\n items: NonNullable<CreateLerRecordParams['educationHistory']>\n): LerRsRecord['educationAndLearnings'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n institution,\n start,\n end,\n current,\n degree,\n specializations,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (institution) container.institution = { name: institution };\n if (start) container.start = start;\n if (end) container.end = end;\n if (typeof current === 'boolean') container.current = current;\n if (descriptions?.length) container.descriptions = descriptions;\n if (degree || specializations) {\n container.educationDegrees = [\n {\n ...(degree ? { name: degree } : {}),\n ...(specializations\n ? {\n specializations: specializations.map(specialization => ({\n name: specialization,\n })),\n }\n : {}),\n },\n ];\n }\n if (narrative) container.narrative = narrative;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps certification source items to LER-RS `certifications`.\n */\nconst buildCertifications = (\n items: NonNullable<CreateLerRecordParams['certifications']>\n): LerRsRecord['certifications'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n start,\n end,\n effectiveTimePeriod,\n verifiableCredential,\n verifications,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (narrative) container.narrative = narrative;\n if (descriptions?.length) container.descriptions = descriptions;\n if (effectiveTimePeriod || start || end) {\n container.effectiveTimePeriod = {\n ...(effectiveTimePeriod ?? {}),\n ...(start ? { validFrom: start } : {}),\n ...(end ? { validTo: end } : {}),\n };\n }\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Returns the LearnCard LER-RS plugin with methods for:\n * - issuing LER-RS VCs\n * - packaging/verifying LER presentations\n * - issuing TCP wrapper VCs for resume packages\n */\nexport const getLerRsPlugin = (initLearnCard: LERRSDependentLearnCard): LERRSPlugin => {\n return {\n name: 'LER-RS',\n displayName: 'LER-RS',\n description:\n 'Create, package, and verify Learning & Employment Record Resume (LER-RS) credentials',\n methods: {\n /**\n * Issues a signed LER-RS VC from normalized person/work/education/certification data.\n *\n * The method:\n * 1. Builds a compliant LER-RS `credentialSubject`\n * 2. Applies VC + LER-RS contexts\n * 3. Signs via `invoke.issueCredential`\n */\n createLerRecord: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = new Date().toISOString();\n const documentId = crypto.randomUUID();\n\n const personSection: LerRsRecord['person'] = {\n name: {\n given: params.person.givenName,\n family: params.person.familyName,\n formattedName:\n params.person.formattedName ??\n `${params.person.givenName} ${params.person.familyName}`,\n },\n };\n\n const hasAddress =\n !!params.person.address?.formattedAddress ||\n !!params.person.address?.line ||\n !!params.person.address?.city ||\n !!params.person.address?.postalCode ||\n !!params.person.address?.countryCode;\n const webEntries = (params.person.web || []).filter(entry => entry?.url);\n const socialEntries = (params.person.social || []).filter(entry => entry?.uri);\n\n const communication: LerRsRecord['communication'] | undefined =\n params.person.email ||\n params.person.phone ||\n hasAddress ||\n webEntries.length > 0 ||\n socialEntries.length > 0\n ? {\n ...(params.person.email\n ? { email: [{ address: params.person.email }] }\n : {}),\n ...(params.person.phone\n ? { phone: [{ formattedNumber: params.person.phone }] }\n : {}),\n ...(webEntries.length\n ? { web: webEntries.map(entry => ({ url: entry.url, name: entry.name })) }\n : {}),\n ...(socialEntries.length\n ? {\n social: socialEntries.map(entry => ({\n uri: entry.uri,\n ...(entry.name ? { name: entry.name } : {}),\n })),\n }\n : {}),\n ...(hasAddress\n ? {\n address: [\n {\n ...(params.person.address?.formattedAddress\n ? {\n formattedAddress:\n params.person.address.formattedAddress,\n }\n : {}),\n ...(params.person.address?.line\n ? { line: params.person.address.line }\n : {}),\n ...(params.person.address?.city\n ? { city: params.person.address.city }\n : {}),\n ...(params.person.address?.postalCode\n ? { postalCode: params.person.address.postalCode }\n : {}),\n ...(params.person.address?.countryCode\n ? {\n countryCode:\n params.person.address.countryCode,\n }\n : {}),\n },\n ],\n }\n : {}),\n }\n : undefined;\n\n const lerRecord: LerRsRecord = {\n type: LER_RS_TYPE_URI_V45,\n documentId: { value: documentId },\n person: personSection,\n ...(communication ? { communication } : {}),\n skills: (params.skills || []).map(s => ({ name: s })),\n narratives: params.narratives,\n employmentHistories: params.workHistory\n ? buildEmploymentHistories(params.workHistory)\n : undefined,\n educationAndLearnings: params.educationHistory\n ? buildEducationAndLearnings(params.educationHistory)\n : undefined,\n certifications: params.certifications\n ? buildCertifications(params.certifications)\n : undefined,\n attachments: params.attachments,\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineLerRsContext],\n id: `urn:uuid:${documentId}`,\n type: ['VerifiableCredential', LER_RS_TYPE_URI_V45],\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: params.person.id,\n ...lerRecord,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n\n /**\n * Issues a VP containing at least one LER-RS credential.\n *\n * Throws if:\n * - credentials list is empty\n * - none of the credentials match LER-RS type checks\n */\n createLerPresentation: async (_learnCard, params): Promise<VerifiablePresentation> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n\n if (!params.credentials.length)\n throw new Error(\n 'createLerPresentation: credentials array must contain at least one credential'\n );\n const containsLer = params.credentials.some(credentialHasLerRsType);\n if (!containsLer)\n throw new Error(\n 'createLerPresentation: credentials must include at least one LER-RS credential'\n );\n\n const vp: UnsignedVP = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2],\n type: ['VerifiablePresentation'],\n holder: did,\n verifiableCredential:\n params.credentials.length === 1\n ? params.credentials[0]\n : params.credentials,\n };\n\n return initLearnCard.invoke.issuePresentation(vp, {\n ...(params.domain ? { domain: params.domain } : {}),\n ...(params.challenge ? { challenge: params.challenge } : {}),\n });\n },\n\n /**\n * Verifies a LER-focused VP and returns structured result details.\n *\n * Overall `verified` allows explicitly self-issued items when determining\n * final status, while still surfacing per-credential verification results.\n */\n verifyLerPresentation: async (\n _learnCard,\n { presentation, domain, challenge }: VerifyLerPresentationParams\n ): Promise<VerificationResult> => {\n const presCheck = await initLearnCard.invoke.verifyPresentation(presentation, {\n ...(domain ? { domain } : {}),\n ...(challenge ? { challenge } : {}),\n });\n\n const presentationResult = {\n verified: presCheck.errors.length === 0,\n errors: presCheck.errors.length ? presCheck.errors : undefined,\n };\n\n const credentialResults: VerificationResult['credentialResults'] = [];\n\n if (typeof presentation !== 'string') {\n const holder = presentation.holder;\n const vcs = toArray<VerifiableCredential>(\n presentation.verifiableCredential as any\n );\n\n for (const credential of vcs) {\n try {\n const credCheck = await initLearnCard.invoke.verifyCredential(\n credential\n );\n const issuerDid =\n typeof credential.issuer === 'string'\n ? credential.issuer\n : credential.issuer?.id;\n const isSelfIssued =\n credentialHasLerRsType(credential) ||\n (!!holder && !!issuerDid && issuerDid === holder);\n\n credentialResults.push({\n credential,\n verified: credCheck.errors.length === 0,\n isSelfIssued,\n errors: credCheck.errors.length ? credCheck.errors : undefined,\n });\n } catch (err) {\n credentialResults.push({\n credential,\n verified: false,\n isSelfIssued: false,\n errors: [\n err instanceof Error\n ? err.message\n : 'Unknown error verifying credential',\n ],\n });\n }\n }\n }\n\n return {\n verified:\n presentationResult.verified &&\n credentialResults.every(r => r.verified || r.isSelfIssued),\n presentationResult,\n credentialResults,\n };\n },\n\n /**\n * Issues a signed TrustedCareerProfile wrapper VC for resume package publishing.\n *\n * Includes:\n * - public PDF URL\n * - PDF SHA-256 hash\n * - included credential references\n * - generation timestamp\n *\n * Co-sign fields are intentionally stubbed for MVP and currently rejected.\n */\n createTcpWrapperVc: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = params.issuanceDate ?? new Date().toISOString();\n const generatedAt = params.generatedAt ?? issuedAt;\n const subjectDid = params.subjectDid ?? did;\n\n if (params.enableCoSign) {\n throw new Error('createTcpWrapperVc: co-signing is not enabled in MVP');\n }\n\n if (params.coSignerDid) {\n throw new Error(\n 'createTcpWrapperVc: coSignerDid is reserved for future co-sign support'\n );\n }\n\n // NOTE: We inline the TCP context for local testing while the hosted\n // context URL is not yet available in all environments.\n const inlineTcpContext = {\n '@version': 1.1,\n id: '@id',\n type: '@type',\n TrustedCareerProfile: 'https://ctx.learncard.com/tcp#TrustedCareerProfile',\n ResumePackage: 'https://ctx.learncard.com/tcp#ResumePackage',\n pdfUrl: {\n '@id': 'https://ctx.learncard.com/tcp#pdfUrl',\n '@type': '@id',\n },\n pdfHash: 'https://ctx.learncard.com/tcp#pdfHash',\n hashAlgorithm: 'https://ctx.learncard.com/tcp#hashAlgorithm',\n includedCredentials: {\n '@id': 'https://ctx.learncard.com/tcp#includedCredentials',\n '@container': '@set',\n },\n category: 'https://ctx.learncard.com/tcp#category',\n generatedAt: {\n '@id': 'https://ctx.learncard.com/tcp#generatedAt',\n '@type': 'http://www.w3.org/2001/XMLSchema#dateTime',\n },\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineTcpContext],\n type: ['VerifiableCredential', TCP_WRAPPER_TYPE],\n id: params.wrapperId,\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: subjectDid,\n type: 'ResumePackage',\n pdfUrl: params.pdfUrl,\n pdfHash: params.pdfHash,\n hashAlgorithm: 'SHA-256',\n includedCredentials: params.includedCredentials,\n generatedAt,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n },\n };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,IAAM,+BAA+B;AAIrC,IAAM,+BAA+B;AAIrC,IAAM,wBACT;AAIG,IAAM,sBACT;AAIG,IAAM,6BACT;AAIG,IAAM,2BAA2B;AAMjC,IAAM,iBAAiB;AAOvB,IAAM,mBAAmB;;;ACvBhC,IAAM,uBAAuB,wBAAC,SAGA;AAC1B,MAAI,KAAK,eAAe,OAAQ,QAAO,KAAK;AAC5C,MAAI,KAAK,qBAAsB,QAAO,CAAC,KAAK,oBAAoB;AAChE,SAAO,CAAC;AACZ,GAP6B;AAY7B,IAAM,UAAU,wBAAI,UAChB,SAAS,OAAO,CAAC,IAAI,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,GAD9C;AAUhB,IAAM,qBAAqB;AAAA,EACvB,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,UAAU;
|
|
4
|
+
"sourcesContent": ["export { getLerRsPlugin } from './ler-rs';\nexport * from './types';\n", "import { Plugin, LearnCard } from '@learncard/core';\nimport {\n VC as VerifiableCredential,\n VP as VerifiablePresentation,\n UnsignedVC,\n UnsignedVP,\n VerificationCheck,\n} from '@learncard/types';\nimport type { VCPluginMethods, VCPluginDependentMethods } from '@learncard/vc-plugin';\n\n/**\n * Legacy W3C VC v1 context kept for interop with previously issued records.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V1 = 'https://www.w3.org/2018/credentials/v1';\n/**\n * Base W3C VC v2 context used by newly issued LER-RS credentials and presentations.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V2 = 'https://www.w3.org/ns/credentials/v2';\n/**\n * HR Open Standards VC wrapper context for LER-RS v4.5.\n */\nexport const LER_RS_VC_CONTEXT_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/VerifiableCredentialLER-RSType.json';\n/**\n * Canonical LER-RS type URI for v4.5.\n */\nexport const LER_RS_TYPE_URI_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/LER-RSType.json';\n/**\n * Legacy LER-RS type URI for v4.4 interop.\n */\nexport const LEGACY_LER_RS_TYPE_URI_V44 =\n 'http://schema.hropenstandards.org/4.4/recruiting/json/ler-rs/LER-RSType.json';\n/**\n * Legacy short type token used by older issuers.\n */\nexport const LEGACY_LER_RS_TYPE_TOKEN = 'LERRS';\n/**\n * Hosted TCP JSON-LD context URL.\n *\n * Note: current local wrapper issuance can inline context during local testing.\n */\nexport const TCP_CONTEXT_V1 = 'https://ctx.learncard.com/tcp/1.0.0.json';\n/**\n * LearnCard-defined wrapper VC type for TCP resume package artifacts.\n *\n * This is intentionally NOT a canonical HR Open Standards LER-RS type;\n * it is a custom wrapper used to bind PDF URL/hash + included credential refs.\n */\nexport const TCP_WRAPPER_TYPE = 'TrustedCareerProfile';\n\n/**\n * Identity details used to populate `credentialSubject.person`.\n */\nexport interface PersonProfile {\n /** Subject DID for the issued LER-RS record. */\n id: string;\n /** Given/first name. */\n givenName: string;\n /** Family/last name. */\n familyName: string;\n /** Optional display name override. */\n formattedName?: string;\n /** Optional contact email to include in communication block. */\n email?: string;\n /** Optional contact phone to include in communication block. */\n phone?: string;\n /** Optional physical/mailing address to include in communication block. */\n address?: {\n formattedAddress?: string;\n line?: string;\n city?: string;\n postalCode?: string;\n countryCode?: string;\n };\n /** Optional website URLs to include in communication block. */\n web?: Array<{ url: string; name?: string }>;\n /** Optional social profile URLs to include in communication block. */\n social?: Array<{ uri: string; name?: string }>;\n}\n\n/**\n * Skill item structure used inside generated LER-RS records.\n */\nexport interface LerSkill {\n name: string;\n comments?: string[];\n description?: string;\n yearsOfExperience?: number;\n endorsers?: Array<{\n person?: { name?: { formattedName?: string } };\n organization?: { name?: string };\n }>;\n}\n\n/**\n * Source work history entry. Can be self-asserted fields and/or third-party verification VCs.\n */\nexport interface WorkHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n // Common self-asserted fields\n position?: string;\n employer?: string;\n start?: string;\n end?: string;\n current?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * Source education entry. Can include freeform fields and optional verification VCs.\n */\nexport interface EducationHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n institution?: string;\n start?: string;\n end?: string;\n current?: boolean;\n degree?: string;\n specializations?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Source certification entry for `credentialSubject.certifications`.\n */\nexport interface CertificationItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n name?: string;\n issuingAuthority?: string | Record<string, unknown>;\n status?: string;\n start?: string;\n end?: string;\n effectiveTimePeriod?: { validFrom?: string; validTo?: string };\n [key: string]: unknown;\n}\n\n/**\n * Narrative section block supported by LER-RS schema.\n */\nexport interface LerNarrative {\n name: string;\n texts: Array<{\n name: string;\n lines: string[];\n }>;\n}\n\n/**\n * Typed shape of the LER-RS object embedded into `credentialSubject`.\n */\nexport interface LerRsRecord {\n type: string;\n documentId?: { value: string };\n person: {\n name: {\n given: string;\n family: string;\n formattedName?: string;\n };\n };\n communication?: {\n email?: { address: string }[];\n web?: { url: string; name?: string }[];\n phone?: Array<Record<string, unknown>>;\n address?: Array<Record<string, unknown>>;\n social?: Array<Record<string, unknown>>;\n };\n skills?: LerSkill[];\n narratives?: LerNarrative[];\n educationAndLearnings?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n employmentHistories?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n licenses?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n certifications?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n employmentPreferences?: Array<Record<string, unknown>>;\n positionPreferences?: Array<Record<string, unknown>>;\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a signed LER-RS VC from normalized source data.\n */\nexport interface CreateLerRecordParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n person: PersonProfile;\n workHistory?: WorkHistoryItem[];\n educationHistory?: EducationHistoryItem[];\n certifications?: CertificationItem[];\n skills?: string[];\n narratives?: LerNarrative[];\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a VP that packages one or more credentials including at least one LER-RS credential.\n */\nexport interface CreateLerPresentationParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n credentials: VerifiableCredential[];\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Parameters for verifying a LER-focused VP and nested credentials.\n */\nexport interface VerifyLerPresentationParams {\n presentation: VerifiablePresentation | string;\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Credential reference stored in TCP wrapper VC.\n */\nexport interface TcpIncludedCredentialRef {\n /** Resolved VC id when available; falls back to URI if id is unavailable. */\n id: string;\n /** Category label used for UI grouping and downstream filtering. */\n category: string;\n}\n\n/**\n * Parameters for issuing TrustedCareerProfile wrapper VCs.\n */\nexport interface CreateTcpWrapperVcParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n wrapperId: string;\n subjectDid?: string;\n pdfUrl: string;\n pdfHash: string;\n includedCredentials: TcpIncludedCredentialRef[];\n generatedAt?: string;\n /** Timestamp used as the issued credential's `validFrom` value. */\n issuanceDate?: string;\n coSignerDid?: string;\n enableCoSign?: boolean;\n}\n\n/**\n * Structured verification output for LER presentation verification.\n */\nexport interface VerificationResult {\n verified: boolean; // Overall status\n presentationResult: {\n verified: boolean;\n errors?: string[];\n };\n credentialResults: {\n credential: VerifiableCredential;\n verified: boolean;\n isSelfIssued: boolean;\n errors?: string[];\n }[];\n}\n\n/**\n * LearnCard dependency contract required by this plugin.\n */\nexport type LERRSDependentLearnCard = LearnCard<\n any,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n\n/**\n * Public invoke methods exposed by the LER-RS plugin.\n */\nexport type LERRSPluginMethods = {\n createLerRecord: (params: CreateLerRecordParams) => Promise<VerifiableCredential>;\n createLerPresentation: (params: CreateLerPresentationParams) => Promise<VerifiablePresentation>;\n verifyLerPresentation: (params: VerifyLerPresentationParams) => Promise<VerificationResult>;\n createTcpWrapperVc: (params: CreateTcpWrapperVcParams) => Promise<VerifiableCredential>;\n};\n\n/**\n * Plugin type definition for registration in LearnCard.\n */\nexport type LERRSPlugin = Plugin<\n 'LER-RS',\n never,\n LERRSPluginMethods,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n", "import {\n VC as VerifiableCredential,\n UnsignedVC,\n VP as VerifiablePresentation,\n UnsignedVP,\n} from '@learncard/types';\nimport {\n LERRSDependentLearnCard,\n LERRSPlugin,\n CreateLerRecordParams,\n CreateLerPresentationParams,\n VerifyLerPresentationParams,\n VerificationResult,\n LerRsRecord,\n LER_RS_CREDENTIAL_CONTEXT_V2,\n LER_RS_TYPE_URI_V45,\n LEGACY_LER_RS_TYPE_URI_V44,\n LEGACY_LER_RS_TYPE_TOKEN,\n TCP_WRAPPER_TYPE,\n} from './types';\n\n/**\n * Normalizes verification containers from either:\n * - `verifications: VC[]`\n * - `verifiableCredential: VC`\n */\nconst getItemVerifications = (item: {\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n}): VerifiableCredential[] => {\n if (item.verifications?.length) return item.verifications;\n if (item.verifiableCredential) return [item.verifiableCredential];\n return [];\n};\n\n/**\n * Converts scalar-or-array values into a normalized array.\n */\nconst toArray = <T>(maybe: T | T[] | undefined): T[] =>\n maybe == null ? [] : Array.isArray(maybe) ? maybe : [maybe];\n\n/**\n * Inline LER-RS JSON-LD context used for signing stability.\n *\n * The published HR Open URL is schema-oriented and can trigger additional remote\n * context resolution during expansion. Inlining this base context avoids network\n * dependency at issue time while preserving deterministic term expansion.\n */\nconst inlineLerRsContext = {\n '@version': 1.1,\n hrrec: 'http://schema.hropenstandards.org/recruiting/',\n '@vocab': 'http://schema.hropenstandards.org/recruiting/',\n // Bind complete source credentials as JSON without inheriting the wrapper's\n // protected VC v2 terms into older VC v1 contexts or altering issuer proofs.\n verifications: { '@id': 'hrrec:verifications', '@type': '@json' },\n};\n\n/**\n * Determines whether a VC represents a LER-RS credential (legacy and current forms).\n *\n * Checks:\n * - VC `type` array/token values\n * - `credentialSubject.type`\n * - nested `credentialSubject.lerrsType.type`\n */\nconst credentialHasLerRsType = (credential: VerifiableCredential): boolean => {\n const typeList = Array.isArray(credential.type) ? credential.type : [credential.type];\n if (\n typeList.some(type =>\n [LEGACY_LER_RS_TYPE_TOKEN, LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(\n type\n )\n )\n )\n return true;\n\n const credentialSubject = credential.credentialSubject as Record<string, unknown> | undefined;\n if (!credentialSubject) return false;\n\n const inlineType = credentialSubject.type;\n if (\n typeof inlineType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(inlineType)\n )\n return true;\n\n const nestedType = (credentialSubject.lerrsType as Record<string, unknown> | undefined)?.type;\n return (\n typeof nestedType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(nestedType)\n );\n};\n\n/**\n * Maps application work history items to LER-RS `employmentHistories` shape.\n */\nconst buildEmploymentHistories = (\n items: NonNullable<CreateLerRecordParams['workHistory']>\n): LerRsRecord['employmentHistories'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n position,\n employer,\n start,\n end,\n current,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (typeof current === 'boolean') container.current = current;\n\n if (employer) container.organization = { tradeName: employer };\n if (position || start || end || typeof current === 'boolean') {\n const ph: Record<string, unknown> = {};\n if (position) ph.title = position;\n if (start) ph.start = start;\n if (end) ph.end = end;\n if (typeof current === 'boolean') ph.current = current;\n if (descriptions?.length) ph.descriptions = descriptions;\n container.positionHistories = [ph];\n }\n if (narrative) container.narrative = narrative;\n if (descriptions?.length && !container.positionHistories)\n container.descriptions = descriptions;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps education source items into LER-RS `educationAndLearnings`.\n */\nconst buildEducationAndLearnings = (\n items: NonNullable<CreateLerRecordParams['educationHistory']>\n): LerRsRecord['educationAndLearnings'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n institution,\n start,\n end,\n current,\n degree,\n specializations,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (institution) container.institution = { name: institution };\n if (start) container.start = start;\n if (end) container.end = end;\n if (typeof current === 'boolean') container.current = current;\n if (descriptions?.length) container.descriptions = descriptions;\n if (degree || specializations) {\n container.educationDegrees = [\n {\n ...(degree ? { name: degree } : {}),\n ...(specializations\n ? {\n specializations: specializations.map(specialization => ({\n name: specialization,\n })),\n }\n : {}),\n },\n ];\n }\n if (narrative) container.narrative = narrative;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps certification source items to LER-RS `certifications`.\n */\nconst buildCertifications = (\n items: NonNullable<CreateLerRecordParams['certifications']>\n): LerRsRecord['certifications'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n start,\n end,\n effectiveTimePeriod,\n verifiableCredential,\n verifications,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (narrative) container.narrative = narrative;\n if (descriptions?.length) container.descriptions = descriptions;\n if (effectiveTimePeriod || start || end) {\n container.effectiveTimePeriod = {\n ...(effectiveTimePeriod ?? {}),\n ...(start ? { validFrom: start } : {}),\n ...(end ? { validTo: end } : {}),\n };\n }\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Returns the LearnCard LER-RS plugin with methods for:\n * - issuing LER-RS VCs\n * - packaging/verifying LER presentations\n * - issuing TCP wrapper VCs for resume packages\n */\nexport const getLerRsPlugin = (initLearnCard: LERRSDependentLearnCard): LERRSPlugin => {\n return {\n name: 'LER-RS',\n displayName: 'LER-RS',\n description:\n 'Create, package, and verify Learning & Employment Record Resume (LER-RS) credentials',\n methods: {\n /**\n * Issues a signed LER-RS VC from normalized person/work/education/certification data.\n *\n * The method:\n * 1. Builds a compliant LER-RS `credentialSubject`\n * 2. Applies VC + LER-RS contexts\n * 3. Signs via `invoke.issueCredential`\n */\n createLerRecord: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = new Date().toISOString();\n const documentId = crypto.randomUUID();\n\n const personSection: LerRsRecord['person'] = {\n name: {\n given: params.person.givenName,\n family: params.person.familyName,\n formattedName:\n params.person.formattedName ??\n `${params.person.givenName} ${params.person.familyName}`,\n },\n };\n\n const hasAddress =\n !!params.person.address?.formattedAddress ||\n !!params.person.address?.line ||\n !!params.person.address?.city ||\n !!params.person.address?.postalCode ||\n !!params.person.address?.countryCode;\n const webEntries = (params.person.web || []).filter(entry => entry?.url);\n const socialEntries = (params.person.social || []).filter(entry => entry?.uri);\n\n const communication: LerRsRecord['communication'] | undefined =\n params.person.email ||\n params.person.phone ||\n hasAddress ||\n webEntries.length > 0 ||\n socialEntries.length > 0\n ? {\n ...(params.person.email\n ? { email: [{ address: params.person.email }] }\n : {}),\n ...(params.person.phone\n ? { phone: [{ formattedNumber: params.person.phone }] }\n : {}),\n ...(webEntries.length\n ? {\n web: webEntries.map(entry => ({\n url: entry.url,\n name: entry.name,\n })),\n }\n : {}),\n ...(socialEntries.length\n ? {\n social: socialEntries.map(entry => ({\n uri: entry.uri,\n ...(entry.name ? { name: entry.name } : {}),\n })),\n }\n : {}),\n ...(hasAddress\n ? {\n address: [\n {\n ...(params.person.address?.formattedAddress\n ? {\n formattedAddress:\n params.person.address\n .formattedAddress,\n }\n : {}),\n ...(params.person.address?.line\n ? { line: params.person.address.line }\n : {}),\n ...(params.person.address?.city\n ? { city: params.person.address.city }\n : {}),\n ...(params.person.address?.postalCode\n ? {\n postalCode:\n params.person.address.postalCode,\n }\n : {}),\n ...(params.person.address?.countryCode\n ? {\n countryCode:\n params.person.address.countryCode,\n }\n : {}),\n },\n ],\n }\n : {}),\n }\n : undefined;\n\n const lerRecord: LerRsRecord = {\n type: LER_RS_TYPE_URI_V45,\n documentId: { value: documentId },\n person: personSection,\n ...(communication ? { communication } : {}),\n skills: (params.skills || []).map(s => ({ name: s })),\n narratives: params.narratives,\n employmentHistories: params.workHistory\n ? buildEmploymentHistories(params.workHistory)\n : undefined,\n educationAndLearnings: params.educationHistory\n ? buildEducationAndLearnings(params.educationHistory)\n : undefined,\n certifications: params.certifications\n ? buildCertifications(params.certifications)\n : undefined,\n attachments: params.attachments,\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineLerRsContext],\n id: `urn:uuid:${documentId}`,\n type: ['VerifiableCredential', LER_RS_TYPE_URI_V45],\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: params.person.id,\n ...lerRecord,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n\n /**\n * Issues a VP containing at least one LER-RS credential.\n *\n * Throws if:\n * - credentials list is empty\n * - none of the credentials match LER-RS type checks\n */\n createLerPresentation: async (_learnCard, params): Promise<VerifiablePresentation> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n\n if (!params.credentials.length)\n throw new Error(\n 'createLerPresentation: credentials array must contain at least one credential'\n );\n const containsLer = params.credentials.some(credentialHasLerRsType);\n if (!containsLer)\n throw new Error(\n 'createLerPresentation: credentials must include at least one LER-RS credential'\n );\n\n const vp: UnsignedVP = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2],\n type: ['VerifiablePresentation'],\n holder: did,\n verifiableCredential:\n params.credentials.length === 1\n ? params.credentials[0]\n : params.credentials,\n };\n\n return initLearnCard.invoke.issuePresentation(vp, {\n ...(params.domain ? { domain: params.domain } : {}),\n ...(params.challenge ? { challenge: params.challenge } : {}),\n });\n },\n\n /**\n * Verifies a LER-focused VP and returns structured result details.\n *\n * Overall `verified` allows explicitly self-issued items when determining\n * final status, while still surfacing per-credential verification results.\n */\n verifyLerPresentation: async (\n _learnCard,\n { presentation, domain, challenge }: VerifyLerPresentationParams\n ): Promise<VerificationResult> => {\n const presCheck = await initLearnCard.invoke.verifyPresentation(presentation, {\n ...(domain ? { domain } : {}),\n ...(challenge ? { challenge } : {}),\n });\n\n const presentationResult = {\n verified: presCheck.errors.length === 0,\n errors: presCheck.errors.length ? presCheck.errors : undefined,\n };\n\n const credentialResults: VerificationResult['credentialResults'] = [];\n\n if (typeof presentation !== 'string') {\n const holder = presentation.holder;\n const vcs = toArray<VerifiableCredential>(\n presentation.verifiableCredential as any\n );\n\n for (const credential of vcs) {\n try {\n const credCheck =\n await initLearnCard.invoke.verifyCredential(credential);\n const issuerDid =\n typeof credential.issuer === 'string'\n ? credential.issuer\n : credential.issuer?.id;\n const isSelfIssued =\n credentialHasLerRsType(credential) ||\n (!!holder && !!issuerDid && issuerDid === holder);\n\n credentialResults.push({\n credential,\n verified: credCheck.errors.length === 0,\n isSelfIssued,\n errors: credCheck.errors.length ? credCheck.errors : undefined,\n });\n } catch (err) {\n credentialResults.push({\n credential,\n verified: false,\n isSelfIssued: false,\n errors: [\n err instanceof Error\n ? err.message\n : 'Unknown error verifying credential',\n ],\n });\n }\n }\n }\n\n return {\n verified:\n presentationResult.verified &&\n credentialResults.every(r => r.verified || r.isSelfIssued),\n presentationResult,\n credentialResults,\n };\n },\n\n /**\n * Issues a signed TrustedCareerProfile wrapper VC for resume package publishing.\n *\n * Includes:\n * - public PDF URL\n * - PDF SHA-256 hash\n * - included credential references\n * - generation timestamp\n *\n * Co-sign fields are intentionally stubbed for MVP and currently rejected.\n */\n createTcpWrapperVc: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = params.issuanceDate ?? new Date().toISOString();\n const generatedAt = params.generatedAt ?? issuedAt;\n const subjectDid = params.subjectDid ?? did;\n\n if (params.enableCoSign) {\n throw new Error('createTcpWrapperVc: co-signing is not enabled in MVP');\n }\n\n if (params.coSignerDid) {\n throw new Error(\n 'createTcpWrapperVc: coSignerDid is reserved for future co-sign support'\n );\n }\n\n // NOTE: We inline the TCP context for local testing while the hosted\n // context URL is not yet available in all environments.\n const inlineTcpContext = {\n '@version': 1.1,\n id: '@id',\n type: '@type',\n TrustedCareerProfile: 'https://ctx.learncard.com/tcp#TrustedCareerProfile',\n ResumePackage: 'https://ctx.learncard.com/tcp#ResumePackage',\n pdfUrl: {\n '@id': 'https://ctx.learncard.com/tcp#pdfUrl',\n '@type': '@id',\n },\n pdfHash: 'https://ctx.learncard.com/tcp#pdfHash',\n hashAlgorithm: 'https://ctx.learncard.com/tcp#hashAlgorithm',\n includedCredentials: {\n '@id': 'https://ctx.learncard.com/tcp#includedCredentials',\n '@container': '@set',\n },\n category: 'https://ctx.learncard.com/tcp#category',\n generatedAt: {\n '@id': 'https://ctx.learncard.com/tcp#generatedAt',\n '@type': 'http://www.w3.org/2001/XMLSchema#dateTime',\n },\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineTcpContext],\n type: ['VerifiableCredential', TCP_WRAPPER_TYPE],\n id: params.wrapperId,\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: subjectDid,\n type: 'ResumePackage',\n pdfUrl: params.pdfUrl,\n pdfHash: params.pdfHash,\n hashAlgorithm: 'SHA-256',\n includedCredentials: params.includedCredentials,\n generatedAt,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n },\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,IAAM,+BAA+B;AAIrC,IAAM,+BAA+B;AAIrC,IAAM,wBACT;AAIG,IAAM,sBACT;AAIG,IAAM,6BACT;AAIG,IAAM,2BAA2B;AAMjC,IAAM,iBAAiB;AAOvB,IAAM,mBAAmB;;;ACvBhC,IAAM,uBAAuB,w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ict";var h=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(r,t)=>h(r,"name",{value:t,configurable:!0});var k=(r,t)=>{for(var e in t)h(r,e,{get:t[e],enumerable:!0})},S=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!A.call(r,n)&&n!==e&&h(r,n,{get:()=>t[n],enumerable:!(s=w(t,n))||s.enumerable});return r};var _=r=>S(h({},"__esModule",{value:!0}),r);var Y={};k(Y,{LEGACY_LER_RS_TYPE_TOKEN:()=>P,LEGACY_LER_RS_TYPE_URI_V44:()=>y,LER_RS_CREDENTIAL_CONTEXT_V1:()=>x,LER_RS_CREDENTIAL_CONTEXT_V2:()=>m,LER_RS_TYPE_URI_V45:()=>R,LER_RS_VC_CONTEXT_V45:()=>N,TCP_CONTEXT_V1:()=>I,TCP_WRAPPER_TYPE:()=>v,getLerRsPlugin:()=>b});module.exports=_(Y);var x="https://www.w3.org/2018/credentials/v1",m="https://www.w3.org/ns/credentials/v2",N="http://schema.hropenstandards.org/4.5/recruiting/json/VerifiableCredentialLER-RSType.json",R="http://schema.hropenstandards.org/4.5/recruiting/json/LER-RSType.json",y="http://schema.hropenstandards.org/4.4/recruiting/json/ler-rs/LER-RSType.json",P="LERRS",I="https://ctx.learncard.com/tcp/1.0.0.json",v="TrustedCareerProfile";var V=C(r=>r.verifications?.length?r.verifications:r.verifiableCredential?[r.verifiableCredential]:[],"getItemVerifications"),D=C(r=>r==null?[]:Array.isArray(r)?r:[r],"toArray"),H={"@version":1.1,hrrec:"http://schema.hropenstandards.org/recruiting/","@vocab":"http://schema.hropenstandards.org/recruiting/"},L=C(r=>{if((Array.isArray(r.type)?r.type:[r.type]).some(a=>[P,y,R].includes(a)))return!0;let e=r.credentialSubject;if(!e)return!1;let s=e.type;if(typeof s=="string"&&[y,R].includes(s))return!0;let n=e.lerrsType?.type;return typeof n=="string"&&[y,R].includes(n)},"credentialHasLerRsType"),U=C(r=>r.map(t=>{let{narrative:e,descriptions:s,verifiableCredential:n,verifications:a,position:d,employer:f,start:c,end:g,current:i,...l}=t,p={...l};if(typeof i=="boolean"&&(p.current=i),f&&(p.organization={tradeName:f}),d||c||g||typeof i=="boolean"){let o={};d&&(o.title=d),c&&(o.start=c),g&&(o.end=g),typeof i=="boolean"&&(o.current=i),s?.length&&(o.descriptions=s),p.positionHistories=[o]}e&&(p.narrative=e),s?.length&&!p.positionHistories&&(p.descriptions=s);let u=V({verifiableCredential:n,verifications:a});return{...p,...u.length?{verifications:u}:{}}}),"buildEmploymentHistories"),M=C(r=>r.map(t=>{let{narrative:e,descriptions:s,verifiableCredential:n,verifications:a,institution:d,start:f,end:c,current:g,degree:i,specializations:l,...p}=t,u={...p};d&&(u.institution={name:d}),f&&(u.start=f),c&&(u.end=c),typeof g=="boolean"&&(u.current=g),s?.length&&(u.descriptions=s),(i||l)&&(u.educationDegrees=[{...i?{name:i}:{},...l?{specializations:l.map(E=>({name:E}))}:{}}]),e&&(u.narrative=e);let o=V({verifiableCredential:n,verifications:a});return{...u,...o.length?{verifications:o}:{}}}),"buildEducationAndLearnings"),j=C(r=>r.map(t=>{let{narrative:e,descriptions:s,start:n,end:a,effectiveTimePeriod:d,verifiableCredential:f,verifications:c,...g}=t,i={...g};e&&(i.narrative=e),s?.length&&(i.descriptions=s),(d||n||a)&&(i.effectiveTimePeriod={...d??{},...n?{validFrom:n}:{},...a?{validTo:a}:{}});let l=V({verifiableCredential:f,verifications:c});return{...i,...l.length?{verifications:l}:{}}}),"buildCertifications"),b=C(r=>({name:"LER-RS",displayName:"LER-RS",description:"Create, package, and verify Learning & Employment Record Resume (LER-RS) credentials",methods:{createLerRecord:C(async(t,e)=>{let n=(e.learnCard??t).id.did(),a=new Date().toISOString(),d=crypto.randomUUID(),f={name:{given:e.person.givenName,family:e.person.familyName,formattedName:e.person.formattedName??`${e.person.givenName} ${e.person.familyName}`}},c=!!e.person.address?.formattedAddress||!!e.person.address?.line||!!e.person.address?.city||!!e.person.address?.postalCode||!!e.person.address?.countryCode,g=(e.person.web||[]).filter(o=>o?.url),i=(e.person.social||[]).filter(o=>o?.uri),l=e.person.email||e.person.phone||c||g.length>0||i.length>0?{...e.person.email?{email:[{address:e.person.email}]}:{},...e.person.phone?{phone:[{formattedNumber:e.person.phone}]}:{},...g.length?{web:g.map(o=>({url:o.url,name:o.name}))}:{},...i.length?{social:i.map(o=>({uri:o.uri,...o.name?{name:o.name}:{}}))}:{},...c?{address:[{...e.person.address?.formattedAddress?{formattedAddress:e.person.address.formattedAddress}:{},...e.person.address?.line?{line:e.person.address.line}:{},...e.person.address?.city?{city:e.person.address.city}:{},...e.person.address?.postalCode?{postalCode:e.person.address.postalCode}:{},...e.person.address?.countryCode?{countryCode:e.person.address.countryCode}:{}}]}:{}}:void 0,p={type:R,documentId:{value:d},person:f,...l?{communication:l}:{},skills:(e.skills||[]).map(o=>({name:o})),narratives:e.narratives,employmentHistories:e.workHistory?U(e.workHistory):void 0,educationAndLearnings:e.educationHistory?M(e.educationHistory):void 0,certifications:e.certifications?j(e.certifications):void 0,attachments:e.attachments},u={"@context":[m,H],id:`urn:uuid:${d}`,type:["VerifiableCredential",R],issuer:n,validFrom:a,credentialSubject:{id:e.person.id,...p}};return r.invoke.issueCredential(u,{proofPurpose:"assertionMethod"})},"createLerRecord"),createLerPresentation:C(async(t,e)=>{let n=(e.learnCard??t).id.did();if(!e.credentials.length)throw new Error("createLerPresentation: credentials array must contain at least one credential");if(!e.credentials.some(L))throw new Error("createLerPresentation: credentials must include at least one LER-RS credential");let d={"@context":[m],type:["VerifiablePresentation"],holder:n,verifiableCredential:e.credentials.length===1?e.credentials[0]:e.credentials};return r.invoke.issuePresentation(d,{...e.domain?{domain:e.domain}:{},...e.challenge?{challenge:e.challenge}:{}})},"createLerPresentation"),verifyLerPresentation:C(async(t,{presentation:e,domain:s,challenge:n})=>{let a=await r.invoke.verifyPresentation(e,{...s?{domain:s}:{},...n?{challenge:n}:{}}),d={verified:a.errors.length===0,errors:a.errors.length?a.errors:void 0},f=[];if(typeof e!="string"){let c=e.holder,g=D(e.verifiableCredential);for(let i of g)try{let l=await r.invoke.verifyCredential(i),p=typeof i.issuer=="string"?i.issuer:i.issuer?.id,u=L(i)||!!c&&!!p&&p===c;f.push({credential:i,verified:l.errors.length===0,isSelfIssued:u,errors:l.errors.length?l.errors:void 0})}catch(l){f.push({credential:i,verified:!1,isSelfIssued:!1,errors:[l instanceof Error?l.message:"Unknown error verifying credential"]})}}return{verified:d.verified&&f.every(c=>c.verified||c.isSelfIssued),presentationResult:d,credentialResults:f}},"verifyLerPresentation"),createTcpWrapperVc:C(async(t,e)=>{let n=(e.learnCard??t).id.did(),a=e.issuanceDate??new Date().toISOString(),d=e.generatedAt??a,f=e.subjectDid??n;if(e.enableCoSign)throw new Error("createTcpWrapperVc: co-signing is not enabled in MVP");if(e.coSignerDid)throw new Error("createTcpWrapperVc: coSignerDid is reserved for future co-sign support");let g={"@context":[m,{"@version":1.1,id:"@id",type:"@type",TrustedCareerProfile:"https://ctx.learncard.com/tcp#TrustedCareerProfile",ResumePackage:"https://ctx.learncard.com/tcp#ResumePackage",pdfUrl:{"@id":"https://ctx.learncard.com/tcp#pdfUrl","@type":"@id"},pdfHash:"https://ctx.learncard.com/tcp#pdfHash",hashAlgorithm:"https://ctx.learncard.com/tcp#hashAlgorithm",includedCredentials:{"@id":"https://ctx.learncard.com/tcp#includedCredentials","@container":"@set"},category:"https://ctx.learncard.com/tcp#category",generatedAt:{"@id":"https://ctx.learncard.com/tcp#generatedAt","@type":"http://www.w3.org/2001/XMLSchema#dateTime"}}],type:["VerifiableCredential",v],id:e.wrapperId,issuer:n,validFrom:a,credentialSubject:{id:f,type:"ResumePackage",pdfUrl:e.pdfUrl,pdfHash:e.pdfHash,hashAlgorithm:"SHA-256",includedCredentials:e.includedCredentials,generatedAt:d}};return r.invoke.issueCredential(g,{proofPurpose:"assertionMethod"})},"createTcpWrapperVc")}}),"getLerRsPlugin");
|
|
1
|
+
"use strict";var h=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(r,t)=>h(r,"name",{value:t,configurable:!0});var k=(r,t)=>{for(var e in t)h(r,e,{get:t[e],enumerable:!0})},S=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!A.call(r,n)&&n!==e&&h(r,n,{get:()=>t[n],enumerable:!(s=w(t,n))||s.enumerable});return r};var _=r=>S(h({},"__esModule",{value:!0}),r);var Y={};k(Y,{LEGACY_LER_RS_TYPE_TOKEN:()=>P,LEGACY_LER_RS_TYPE_URI_V44:()=>y,LER_RS_CREDENTIAL_CONTEXT_V1:()=>x,LER_RS_CREDENTIAL_CONTEXT_V2:()=>m,LER_RS_TYPE_URI_V45:()=>R,LER_RS_VC_CONTEXT_V45:()=>N,TCP_CONTEXT_V1:()=>I,TCP_WRAPPER_TYPE:()=>v,getLerRsPlugin:()=>b});module.exports=_(Y);var x="https://www.w3.org/2018/credentials/v1",m="https://www.w3.org/ns/credentials/v2",N="http://schema.hropenstandards.org/4.5/recruiting/json/VerifiableCredentialLER-RSType.json",R="http://schema.hropenstandards.org/4.5/recruiting/json/LER-RSType.json",y="http://schema.hropenstandards.org/4.4/recruiting/json/ler-rs/LER-RSType.json",P="LERRS",I="https://ctx.learncard.com/tcp/1.0.0.json",v="TrustedCareerProfile";var V=C(r=>r.verifications?.length?r.verifications:r.verifiableCredential?[r.verifiableCredential]:[],"getItemVerifications"),D=C(r=>r==null?[]:Array.isArray(r)?r:[r],"toArray"),H={"@version":1.1,hrrec:"http://schema.hropenstandards.org/recruiting/","@vocab":"http://schema.hropenstandards.org/recruiting/",verifications:{"@id":"hrrec:verifications","@type":"@json"}},L=C(r=>{if((Array.isArray(r.type)?r.type:[r.type]).some(a=>[P,y,R].includes(a)))return!0;let e=r.credentialSubject;if(!e)return!1;let s=e.type;if(typeof s=="string"&&[y,R].includes(s))return!0;let n=e.lerrsType?.type;return typeof n=="string"&&[y,R].includes(n)},"credentialHasLerRsType"),U=C(r=>r.map(t=>{let{narrative:e,descriptions:s,verifiableCredential:n,verifications:a,position:d,employer:f,start:c,end:g,current:i,...l}=t,p={...l};if(typeof i=="boolean"&&(p.current=i),f&&(p.organization={tradeName:f}),d||c||g||typeof i=="boolean"){let o={};d&&(o.title=d),c&&(o.start=c),g&&(o.end=g),typeof i=="boolean"&&(o.current=i),s?.length&&(o.descriptions=s),p.positionHistories=[o]}e&&(p.narrative=e),s?.length&&!p.positionHistories&&(p.descriptions=s);let u=V({verifiableCredential:n,verifications:a});return{...p,...u.length?{verifications:u}:{}}}),"buildEmploymentHistories"),M=C(r=>r.map(t=>{let{narrative:e,descriptions:s,verifiableCredential:n,verifications:a,institution:d,start:f,end:c,current:g,degree:i,specializations:l,...p}=t,u={...p};d&&(u.institution={name:d}),f&&(u.start=f),c&&(u.end=c),typeof g=="boolean"&&(u.current=g),s?.length&&(u.descriptions=s),(i||l)&&(u.educationDegrees=[{...i?{name:i}:{},...l?{specializations:l.map(E=>({name:E}))}:{}}]),e&&(u.narrative=e);let o=V({verifiableCredential:n,verifications:a});return{...u,...o.length?{verifications:o}:{}}}),"buildEducationAndLearnings"),j=C(r=>r.map(t=>{let{narrative:e,descriptions:s,start:n,end:a,effectiveTimePeriod:d,verifiableCredential:f,verifications:c,...g}=t,i={...g};e&&(i.narrative=e),s?.length&&(i.descriptions=s),(d||n||a)&&(i.effectiveTimePeriod={...d??{},...n?{validFrom:n}:{},...a?{validTo:a}:{}});let l=V({verifiableCredential:f,verifications:c});return{...i,...l.length?{verifications:l}:{}}}),"buildCertifications"),b=C(r=>({name:"LER-RS",displayName:"LER-RS",description:"Create, package, and verify Learning & Employment Record Resume (LER-RS) credentials",methods:{createLerRecord:C(async(t,e)=>{let n=(e.learnCard??t).id.did(),a=new Date().toISOString(),d=crypto.randomUUID(),f={name:{given:e.person.givenName,family:e.person.familyName,formattedName:e.person.formattedName??`${e.person.givenName} ${e.person.familyName}`}},c=!!e.person.address?.formattedAddress||!!e.person.address?.line||!!e.person.address?.city||!!e.person.address?.postalCode||!!e.person.address?.countryCode,g=(e.person.web||[]).filter(o=>o?.url),i=(e.person.social||[]).filter(o=>o?.uri),l=e.person.email||e.person.phone||c||g.length>0||i.length>0?{...e.person.email?{email:[{address:e.person.email}]}:{},...e.person.phone?{phone:[{formattedNumber:e.person.phone}]}:{},...g.length?{web:g.map(o=>({url:o.url,name:o.name}))}:{},...i.length?{social:i.map(o=>({uri:o.uri,...o.name?{name:o.name}:{}}))}:{},...c?{address:[{...e.person.address?.formattedAddress?{formattedAddress:e.person.address.formattedAddress}:{},...e.person.address?.line?{line:e.person.address.line}:{},...e.person.address?.city?{city:e.person.address.city}:{},...e.person.address?.postalCode?{postalCode:e.person.address.postalCode}:{},...e.person.address?.countryCode?{countryCode:e.person.address.countryCode}:{}}]}:{}}:void 0,p={type:R,documentId:{value:d},person:f,...l?{communication:l}:{},skills:(e.skills||[]).map(o=>({name:o})),narratives:e.narratives,employmentHistories:e.workHistory?U(e.workHistory):void 0,educationAndLearnings:e.educationHistory?M(e.educationHistory):void 0,certifications:e.certifications?j(e.certifications):void 0,attachments:e.attachments},u={"@context":[m,H],id:`urn:uuid:${d}`,type:["VerifiableCredential",R],issuer:n,validFrom:a,credentialSubject:{id:e.person.id,...p}};return r.invoke.issueCredential(u,{proofPurpose:"assertionMethod"})},"createLerRecord"),createLerPresentation:C(async(t,e)=>{let n=(e.learnCard??t).id.did();if(!e.credentials.length)throw new Error("createLerPresentation: credentials array must contain at least one credential");if(!e.credentials.some(L))throw new Error("createLerPresentation: credentials must include at least one LER-RS credential");let d={"@context":[m],type:["VerifiablePresentation"],holder:n,verifiableCredential:e.credentials.length===1?e.credentials[0]:e.credentials};return r.invoke.issuePresentation(d,{...e.domain?{domain:e.domain}:{},...e.challenge?{challenge:e.challenge}:{}})},"createLerPresentation"),verifyLerPresentation:C(async(t,{presentation:e,domain:s,challenge:n})=>{let a=await r.invoke.verifyPresentation(e,{...s?{domain:s}:{},...n?{challenge:n}:{}}),d={verified:a.errors.length===0,errors:a.errors.length?a.errors:void 0},f=[];if(typeof e!="string"){let c=e.holder,g=D(e.verifiableCredential);for(let i of g)try{let l=await r.invoke.verifyCredential(i),p=typeof i.issuer=="string"?i.issuer:i.issuer?.id,u=L(i)||!!c&&!!p&&p===c;f.push({credential:i,verified:l.errors.length===0,isSelfIssued:u,errors:l.errors.length?l.errors:void 0})}catch(l){f.push({credential:i,verified:!1,isSelfIssued:!1,errors:[l instanceof Error?l.message:"Unknown error verifying credential"]})}}return{verified:d.verified&&f.every(c=>c.verified||c.isSelfIssued),presentationResult:d,credentialResults:f}},"verifyLerPresentation"),createTcpWrapperVc:C(async(t,e)=>{let n=(e.learnCard??t).id.did(),a=e.issuanceDate??new Date().toISOString(),d=e.generatedAt??a,f=e.subjectDid??n;if(e.enableCoSign)throw new Error("createTcpWrapperVc: co-signing is not enabled in MVP");if(e.coSignerDid)throw new Error("createTcpWrapperVc: coSignerDid is reserved for future co-sign support");let g={"@context":[m,{"@version":1.1,id:"@id",type:"@type",TrustedCareerProfile:"https://ctx.learncard.com/tcp#TrustedCareerProfile",ResumePackage:"https://ctx.learncard.com/tcp#ResumePackage",pdfUrl:{"@id":"https://ctx.learncard.com/tcp#pdfUrl","@type":"@id"},pdfHash:"https://ctx.learncard.com/tcp#pdfHash",hashAlgorithm:"https://ctx.learncard.com/tcp#hashAlgorithm",includedCredentials:{"@id":"https://ctx.learncard.com/tcp#includedCredentials","@container":"@set"},category:"https://ctx.learncard.com/tcp#category",generatedAt:{"@id":"https://ctx.learncard.com/tcp#generatedAt","@type":"http://www.w3.org/2001/XMLSchema#dateTime"}}],type:["VerifiableCredential",v],id:e.wrapperId,issuer:n,validFrom:a,credentialSubject:{id:f,type:"ResumePackage",pdfUrl:e.pdfUrl,pdfHash:e.pdfHash,hashAlgorithm:"SHA-256",includedCredentials:e.includedCredentials,generatedAt:d}};return r.invoke.issueCredential(g,{proofPurpose:"assertionMethod"})},"createTcpWrapperVc")}}),"getLerRsPlugin");
|
|
2
2
|
//# sourceMappingURL=ler-rs-plugin.cjs.production.min.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/types.ts", "../src/ler-rs.ts"],
|
|
4
|
-
"sourcesContent": ["export { getLerRsPlugin } from './ler-rs';\nexport * from './types';\n", "import { Plugin, LearnCard } from '@learncard/core';\nimport {\n VC as VerifiableCredential,\n VP as VerifiablePresentation,\n UnsignedVC,\n UnsignedVP,\n VerificationCheck,\n} from '@learncard/types';\nimport type { VCPluginMethods, VCPluginDependentMethods } from '@learncard/vc-plugin';\n\n/**\n * Legacy W3C VC v1 context kept for interop with previously issued records.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V1 = 'https://www.w3.org/2018/credentials/v1';\n/**\n * Base W3C VC v2 context used by newly issued LER-RS credentials and presentations.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V2 = 'https://www.w3.org/ns/credentials/v2';\n/**\n * HR Open Standards VC wrapper context for LER-RS v4.5.\n */\nexport const LER_RS_VC_CONTEXT_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/VerifiableCredentialLER-RSType.json';\n/**\n * Canonical LER-RS type URI for v4.5.\n */\nexport const LER_RS_TYPE_URI_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/LER-RSType.json';\n/**\n * Legacy LER-RS type URI for v4.4 interop.\n */\nexport const LEGACY_LER_RS_TYPE_URI_V44 =\n 'http://schema.hropenstandards.org/4.4/recruiting/json/ler-rs/LER-RSType.json';\n/**\n * Legacy short type token used by older issuers.\n */\nexport const LEGACY_LER_RS_TYPE_TOKEN = 'LERRS';\n/**\n * Hosted TCP JSON-LD context URL.\n *\n * Note: current local wrapper issuance can inline context during local testing.\n */\nexport const TCP_CONTEXT_V1 = 'https://ctx.learncard.com/tcp/1.0.0.json';\n/**\n * LearnCard-defined wrapper VC type for TCP resume package artifacts.\n *\n * This is intentionally NOT a canonical HR Open Standards LER-RS type;\n * it is a custom wrapper used to bind PDF URL/hash + included credential refs.\n */\nexport const TCP_WRAPPER_TYPE = 'TrustedCareerProfile';\n\n/**\n * Identity details used to populate `credentialSubject.person`.\n */\nexport interface PersonProfile {\n /** Subject DID for the issued LER-RS record. */\n id: string;\n /** Given/first name. */\n givenName: string;\n /** Family/last name. */\n familyName: string;\n /** Optional display name override. */\n formattedName?: string;\n /** Optional contact email to include in communication block. */\n email?: string;\n /** Optional contact phone to include in communication block. */\n phone?: string;\n /** Optional physical/mailing address to include in communication block. */\n address?: {\n formattedAddress?: string;\n line?: string;\n city?: string;\n postalCode?: string;\n countryCode?: string;\n };\n /** Optional website URLs to include in communication block. */\n web?: Array<{ url: string; name?: string }>;\n /** Optional social profile URLs to include in communication block. */\n social?: Array<{ uri: string; name?: string }>;\n}\n\n/**\n * Skill item structure used inside generated LER-RS records.\n */\nexport interface LerSkill {\n name: string;\n comments?: string[];\n description?: string;\n yearsOfExperience?: number;\n endorsers?: Array<{\n person?: { name?: { formattedName?: string } };\n organization?: { name?: string };\n }>;\n}\n\n/**\n * Source work history entry. Can be self-asserted fields and/or third-party verification VCs.\n */\nexport interface WorkHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n // Common self-asserted fields\n position?: string;\n employer?: string;\n start?: string;\n end?: string;\n current?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * Source education entry. Can include freeform fields and optional verification VCs.\n */\nexport interface EducationHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n institution?: string;\n start?: string;\n end?: string;\n current?: boolean;\n degree?: string;\n specializations?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Source certification entry for `credentialSubject.certifications`.\n */\nexport interface CertificationItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n name?: string;\n issuingAuthority?: string | Record<string, unknown>;\n status?: string;\n start?: string;\n end?: string;\n effectiveTimePeriod?: { validFrom?: string; validTo?: string };\n [key: string]: unknown;\n}\n\n/**\n * Narrative section block supported by LER-RS schema.\n */\nexport interface LerNarrative {\n name: string;\n texts: Array<{\n name: string;\n lines: string[];\n }>;\n}\n\n/**\n * Typed shape of the LER-RS object embedded into `credentialSubject`.\n */\nexport interface LerRsRecord {\n type: string;\n documentId?: { value: string };\n person: {\n name: {\n given: string;\n family: string;\n formattedName?: string;\n };\n };\n communication?: {\n email?: { address: string }[];\n web?: { url: string; name?: string }[];\n phone?: Array<Record<string, unknown>>;\n address?: Array<Record<string, unknown>>;\n social?: Array<Record<string, unknown>>;\n };\n skills?: LerSkill[];\n narratives?: LerNarrative[];\n educationAndLearnings?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n employmentHistories?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n licenses?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n certifications?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n employmentPreferences?: Array<Record<string, unknown>>;\n positionPreferences?: Array<Record<string, unknown>>;\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a signed LER-RS VC from normalized source data.\n */\nexport interface CreateLerRecordParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n person: PersonProfile;\n workHistory?: WorkHistoryItem[];\n educationHistory?: EducationHistoryItem[];\n certifications?: CertificationItem[];\n skills?: string[];\n narratives?: LerNarrative[];\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a VP that packages one or more credentials including at least one LER-RS credential.\n */\nexport interface CreateLerPresentationParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n credentials: VerifiableCredential[];\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Parameters for verifying a LER-focused VP and nested credentials.\n */\nexport interface VerifyLerPresentationParams {\n presentation: VerifiablePresentation | string;\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Credential reference stored in TCP wrapper VC.\n */\nexport interface TcpIncludedCredentialRef {\n /** Resolved VC id when available; falls back to URI if id is unavailable. */\n id: string;\n /** Category label used for UI grouping and downstream filtering. */\n category: string;\n}\n\n/**\n * Parameters for issuing TrustedCareerProfile wrapper VCs.\n */\nexport interface CreateTcpWrapperVcParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n wrapperId: string;\n subjectDid?: string;\n pdfUrl: string;\n pdfHash: string;\n includedCredentials: TcpIncludedCredentialRef[];\n generatedAt?: string;\n /** Timestamp used as the issued credential's `validFrom` value. */\n issuanceDate?: string;\n coSignerDid?: string;\n enableCoSign?: boolean;\n}\n\n/**\n * Structured verification output for LER presentation verification.\n */\nexport interface VerificationResult {\n verified: boolean; // Overall status\n presentationResult: {\n verified: boolean;\n errors?: string[];\n };\n credentialResults: {\n credential: VerifiableCredential;\n verified: boolean;\n isSelfIssued: boolean;\n errors?: string[];\n }[];\n}\n\n/**\n * LearnCard dependency contract required by this plugin.\n */\nexport type LERRSDependentLearnCard = LearnCard<\n any,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n\n/**\n * Public invoke methods exposed by the LER-RS plugin.\n */\nexport type LERRSPluginMethods = {\n createLerRecord: (params: CreateLerRecordParams) => Promise<VerifiableCredential>;\n createLerPresentation: (params: CreateLerPresentationParams) => Promise<VerifiablePresentation>;\n verifyLerPresentation: (params: VerifyLerPresentationParams) => Promise<VerificationResult>;\n createTcpWrapperVc: (params: CreateTcpWrapperVcParams) => Promise<VerifiableCredential>;\n};\n\n/**\n * Plugin type definition for registration in LearnCard.\n */\nexport type LERRSPlugin = Plugin<\n 'LER-RS',\n never,\n LERRSPluginMethods,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n", "import {\n VC as VerifiableCredential,\n UnsignedVC,\n VP as VerifiablePresentation,\n UnsignedVP,\n} from '@learncard/types';\nimport {\n LERRSDependentLearnCard,\n LERRSPlugin,\n CreateLerRecordParams,\n CreateLerPresentationParams,\n VerifyLerPresentationParams,\n VerificationResult,\n LerRsRecord,\n LER_RS_CREDENTIAL_CONTEXT_V2,\n LER_RS_TYPE_URI_V45,\n LEGACY_LER_RS_TYPE_URI_V44,\n LEGACY_LER_RS_TYPE_TOKEN,\n TCP_WRAPPER_TYPE,\n} from './types';\n\n/**\n * Normalizes verification containers from either:\n * - `verifications: VC[]`\n * - `verifiableCredential: VC`\n */\nconst getItemVerifications = (item: {\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n}): VerifiableCredential[] => {\n if (item.verifications?.length) return item.verifications;\n if (item.verifiableCredential) return [item.verifiableCredential];\n return [];\n};\n\n/**\n * Converts scalar-or-array values into a normalized array.\n */\nconst toArray = <T>(maybe: T | T[] | undefined): T[] =>\n maybe == null ? [] : Array.isArray(maybe) ? maybe : [maybe];\n\n/**\n * Inline LER-RS JSON-LD context used for signing stability.\n *\n * The published HR Open URL is schema-oriented and can trigger additional remote\n * context resolution during expansion. Inlining this base context avoids network\n * dependency at issue time while preserving deterministic term expansion.\n */\nconst inlineLerRsContext = {\n '@version': 1.1,\n hrrec: 'http://schema.hropenstandards.org/recruiting/',\n '@vocab': 'http://schema.hropenstandards.org/recruiting/',\n};\n\n/**\n * Determines whether a VC represents a LER-RS credential (legacy and current forms).\n *\n * Checks:\n * - VC `type` array/token values\n * - `credentialSubject.type`\n * - nested `credentialSubject.lerrsType.type`\n */\nconst credentialHasLerRsType = (credential: VerifiableCredential): boolean => {\n const typeList = Array.isArray(credential.type) ? credential.type : [credential.type];\n if (\n typeList.some(type =>\n [LEGACY_LER_RS_TYPE_TOKEN, LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(\n type\n )\n )\n )\n return true;\n\n const credentialSubject = credential.credentialSubject as Record<string, unknown> | undefined;\n if (!credentialSubject) return false;\n\n const inlineType = credentialSubject.type;\n if (\n typeof inlineType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(inlineType)\n )\n return true;\n\n const nestedType = (credentialSubject.lerrsType as Record<string, unknown> | undefined)?.type;\n return (\n typeof nestedType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(nestedType)\n );\n};\n\n/**\n * Maps application work history items to LER-RS `employmentHistories` shape.\n */\nconst buildEmploymentHistories = (\n items: NonNullable<CreateLerRecordParams['workHistory']>\n): LerRsRecord['employmentHistories'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n position,\n employer,\n start,\n end,\n current,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (typeof current === 'boolean') container.current = current;\n\n if (employer) container.organization = { tradeName: employer };\n if (position || start || end || typeof current === 'boolean') {\n const ph: Record<string, unknown> = {};\n if (position) ph.title = position;\n if (start) ph.start = start;\n if (end) ph.end = end;\n if (typeof current === 'boolean') ph.current = current;\n if (descriptions?.length) ph.descriptions = descriptions;\n container.positionHistories = [ph];\n }\n if (narrative) container.narrative = narrative;\n if (descriptions?.length && !container.positionHistories) container.descriptions = descriptions;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps education source items into LER-RS `educationAndLearnings`.\n */\nconst buildEducationAndLearnings = (\n items: NonNullable<CreateLerRecordParams['educationHistory']>\n): LerRsRecord['educationAndLearnings'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n institution,\n start,\n end,\n current,\n degree,\n specializations,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (institution) container.institution = { name: institution };\n if (start) container.start = start;\n if (end) container.end = end;\n if (typeof current === 'boolean') container.current = current;\n if (descriptions?.length) container.descriptions = descriptions;\n if (degree || specializations) {\n container.educationDegrees = [\n {\n ...(degree ? { name: degree } : {}),\n ...(specializations\n ? {\n specializations: specializations.map(specialization => ({\n name: specialization,\n })),\n }\n : {}),\n },\n ];\n }\n if (narrative) container.narrative = narrative;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps certification source items to LER-RS `certifications`.\n */\nconst buildCertifications = (\n items: NonNullable<CreateLerRecordParams['certifications']>\n): LerRsRecord['certifications'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n start,\n end,\n effectiveTimePeriod,\n verifiableCredential,\n verifications,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (narrative) container.narrative = narrative;\n if (descriptions?.length) container.descriptions = descriptions;\n if (effectiveTimePeriod || start || end) {\n container.effectiveTimePeriod = {\n ...(effectiveTimePeriod ?? {}),\n ...(start ? { validFrom: start } : {}),\n ...(end ? { validTo: end } : {}),\n };\n }\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Returns the LearnCard LER-RS plugin with methods for:\n * - issuing LER-RS VCs\n * - packaging/verifying LER presentations\n * - issuing TCP wrapper VCs for resume packages\n */\nexport const getLerRsPlugin = (initLearnCard: LERRSDependentLearnCard): LERRSPlugin => {\n return {\n name: 'LER-RS',\n displayName: 'LER-RS',\n description:\n 'Create, package, and verify Learning & Employment Record Resume (LER-RS) credentials',\n methods: {\n /**\n * Issues a signed LER-RS VC from normalized person/work/education/certification data.\n *\n * The method:\n * 1. Builds a compliant LER-RS `credentialSubject`\n * 2. Applies VC + LER-RS contexts\n * 3. Signs via `invoke.issueCredential`\n */\n createLerRecord: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = new Date().toISOString();\n const documentId = crypto.randomUUID();\n\n const personSection: LerRsRecord['person'] = {\n name: {\n given: params.person.givenName,\n family: params.person.familyName,\n formattedName:\n params.person.formattedName ??\n `${params.person.givenName} ${params.person.familyName}`,\n },\n };\n\n const hasAddress =\n !!params.person.address?.formattedAddress ||\n !!params.person.address?.line ||\n !!params.person.address?.city ||\n !!params.person.address?.postalCode ||\n !!params.person.address?.countryCode;\n const webEntries = (params.person.web || []).filter(entry => entry?.url);\n const socialEntries = (params.person.social || []).filter(entry => entry?.uri);\n\n const communication: LerRsRecord['communication'] | undefined =\n params.person.email ||\n params.person.phone ||\n hasAddress ||\n webEntries.length > 0 ||\n socialEntries.length > 0\n ? {\n ...(params.person.email\n ? { email: [{ address: params.person.email }] }\n : {}),\n ...(params.person.phone\n ? { phone: [{ formattedNumber: params.person.phone }] }\n : {}),\n ...(webEntries.length\n ? { web: webEntries.map(entry => ({ url: entry.url, name: entry.name })) }\n : {}),\n ...(socialEntries.length\n ? {\n social: socialEntries.map(entry => ({\n uri: entry.uri,\n ...(entry.name ? { name: entry.name } : {}),\n })),\n }\n : {}),\n ...(hasAddress\n ? {\n address: [\n {\n ...(params.person.address?.formattedAddress\n ? {\n formattedAddress:\n params.person.address.formattedAddress,\n }\n : {}),\n ...(params.person.address?.line\n ? { line: params.person.address.line }\n : {}),\n ...(params.person.address?.city\n ? { city: params.person.address.city }\n : {}),\n ...(params.person.address?.postalCode\n ? { postalCode: params.person.address.postalCode }\n : {}),\n ...(params.person.address?.countryCode\n ? {\n countryCode:\n params.person.address.countryCode,\n }\n : {}),\n },\n ],\n }\n : {}),\n }\n : undefined;\n\n const lerRecord: LerRsRecord = {\n type: LER_RS_TYPE_URI_V45,\n documentId: { value: documentId },\n person: personSection,\n ...(communication ? { communication } : {}),\n skills: (params.skills || []).map(s => ({ name: s })),\n narratives: params.narratives,\n employmentHistories: params.workHistory\n ? buildEmploymentHistories(params.workHistory)\n : undefined,\n educationAndLearnings: params.educationHistory\n ? buildEducationAndLearnings(params.educationHistory)\n : undefined,\n certifications: params.certifications\n ? buildCertifications(params.certifications)\n : undefined,\n attachments: params.attachments,\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineLerRsContext],\n id: `urn:uuid:${documentId}`,\n type: ['VerifiableCredential', LER_RS_TYPE_URI_V45],\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: params.person.id,\n ...lerRecord,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n\n /**\n * Issues a VP containing at least one LER-RS credential.\n *\n * Throws if:\n * - credentials list is empty\n * - none of the credentials match LER-RS type checks\n */\n createLerPresentation: async (_learnCard, params): Promise<VerifiablePresentation> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n\n if (!params.credentials.length)\n throw new Error(\n 'createLerPresentation: credentials array must contain at least one credential'\n );\n const containsLer = params.credentials.some(credentialHasLerRsType);\n if (!containsLer)\n throw new Error(\n 'createLerPresentation: credentials must include at least one LER-RS credential'\n );\n\n const vp: UnsignedVP = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2],\n type: ['VerifiablePresentation'],\n holder: did,\n verifiableCredential:\n params.credentials.length === 1\n ? params.credentials[0]\n : params.credentials,\n };\n\n return initLearnCard.invoke.issuePresentation(vp, {\n ...(params.domain ? { domain: params.domain } : {}),\n ...(params.challenge ? { challenge: params.challenge } : {}),\n });\n },\n\n /**\n * Verifies a LER-focused VP and returns structured result details.\n *\n * Overall `verified` allows explicitly self-issued items when determining\n * final status, while still surfacing per-credential verification results.\n */\n verifyLerPresentation: async (\n _learnCard,\n { presentation, domain, challenge }: VerifyLerPresentationParams\n ): Promise<VerificationResult> => {\n const presCheck = await initLearnCard.invoke.verifyPresentation(presentation, {\n ...(domain ? { domain } : {}),\n ...(challenge ? { challenge } : {}),\n });\n\n const presentationResult = {\n verified: presCheck.errors.length === 0,\n errors: presCheck.errors.length ? presCheck.errors : undefined,\n };\n\n const credentialResults: VerificationResult['credentialResults'] = [];\n\n if (typeof presentation !== 'string') {\n const holder = presentation.holder;\n const vcs = toArray<VerifiableCredential>(\n presentation.verifiableCredential as any\n );\n\n for (const credential of vcs) {\n try {\n const credCheck = await initLearnCard.invoke.verifyCredential(\n credential\n );\n const issuerDid =\n typeof credential.issuer === 'string'\n ? credential.issuer\n : credential.issuer?.id;\n const isSelfIssued =\n credentialHasLerRsType(credential) ||\n (!!holder && !!issuerDid && issuerDid === holder);\n\n credentialResults.push({\n credential,\n verified: credCheck.errors.length === 0,\n isSelfIssued,\n errors: credCheck.errors.length ? credCheck.errors : undefined,\n });\n } catch (err) {\n credentialResults.push({\n credential,\n verified: false,\n isSelfIssued: false,\n errors: [\n err instanceof Error\n ? err.message\n : 'Unknown error verifying credential',\n ],\n });\n }\n }\n }\n\n return {\n verified:\n presentationResult.verified &&\n credentialResults.every(r => r.verified || r.isSelfIssued),\n presentationResult,\n credentialResults,\n };\n },\n\n /**\n * Issues a signed TrustedCareerProfile wrapper VC for resume package publishing.\n *\n * Includes:\n * - public PDF URL\n * - PDF SHA-256 hash\n * - included credential references\n * - generation timestamp\n *\n * Co-sign fields are intentionally stubbed for MVP and currently rejected.\n */\n createTcpWrapperVc: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = params.issuanceDate ?? new Date().toISOString();\n const generatedAt = params.generatedAt ?? issuedAt;\n const subjectDid = params.subjectDid ?? did;\n\n if (params.enableCoSign) {\n throw new Error('createTcpWrapperVc: co-signing is not enabled in MVP');\n }\n\n if (params.coSignerDid) {\n throw new Error(\n 'createTcpWrapperVc: coSignerDid is reserved for future co-sign support'\n );\n }\n\n // NOTE: We inline the TCP context for local testing while the hosted\n // context URL is not yet available in all environments.\n const inlineTcpContext = {\n '@version': 1.1,\n id: '@id',\n type: '@type',\n TrustedCareerProfile: 'https://ctx.learncard.com/tcp#TrustedCareerProfile',\n ResumePackage: 'https://ctx.learncard.com/tcp#ResumePackage',\n pdfUrl: {\n '@id': 'https://ctx.learncard.com/tcp#pdfUrl',\n '@type': '@id',\n },\n pdfHash: 'https://ctx.learncard.com/tcp#pdfHash',\n hashAlgorithm: 'https://ctx.learncard.com/tcp#hashAlgorithm',\n includedCredentials: {\n '@id': 'https://ctx.learncard.com/tcp#includedCredentials',\n '@container': '@set',\n },\n category: 'https://ctx.learncard.com/tcp#category',\n generatedAt: {\n '@id': 'https://ctx.learncard.com/tcp#generatedAt',\n '@type': 'http://www.w3.org/2001/XMLSchema#dateTime',\n },\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineTcpContext],\n type: ['VerifiableCredential', TCP_WRAPPER_TYPE],\n id: params.wrapperId,\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: subjectDid,\n type: 'ResumePackage',\n pdfUrl: params.pdfUrl,\n pdfHash: params.pdfHash,\n hashAlgorithm: 'SHA-256',\n includedCredentials: params.includedCredentials,\n generatedAt,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n },\n };\n};\n"],
|
|
5
|
-
"mappings": "4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,+BAAAC,EAAA,iCAAAC,EAAA,iCAAAC,EAAA,wBAAAC,EAAA,0BAAAC,EAAA,mBAAAC,EAAA,qBAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAX,GCaO,IAAMY,EAA+B,yCAI/BC,EAA+B,uCAI/BC,EACT,4FAISC,EACT,wEAISC,EACT,+EAISC,EAA2B,QAM3BC,EAAiB,2CAOjBC,EAAmB,uBCvBhC,IAAMC,EAAuBC,EAACC,GAItBA,EAAK,eAAe,OAAeA,EAAK,cACxCA,EAAK,qBAA6B,CAACA,EAAK,oBAAoB,EACzD,CAAC,EANiB,wBAYvBC,EAAUF,EAAIG,GAChBA,GAAS,KAAO,CAAC,EAAI,MAAM,QAAQA,CAAK,EAAIA,EAAQ,CAACA,CAAK,EAD9C,WAUVC,EAAqB,CACvB,WAAY,IACZ,MAAO,gDACP,SAAU
|
|
4
|
+
"sourcesContent": ["export { getLerRsPlugin } from './ler-rs';\nexport * from './types';\n", "import { Plugin, LearnCard } from '@learncard/core';\nimport {\n VC as VerifiableCredential,\n VP as VerifiablePresentation,\n UnsignedVC,\n UnsignedVP,\n VerificationCheck,\n} from '@learncard/types';\nimport type { VCPluginMethods, VCPluginDependentMethods } from '@learncard/vc-plugin';\n\n/**\n * Legacy W3C VC v1 context kept for interop with previously issued records.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V1 = 'https://www.w3.org/2018/credentials/v1';\n/**\n * Base W3C VC v2 context used by newly issued LER-RS credentials and presentations.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V2 = 'https://www.w3.org/ns/credentials/v2';\n/**\n * HR Open Standards VC wrapper context for LER-RS v4.5.\n */\nexport const LER_RS_VC_CONTEXT_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/VerifiableCredentialLER-RSType.json';\n/**\n * Canonical LER-RS type URI for v4.5.\n */\nexport const LER_RS_TYPE_URI_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/LER-RSType.json';\n/**\n * Legacy LER-RS type URI for v4.4 interop.\n */\nexport const LEGACY_LER_RS_TYPE_URI_V44 =\n 'http://schema.hropenstandards.org/4.4/recruiting/json/ler-rs/LER-RSType.json';\n/**\n * Legacy short type token used by older issuers.\n */\nexport const LEGACY_LER_RS_TYPE_TOKEN = 'LERRS';\n/**\n * Hosted TCP JSON-LD context URL.\n *\n * Note: current local wrapper issuance can inline context during local testing.\n */\nexport const TCP_CONTEXT_V1 = 'https://ctx.learncard.com/tcp/1.0.0.json';\n/**\n * LearnCard-defined wrapper VC type for TCP resume package artifacts.\n *\n * This is intentionally NOT a canonical HR Open Standards LER-RS type;\n * it is a custom wrapper used to bind PDF URL/hash + included credential refs.\n */\nexport const TCP_WRAPPER_TYPE = 'TrustedCareerProfile';\n\n/**\n * Identity details used to populate `credentialSubject.person`.\n */\nexport interface PersonProfile {\n /** Subject DID for the issued LER-RS record. */\n id: string;\n /** Given/first name. */\n givenName: string;\n /** Family/last name. */\n familyName: string;\n /** Optional display name override. */\n formattedName?: string;\n /** Optional contact email to include in communication block. */\n email?: string;\n /** Optional contact phone to include in communication block. */\n phone?: string;\n /** Optional physical/mailing address to include in communication block. */\n address?: {\n formattedAddress?: string;\n line?: string;\n city?: string;\n postalCode?: string;\n countryCode?: string;\n };\n /** Optional website URLs to include in communication block. */\n web?: Array<{ url: string; name?: string }>;\n /** Optional social profile URLs to include in communication block. */\n social?: Array<{ uri: string; name?: string }>;\n}\n\n/**\n * Skill item structure used inside generated LER-RS records.\n */\nexport interface LerSkill {\n name: string;\n comments?: string[];\n description?: string;\n yearsOfExperience?: number;\n endorsers?: Array<{\n person?: { name?: { formattedName?: string } };\n organization?: { name?: string };\n }>;\n}\n\n/**\n * Source work history entry. Can be self-asserted fields and/or third-party verification VCs.\n */\nexport interface WorkHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n // Common self-asserted fields\n position?: string;\n employer?: string;\n start?: string;\n end?: string;\n current?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * Source education entry. Can include freeform fields and optional verification VCs.\n */\nexport interface EducationHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n institution?: string;\n start?: string;\n end?: string;\n current?: boolean;\n degree?: string;\n specializations?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Source certification entry for `credentialSubject.certifications`.\n */\nexport interface CertificationItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n name?: string;\n issuingAuthority?: string | Record<string, unknown>;\n status?: string;\n start?: string;\n end?: string;\n effectiveTimePeriod?: { validFrom?: string; validTo?: string };\n [key: string]: unknown;\n}\n\n/**\n * Narrative section block supported by LER-RS schema.\n */\nexport interface LerNarrative {\n name: string;\n texts: Array<{\n name: string;\n lines: string[];\n }>;\n}\n\n/**\n * Typed shape of the LER-RS object embedded into `credentialSubject`.\n */\nexport interface LerRsRecord {\n type: string;\n documentId?: { value: string };\n person: {\n name: {\n given: string;\n family: string;\n formattedName?: string;\n };\n };\n communication?: {\n email?: { address: string }[];\n web?: { url: string; name?: string }[];\n phone?: Array<Record<string, unknown>>;\n address?: Array<Record<string, unknown>>;\n social?: Array<Record<string, unknown>>;\n };\n skills?: LerSkill[];\n narratives?: LerNarrative[];\n educationAndLearnings?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n employmentHistories?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n licenses?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n certifications?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n employmentPreferences?: Array<Record<string, unknown>>;\n positionPreferences?: Array<Record<string, unknown>>;\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a signed LER-RS VC from normalized source data.\n */\nexport interface CreateLerRecordParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n person: PersonProfile;\n workHistory?: WorkHistoryItem[];\n educationHistory?: EducationHistoryItem[];\n certifications?: CertificationItem[];\n skills?: string[];\n narratives?: LerNarrative[];\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a VP that packages one or more credentials including at least one LER-RS credential.\n */\nexport interface CreateLerPresentationParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n credentials: VerifiableCredential[];\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Parameters for verifying a LER-focused VP and nested credentials.\n */\nexport interface VerifyLerPresentationParams {\n presentation: VerifiablePresentation | string;\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Credential reference stored in TCP wrapper VC.\n */\nexport interface TcpIncludedCredentialRef {\n /** Resolved VC id when available; falls back to URI if id is unavailable. */\n id: string;\n /** Category label used for UI grouping and downstream filtering. */\n category: string;\n}\n\n/**\n * Parameters for issuing TrustedCareerProfile wrapper VCs.\n */\nexport interface CreateTcpWrapperVcParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n wrapperId: string;\n subjectDid?: string;\n pdfUrl: string;\n pdfHash: string;\n includedCredentials: TcpIncludedCredentialRef[];\n generatedAt?: string;\n /** Timestamp used as the issued credential's `validFrom` value. */\n issuanceDate?: string;\n coSignerDid?: string;\n enableCoSign?: boolean;\n}\n\n/**\n * Structured verification output for LER presentation verification.\n */\nexport interface VerificationResult {\n verified: boolean; // Overall status\n presentationResult: {\n verified: boolean;\n errors?: string[];\n };\n credentialResults: {\n credential: VerifiableCredential;\n verified: boolean;\n isSelfIssued: boolean;\n errors?: string[];\n }[];\n}\n\n/**\n * LearnCard dependency contract required by this plugin.\n */\nexport type LERRSDependentLearnCard = LearnCard<\n any,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n\n/**\n * Public invoke methods exposed by the LER-RS plugin.\n */\nexport type LERRSPluginMethods = {\n createLerRecord: (params: CreateLerRecordParams) => Promise<VerifiableCredential>;\n createLerPresentation: (params: CreateLerPresentationParams) => Promise<VerifiablePresentation>;\n verifyLerPresentation: (params: VerifyLerPresentationParams) => Promise<VerificationResult>;\n createTcpWrapperVc: (params: CreateTcpWrapperVcParams) => Promise<VerifiableCredential>;\n};\n\n/**\n * Plugin type definition for registration in LearnCard.\n */\nexport type LERRSPlugin = Plugin<\n 'LER-RS',\n never,\n LERRSPluginMethods,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n", "import {\n VC as VerifiableCredential,\n UnsignedVC,\n VP as VerifiablePresentation,\n UnsignedVP,\n} from '@learncard/types';\nimport {\n LERRSDependentLearnCard,\n LERRSPlugin,\n CreateLerRecordParams,\n CreateLerPresentationParams,\n VerifyLerPresentationParams,\n VerificationResult,\n LerRsRecord,\n LER_RS_CREDENTIAL_CONTEXT_V2,\n LER_RS_TYPE_URI_V45,\n LEGACY_LER_RS_TYPE_URI_V44,\n LEGACY_LER_RS_TYPE_TOKEN,\n TCP_WRAPPER_TYPE,\n} from './types';\n\n/**\n * Normalizes verification containers from either:\n * - `verifications: VC[]`\n * - `verifiableCredential: VC`\n */\nconst getItemVerifications = (item: {\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n}): VerifiableCredential[] => {\n if (item.verifications?.length) return item.verifications;\n if (item.verifiableCredential) return [item.verifiableCredential];\n return [];\n};\n\n/**\n * Converts scalar-or-array values into a normalized array.\n */\nconst toArray = <T>(maybe: T | T[] | undefined): T[] =>\n maybe == null ? [] : Array.isArray(maybe) ? maybe : [maybe];\n\n/**\n * Inline LER-RS JSON-LD context used for signing stability.\n *\n * The published HR Open URL is schema-oriented and can trigger additional remote\n * context resolution during expansion. Inlining this base context avoids network\n * dependency at issue time while preserving deterministic term expansion.\n */\nconst inlineLerRsContext = {\n '@version': 1.1,\n hrrec: 'http://schema.hropenstandards.org/recruiting/',\n '@vocab': 'http://schema.hropenstandards.org/recruiting/',\n // Bind complete source credentials as JSON without inheriting the wrapper's\n // protected VC v2 terms into older VC v1 contexts or altering issuer proofs.\n verifications: { '@id': 'hrrec:verifications', '@type': '@json' },\n};\n\n/**\n * Determines whether a VC represents a LER-RS credential (legacy and current forms).\n *\n * Checks:\n * - VC `type` array/token values\n * - `credentialSubject.type`\n * - nested `credentialSubject.lerrsType.type`\n */\nconst credentialHasLerRsType = (credential: VerifiableCredential): boolean => {\n const typeList = Array.isArray(credential.type) ? credential.type : [credential.type];\n if (\n typeList.some(type =>\n [LEGACY_LER_RS_TYPE_TOKEN, LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(\n type\n )\n )\n )\n return true;\n\n const credentialSubject = credential.credentialSubject as Record<string, unknown> | undefined;\n if (!credentialSubject) return false;\n\n const inlineType = credentialSubject.type;\n if (\n typeof inlineType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(inlineType)\n )\n return true;\n\n const nestedType = (credentialSubject.lerrsType as Record<string, unknown> | undefined)?.type;\n return (\n typeof nestedType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(nestedType)\n );\n};\n\n/**\n * Maps application work history items to LER-RS `employmentHistories` shape.\n */\nconst buildEmploymentHistories = (\n items: NonNullable<CreateLerRecordParams['workHistory']>\n): LerRsRecord['employmentHistories'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n position,\n employer,\n start,\n end,\n current,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (typeof current === 'boolean') container.current = current;\n\n if (employer) container.organization = { tradeName: employer };\n if (position || start || end || typeof current === 'boolean') {\n const ph: Record<string, unknown> = {};\n if (position) ph.title = position;\n if (start) ph.start = start;\n if (end) ph.end = end;\n if (typeof current === 'boolean') ph.current = current;\n if (descriptions?.length) ph.descriptions = descriptions;\n container.positionHistories = [ph];\n }\n if (narrative) container.narrative = narrative;\n if (descriptions?.length && !container.positionHistories)\n container.descriptions = descriptions;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps education source items into LER-RS `educationAndLearnings`.\n */\nconst buildEducationAndLearnings = (\n items: NonNullable<CreateLerRecordParams['educationHistory']>\n): LerRsRecord['educationAndLearnings'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n institution,\n start,\n end,\n current,\n degree,\n specializations,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (institution) container.institution = { name: institution };\n if (start) container.start = start;\n if (end) container.end = end;\n if (typeof current === 'boolean') container.current = current;\n if (descriptions?.length) container.descriptions = descriptions;\n if (degree || specializations) {\n container.educationDegrees = [\n {\n ...(degree ? { name: degree } : {}),\n ...(specializations\n ? {\n specializations: specializations.map(specialization => ({\n name: specialization,\n })),\n }\n : {}),\n },\n ];\n }\n if (narrative) container.narrative = narrative;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps certification source items to LER-RS `certifications`.\n */\nconst buildCertifications = (\n items: NonNullable<CreateLerRecordParams['certifications']>\n): LerRsRecord['certifications'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n start,\n end,\n effectiveTimePeriod,\n verifiableCredential,\n verifications,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (narrative) container.narrative = narrative;\n if (descriptions?.length) container.descriptions = descriptions;\n if (effectiveTimePeriod || start || end) {\n container.effectiveTimePeriod = {\n ...(effectiveTimePeriod ?? {}),\n ...(start ? { validFrom: start } : {}),\n ...(end ? { validTo: end } : {}),\n };\n }\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Returns the LearnCard LER-RS plugin with methods for:\n * - issuing LER-RS VCs\n * - packaging/verifying LER presentations\n * - issuing TCP wrapper VCs for resume packages\n */\nexport const getLerRsPlugin = (initLearnCard: LERRSDependentLearnCard): LERRSPlugin => {\n return {\n name: 'LER-RS',\n displayName: 'LER-RS',\n description:\n 'Create, package, and verify Learning & Employment Record Resume (LER-RS) credentials',\n methods: {\n /**\n * Issues a signed LER-RS VC from normalized person/work/education/certification data.\n *\n * The method:\n * 1. Builds a compliant LER-RS `credentialSubject`\n * 2. Applies VC + LER-RS contexts\n * 3. Signs via `invoke.issueCredential`\n */\n createLerRecord: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = new Date().toISOString();\n const documentId = crypto.randomUUID();\n\n const personSection: LerRsRecord['person'] = {\n name: {\n given: params.person.givenName,\n family: params.person.familyName,\n formattedName:\n params.person.formattedName ??\n `${params.person.givenName} ${params.person.familyName}`,\n },\n };\n\n const hasAddress =\n !!params.person.address?.formattedAddress ||\n !!params.person.address?.line ||\n !!params.person.address?.city ||\n !!params.person.address?.postalCode ||\n !!params.person.address?.countryCode;\n const webEntries = (params.person.web || []).filter(entry => entry?.url);\n const socialEntries = (params.person.social || []).filter(entry => entry?.uri);\n\n const communication: LerRsRecord['communication'] | undefined =\n params.person.email ||\n params.person.phone ||\n hasAddress ||\n webEntries.length > 0 ||\n socialEntries.length > 0\n ? {\n ...(params.person.email\n ? { email: [{ address: params.person.email }] }\n : {}),\n ...(params.person.phone\n ? { phone: [{ formattedNumber: params.person.phone }] }\n : {}),\n ...(webEntries.length\n ? {\n web: webEntries.map(entry => ({\n url: entry.url,\n name: entry.name,\n })),\n }\n : {}),\n ...(socialEntries.length\n ? {\n social: socialEntries.map(entry => ({\n uri: entry.uri,\n ...(entry.name ? { name: entry.name } : {}),\n })),\n }\n : {}),\n ...(hasAddress\n ? {\n address: [\n {\n ...(params.person.address?.formattedAddress\n ? {\n formattedAddress:\n params.person.address\n .formattedAddress,\n }\n : {}),\n ...(params.person.address?.line\n ? { line: params.person.address.line }\n : {}),\n ...(params.person.address?.city\n ? { city: params.person.address.city }\n : {}),\n ...(params.person.address?.postalCode\n ? {\n postalCode:\n params.person.address.postalCode,\n }\n : {}),\n ...(params.person.address?.countryCode\n ? {\n countryCode:\n params.person.address.countryCode,\n }\n : {}),\n },\n ],\n }\n : {}),\n }\n : undefined;\n\n const lerRecord: LerRsRecord = {\n type: LER_RS_TYPE_URI_V45,\n documentId: { value: documentId },\n person: personSection,\n ...(communication ? { communication } : {}),\n skills: (params.skills || []).map(s => ({ name: s })),\n narratives: params.narratives,\n employmentHistories: params.workHistory\n ? buildEmploymentHistories(params.workHistory)\n : undefined,\n educationAndLearnings: params.educationHistory\n ? buildEducationAndLearnings(params.educationHistory)\n : undefined,\n certifications: params.certifications\n ? buildCertifications(params.certifications)\n : undefined,\n attachments: params.attachments,\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineLerRsContext],\n id: `urn:uuid:${documentId}`,\n type: ['VerifiableCredential', LER_RS_TYPE_URI_V45],\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: params.person.id,\n ...lerRecord,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n\n /**\n * Issues a VP containing at least one LER-RS credential.\n *\n * Throws if:\n * - credentials list is empty\n * - none of the credentials match LER-RS type checks\n */\n createLerPresentation: async (_learnCard, params): Promise<VerifiablePresentation> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n\n if (!params.credentials.length)\n throw new Error(\n 'createLerPresentation: credentials array must contain at least one credential'\n );\n const containsLer = params.credentials.some(credentialHasLerRsType);\n if (!containsLer)\n throw new Error(\n 'createLerPresentation: credentials must include at least one LER-RS credential'\n );\n\n const vp: UnsignedVP = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2],\n type: ['VerifiablePresentation'],\n holder: did,\n verifiableCredential:\n params.credentials.length === 1\n ? params.credentials[0]\n : params.credentials,\n };\n\n return initLearnCard.invoke.issuePresentation(vp, {\n ...(params.domain ? { domain: params.domain } : {}),\n ...(params.challenge ? { challenge: params.challenge } : {}),\n });\n },\n\n /**\n * Verifies a LER-focused VP and returns structured result details.\n *\n * Overall `verified` allows explicitly self-issued items when determining\n * final status, while still surfacing per-credential verification results.\n */\n verifyLerPresentation: async (\n _learnCard,\n { presentation, domain, challenge }: VerifyLerPresentationParams\n ): Promise<VerificationResult> => {\n const presCheck = await initLearnCard.invoke.verifyPresentation(presentation, {\n ...(domain ? { domain } : {}),\n ...(challenge ? { challenge } : {}),\n });\n\n const presentationResult = {\n verified: presCheck.errors.length === 0,\n errors: presCheck.errors.length ? presCheck.errors : undefined,\n };\n\n const credentialResults: VerificationResult['credentialResults'] = [];\n\n if (typeof presentation !== 'string') {\n const holder = presentation.holder;\n const vcs = toArray<VerifiableCredential>(\n presentation.verifiableCredential as any\n );\n\n for (const credential of vcs) {\n try {\n const credCheck =\n await initLearnCard.invoke.verifyCredential(credential);\n const issuerDid =\n typeof credential.issuer === 'string'\n ? credential.issuer\n : credential.issuer?.id;\n const isSelfIssued =\n credentialHasLerRsType(credential) ||\n (!!holder && !!issuerDid && issuerDid === holder);\n\n credentialResults.push({\n credential,\n verified: credCheck.errors.length === 0,\n isSelfIssued,\n errors: credCheck.errors.length ? credCheck.errors : undefined,\n });\n } catch (err) {\n credentialResults.push({\n credential,\n verified: false,\n isSelfIssued: false,\n errors: [\n err instanceof Error\n ? err.message\n : 'Unknown error verifying credential',\n ],\n });\n }\n }\n }\n\n return {\n verified:\n presentationResult.verified &&\n credentialResults.every(r => r.verified || r.isSelfIssued),\n presentationResult,\n credentialResults,\n };\n },\n\n /**\n * Issues a signed TrustedCareerProfile wrapper VC for resume package publishing.\n *\n * Includes:\n * - public PDF URL\n * - PDF SHA-256 hash\n * - included credential references\n * - generation timestamp\n *\n * Co-sign fields are intentionally stubbed for MVP and currently rejected.\n */\n createTcpWrapperVc: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = params.issuanceDate ?? new Date().toISOString();\n const generatedAt = params.generatedAt ?? issuedAt;\n const subjectDid = params.subjectDid ?? did;\n\n if (params.enableCoSign) {\n throw new Error('createTcpWrapperVc: co-signing is not enabled in MVP');\n }\n\n if (params.coSignerDid) {\n throw new Error(\n 'createTcpWrapperVc: coSignerDid is reserved for future co-sign support'\n );\n }\n\n // NOTE: We inline the TCP context for local testing while the hosted\n // context URL is not yet available in all environments.\n const inlineTcpContext = {\n '@version': 1.1,\n id: '@id',\n type: '@type',\n TrustedCareerProfile: 'https://ctx.learncard.com/tcp#TrustedCareerProfile',\n ResumePackage: 'https://ctx.learncard.com/tcp#ResumePackage',\n pdfUrl: {\n '@id': 'https://ctx.learncard.com/tcp#pdfUrl',\n '@type': '@id',\n },\n pdfHash: 'https://ctx.learncard.com/tcp#pdfHash',\n hashAlgorithm: 'https://ctx.learncard.com/tcp#hashAlgorithm',\n includedCredentials: {\n '@id': 'https://ctx.learncard.com/tcp#includedCredentials',\n '@container': '@set',\n },\n category: 'https://ctx.learncard.com/tcp#category',\n generatedAt: {\n '@id': 'https://ctx.learncard.com/tcp#generatedAt',\n '@type': 'http://www.w3.org/2001/XMLSchema#dateTime',\n },\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineTcpContext],\n type: ['VerifiableCredential', TCP_WRAPPER_TYPE],\n id: params.wrapperId,\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: subjectDid,\n type: 'ResumePackage',\n pdfUrl: params.pdfUrl,\n pdfHash: params.pdfHash,\n hashAlgorithm: 'SHA-256',\n includedCredentials: params.includedCredentials,\n generatedAt,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n },\n };\n};\n"],
|
|
5
|
+
"mappings": "4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,+BAAAC,EAAA,iCAAAC,EAAA,iCAAAC,EAAA,wBAAAC,EAAA,0BAAAC,EAAA,mBAAAC,EAAA,qBAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAX,GCaO,IAAMY,EAA+B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TCP_WRAPPER_TYPE", "getLerRsPlugin", "__toCommonJS", "LER_RS_CREDENTIAL_CONTEXT_V1", "LER_RS_CREDENTIAL_CONTEXT_V2", "LER_RS_VC_CONTEXT_V45", "LER_RS_TYPE_URI_V45", "LEGACY_LER_RS_TYPE_URI_V44", "LEGACY_LER_RS_TYPE_TOKEN", "TCP_CONTEXT_V1", "TCP_WRAPPER_TYPE", "getItemVerifications", "__name", "item", "toArray", "maybe", "inlineLerRsContext", "credentialHasLerRsType", "credential", "type", "LEGACY_LER_RS_TYPE_TOKEN", "LEGACY_LER_RS_TYPE_URI_V44", "LER_RS_TYPE_URI_V45", "credentialSubject", "inlineType", "nestedType", "buildEmploymentHistories", "items", "narrative", "descriptions", "verifiableCredential", "verifications", "position", "employer", "start", "end", "current", "rest", "container", "ph", "containerVerifications", "buildEducationAndLearnings", "institution", "degree", "specializations", "specialization", "buildCertifications", "effectiveTimePeriod", "getLerRsPlugin", "initLearnCard", "_learnCard", "params", "did", "issuedAt", "documentId", "personSection", "hasAddress", "webEntries", "entry", "socialEntries", "communication", "lerRecord", "s", "unsignedVC", "LER_RS_CREDENTIAL_CONTEXT_V2", "vp", "presentation", "domain", "challenge", "presCheck", "presentationResult", "credentialResults", "holder", "vcs", "credCheck", "issuerDid", "isSelfIssued", "err", "r", "generatedAt", "subjectDid", "TCP_WRAPPER_TYPE"]
|
|
7
7
|
}
|
|
@@ -21,7 +21,10 @@ var toArray = /* @__PURE__ */ __name((maybe) => maybe == null ? [] : Array.isArr
|
|
|
21
21
|
var inlineLerRsContext = {
|
|
22
22
|
"@version": 1.1,
|
|
23
23
|
hrrec: "http://schema.hropenstandards.org/recruiting/",
|
|
24
|
-
"@vocab": "http://schema.hropenstandards.org/recruiting/"
|
|
24
|
+
"@vocab": "http://schema.hropenstandards.org/recruiting/",
|
|
25
|
+
// Bind complete source credentials as JSON without inheriting the wrapper's
|
|
26
|
+
// protected VC v2 terms into older VC v1 contexts or altering issuer proofs.
|
|
27
|
+
verifications: { "@id": "hrrec:verifications", "@type": "@json" }
|
|
25
28
|
};
|
|
26
29
|
var credentialHasLerRsType = /* @__PURE__ */ __name((credential) => {
|
|
27
30
|
const typeList = Array.isArray(credential.type) ? credential.type : [credential.type];
|
|
@@ -66,7 +69,8 @@ var buildEmploymentHistories = /* @__PURE__ */ __name((items) => {
|
|
|
66
69
|
container.positionHistories = [ph];
|
|
67
70
|
}
|
|
68
71
|
if (narrative) container.narrative = narrative;
|
|
69
|
-
if (descriptions?.length && !container.positionHistories)
|
|
72
|
+
if (descriptions?.length && !container.positionHistories)
|
|
73
|
+
container.descriptions = descriptions;
|
|
70
74
|
const containerVerifications = getItemVerifications({
|
|
71
75
|
verifiableCredential,
|
|
72
76
|
verifications
|
|
@@ -185,7 +189,12 @@ var getLerRsPlugin = /* @__PURE__ */ __name((initLearnCard) => {
|
|
|
185
189
|
const communication = params.person.email || params.person.phone || hasAddress || webEntries.length > 0 || socialEntries.length > 0 ? {
|
|
186
190
|
...params.person.email ? { email: [{ address: params.person.email }] } : {},
|
|
187
191
|
...params.person.phone ? { phone: [{ formattedNumber: params.person.phone }] } : {},
|
|
188
|
-
...webEntries.length ? {
|
|
192
|
+
...webEntries.length ? {
|
|
193
|
+
web: webEntries.map((entry) => ({
|
|
194
|
+
url: entry.url,
|
|
195
|
+
name: entry.name
|
|
196
|
+
}))
|
|
197
|
+
} : {},
|
|
189
198
|
...socialEntries.length ? {
|
|
190
199
|
social: socialEntries.map((entry) => ({
|
|
191
200
|
uri: entry.uri,
|
|
@@ -200,7 +209,9 @@ var getLerRsPlugin = /* @__PURE__ */ __name((initLearnCard) => {
|
|
|
200
209
|
} : {},
|
|
201
210
|
...params.person.address?.line ? { line: params.person.address.line } : {},
|
|
202
211
|
...params.person.address?.city ? { city: params.person.address.city } : {},
|
|
203
|
-
...params.person.address?.postalCode ? {
|
|
212
|
+
...params.person.address?.postalCode ? {
|
|
213
|
+
postalCode: params.person.address.postalCode
|
|
214
|
+
} : {},
|
|
204
215
|
...params.person.address?.countryCode ? {
|
|
205
216
|
countryCode: params.person.address.countryCode
|
|
206
217
|
} : {}
|
|
@@ -288,9 +299,7 @@ var getLerRsPlugin = /* @__PURE__ */ __name((initLearnCard) => {
|
|
|
288
299
|
);
|
|
289
300
|
for (const credential of vcs) {
|
|
290
301
|
try {
|
|
291
|
-
const credCheck = await initLearnCard.invoke.verifyCredential(
|
|
292
|
-
credential
|
|
293
|
-
);
|
|
302
|
+
const credCheck = await initLearnCard.invoke.verifyCredential(credential);
|
|
294
303
|
const issuerDid = typeof credential.issuer === "string" ? credential.issuer : credential.issuer?.id;
|
|
295
304
|
const isSelfIssued = credentialHasLerRsType(credential) || !!holder && !!issuerDid && issuerDid === holder;
|
|
296
305
|
credentialResults.push({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types.ts", "../src/ler-rs.ts"],
|
|
4
|
-
"sourcesContent": ["import { Plugin, LearnCard } from '@learncard/core';\nimport {\n VC as VerifiableCredential,\n VP as VerifiablePresentation,\n UnsignedVC,\n UnsignedVP,\n VerificationCheck,\n} from '@learncard/types';\nimport type { VCPluginMethods, VCPluginDependentMethods } from '@learncard/vc-plugin';\n\n/**\n * Legacy W3C VC v1 context kept for interop with previously issued records.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V1 = 'https://www.w3.org/2018/credentials/v1';\n/**\n * Base W3C VC v2 context used by newly issued LER-RS credentials and presentations.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V2 = 'https://www.w3.org/ns/credentials/v2';\n/**\n * HR Open Standards VC wrapper context for LER-RS v4.5.\n */\nexport const LER_RS_VC_CONTEXT_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/VerifiableCredentialLER-RSType.json';\n/**\n * Canonical LER-RS type URI for v4.5.\n */\nexport const LER_RS_TYPE_URI_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/LER-RSType.json';\n/**\n * Legacy LER-RS type URI for v4.4 interop.\n */\nexport const LEGACY_LER_RS_TYPE_URI_V44 =\n 'http://schema.hropenstandards.org/4.4/recruiting/json/ler-rs/LER-RSType.json';\n/**\n * Legacy short type token used by older issuers.\n */\nexport const LEGACY_LER_RS_TYPE_TOKEN = 'LERRS';\n/**\n * Hosted TCP JSON-LD context URL.\n *\n * Note: current local wrapper issuance can inline context during local testing.\n */\nexport const TCP_CONTEXT_V1 = 'https://ctx.learncard.com/tcp/1.0.0.json';\n/**\n * LearnCard-defined wrapper VC type for TCP resume package artifacts.\n *\n * This is intentionally NOT a canonical HR Open Standards LER-RS type;\n * it is a custom wrapper used to bind PDF URL/hash + included credential refs.\n */\nexport const TCP_WRAPPER_TYPE = 'TrustedCareerProfile';\n\n/**\n * Identity details used to populate `credentialSubject.person`.\n */\nexport interface PersonProfile {\n /** Subject DID for the issued LER-RS record. */\n id: string;\n /** Given/first name. */\n givenName: string;\n /** Family/last name. */\n familyName: string;\n /** Optional display name override. */\n formattedName?: string;\n /** Optional contact email to include in communication block. */\n email?: string;\n /** Optional contact phone to include in communication block. */\n phone?: string;\n /** Optional physical/mailing address to include in communication block. */\n address?: {\n formattedAddress?: string;\n line?: string;\n city?: string;\n postalCode?: string;\n countryCode?: string;\n };\n /** Optional website URLs to include in communication block. */\n web?: Array<{ url: string; name?: string }>;\n /** Optional social profile URLs to include in communication block. */\n social?: Array<{ uri: string; name?: string }>;\n}\n\n/**\n * Skill item structure used inside generated LER-RS records.\n */\nexport interface LerSkill {\n name: string;\n comments?: string[];\n description?: string;\n yearsOfExperience?: number;\n endorsers?: Array<{\n person?: { name?: { formattedName?: string } };\n organization?: { name?: string };\n }>;\n}\n\n/**\n * Source work history entry. Can be self-asserted fields and/or third-party verification VCs.\n */\nexport interface WorkHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n // Common self-asserted fields\n position?: string;\n employer?: string;\n start?: string;\n end?: string;\n current?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * Source education entry. Can include freeform fields and optional verification VCs.\n */\nexport interface EducationHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n institution?: string;\n start?: string;\n end?: string;\n current?: boolean;\n degree?: string;\n specializations?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Source certification entry for `credentialSubject.certifications`.\n */\nexport interface CertificationItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n name?: string;\n issuingAuthority?: string | Record<string, unknown>;\n status?: string;\n start?: string;\n end?: string;\n effectiveTimePeriod?: { validFrom?: string; validTo?: string };\n [key: string]: unknown;\n}\n\n/**\n * Narrative section block supported by LER-RS schema.\n */\nexport interface LerNarrative {\n name: string;\n texts: Array<{\n name: string;\n lines: string[];\n }>;\n}\n\n/**\n * Typed shape of the LER-RS object embedded into `credentialSubject`.\n */\nexport interface LerRsRecord {\n type: string;\n documentId?: { value: string };\n person: {\n name: {\n given: string;\n family: string;\n formattedName?: string;\n };\n };\n communication?: {\n email?: { address: string }[];\n web?: { url: string; name?: string }[];\n phone?: Array<Record<string, unknown>>;\n address?: Array<Record<string, unknown>>;\n social?: Array<Record<string, unknown>>;\n };\n skills?: LerSkill[];\n narratives?: LerNarrative[];\n educationAndLearnings?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n employmentHistories?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n licenses?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n certifications?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n employmentPreferences?: Array<Record<string, unknown>>;\n positionPreferences?: Array<Record<string, unknown>>;\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a signed LER-RS VC from normalized source data.\n */\nexport interface CreateLerRecordParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n person: PersonProfile;\n workHistory?: WorkHistoryItem[];\n educationHistory?: EducationHistoryItem[];\n certifications?: CertificationItem[];\n skills?: string[];\n narratives?: LerNarrative[];\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a VP that packages one or more credentials including at least one LER-RS credential.\n */\nexport interface CreateLerPresentationParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n credentials: VerifiableCredential[];\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Parameters for verifying a LER-focused VP and nested credentials.\n */\nexport interface VerifyLerPresentationParams {\n presentation: VerifiablePresentation | string;\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Credential reference stored in TCP wrapper VC.\n */\nexport interface TcpIncludedCredentialRef {\n /** Resolved VC id when available; falls back to URI if id is unavailable. */\n id: string;\n /** Category label used for UI grouping and downstream filtering. */\n category: string;\n}\n\n/**\n * Parameters for issuing TrustedCareerProfile wrapper VCs.\n */\nexport interface CreateTcpWrapperVcParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n wrapperId: string;\n subjectDid?: string;\n pdfUrl: string;\n pdfHash: string;\n includedCredentials: TcpIncludedCredentialRef[];\n generatedAt?: string;\n /** Timestamp used as the issued credential's `validFrom` value. */\n issuanceDate?: string;\n coSignerDid?: string;\n enableCoSign?: boolean;\n}\n\n/**\n * Structured verification output for LER presentation verification.\n */\nexport interface VerificationResult {\n verified: boolean; // Overall status\n presentationResult: {\n verified: boolean;\n errors?: string[];\n };\n credentialResults: {\n credential: VerifiableCredential;\n verified: boolean;\n isSelfIssued: boolean;\n errors?: string[];\n }[];\n}\n\n/**\n * LearnCard dependency contract required by this plugin.\n */\nexport type LERRSDependentLearnCard = LearnCard<\n any,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n\n/**\n * Public invoke methods exposed by the LER-RS plugin.\n */\nexport type LERRSPluginMethods = {\n createLerRecord: (params: CreateLerRecordParams) => Promise<VerifiableCredential>;\n createLerPresentation: (params: CreateLerPresentationParams) => Promise<VerifiablePresentation>;\n verifyLerPresentation: (params: VerifyLerPresentationParams) => Promise<VerificationResult>;\n createTcpWrapperVc: (params: CreateTcpWrapperVcParams) => Promise<VerifiableCredential>;\n};\n\n/**\n * Plugin type definition for registration in LearnCard.\n */\nexport type LERRSPlugin = Plugin<\n 'LER-RS',\n never,\n LERRSPluginMethods,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n", "import {\n VC as VerifiableCredential,\n UnsignedVC,\n VP as VerifiablePresentation,\n UnsignedVP,\n} from '@learncard/types';\nimport {\n LERRSDependentLearnCard,\n LERRSPlugin,\n CreateLerRecordParams,\n CreateLerPresentationParams,\n VerifyLerPresentationParams,\n VerificationResult,\n LerRsRecord,\n LER_RS_CREDENTIAL_CONTEXT_V2,\n LER_RS_TYPE_URI_V45,\n LEGACY_LER_RS_TYPE_URI_V44,\n LEGACY_LER_RS_TYPE_TOKEN,\n TCP_WRAPPER_TYPE,\n} from './types';\n\n/**\n * Normalizes verification containers from either:\n * - `verifications: VC[]`\n * - `verifiableCredential: VC`\n */\nconst getItemVerifications = (item: {\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n}): VerifiableCredential[] => {\n if (item.verifications?.length) return item.verifications;\n if (item.verifiableCredential) return [item.verifiableCredential];\n return [];\n};\n\n/**\n * Converts scalar-or-array values into a normalized array.\n */\nconst toArray = <T>(maybe: T | T[] | undefined): T[] =>\n maybe == null ? [] : Array.isArray(maybe) ? maybe : [maybe];\n\n/**\n * Inline LER-RS JSON-LD context used for signing stability.\n *\n * The published HR Open URL is schema-oriented and can trigger additional remote\n * context resolution during expansion. Inlining this base context avoids network\n * dependency at issue time while preserving deterministic term expansion.\n */\nconst inlineLerRsContext = {\n '@version': 1.1,\n hrrec: 'http://schema.hropenstandards.org/recruiting/',\n '@vocab': 'http://schema.hropenstandards.org/recruiting/',\n};\n\n/**\n * Determines whether a VC represents a LER-RS credential (legacy and current forms).\n *\n * Checks:\n * - VC `type` array/token values\n * - `credentialSubject.type`\n * - nested `credentialSubject.lerrsType.type`\n */\nconst credentialHasLerRsType = (credential: VerifiableCredential): boolean => {\n const typeList = Array.isArray(credential.type) ? credential.type : [credential.type];\n if (\n typeList.some(type =>\n [LEGACY_LER_RS_TYPE_TOKEN, LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(\n type\n )\n )\n )\n return true;\n\n const credentialSubject = credential.credentialSubject as Record<string, unknown> | undefined;\n if (!credentialSubject) return false;\n\n const inlineType = credentialSubject.type;\n if (\n typeof inlineType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(inlineType)\n )\n return true;\n\n const nestedType = (credentialSubject.lerrsType as Record<string, unknown> | undefined)?.type;\n return (\n typeof nestedType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(nestedType)\n );\n};\n\n/**\n * Maps application work history items to LER-RS `employmentHistories` shape.\n */\nconst buildEmploymentHistories = (\n items: NonNullable<CreateLerRecordParams['workHistory']>\n): LerRsRecord['employmentHistories'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n position,\n employer,\n start,\n end,\n current,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (typeof current === 'boolean') container.current = current;\n\n if (employer) container.organization = { tradeName: employer };\n if (position || start || end || typeof current === 'boolean') {\n const ph: Record<string, unknown> = {};\n if (position) ph.title = position;\n if (start) ph.start = start;\n if (end) ph.end = end;\n if (typeof current === 'boolean') ph.current = current;\n if (descriptions?.length) ph.descriptions = descriptions;\n container.positionHistories = [ph];\n }\n if (narrative) container.narrative = narrative;\n if (descriptions?.length && !container.positionHistories) container.descriptions = descriptions;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps education source items into LER-RS `educationAndLearnings`.\n */\nconst buildEducationAndLearnings = (\n items: NonNullable<CreateLerRecordParams['educationHistory']>\n): LerRsRecord['educationAndLearnings'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n institution,\n start,\n end,\n current,\n degree,\n specializations,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (institution) container.institution = { name: institution };\n if (start) container.start = start;\n if (end) container.end = end;\n if (typeof current === 'boolean') container.current = current;\n if (descriptions?.length) container.descriptions = descriptions;\n if (degree || specializations) {\n container.educationDegrees = [\n {\n ...(degree ? { name: degree } : {}),\n ...(specializations\n ? {\n specializations: specializations.map(specialization => ({\n name: specialization,\n })),\n }\n : {}),\n },\n ];\n }\n if (narrative) container.narrative = narrative;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps certification source items to LER-RS `certifications`.\n */\nconst buildCertifications = (\n items: NonNullable<CreateLerRecordParams['certifications']>\n): LerRsRecord['certifications'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n start,\n end,\n effectiveTimePeriod,\n verifiableCredential,\n verifications,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (narrative) container.narrative = narrative;\n if (descriptions?.length) container.descriptions = descriptions;\n if (effectiveTimePeriod || start || end) {\n container.effectiveTimePeriod = {\n ...(effectiveTimePeriod ?? {}),\n ...(start ? { validFrom: start } : {}),\n ...(end ? { validTo: end } : {}),\n };\n }\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Returns the LearnCard LER-RS plugin with methods for:\n * - issuing LER-RS VCs\n * - packaging/verifying LER presentations\n * - issuing TCP wrapper VCs for resume packages\n */\nexport const getLerRsPlugin = (initLearnCard: LERRSDependentLearnCard): LERRSPlugin => {\n return {\n name: 'LER-RS',\n displayName: 'LER-RS',\n description:\n 'Create, package, and verify Learning & Employment Record Resume (LER-RS) credentials',\n methods: {\n /**\n * Issues a signed LER-RS VC from normalized person/work/education/certification data.\n *\n * The method:\n * 1. Builds a compliant LER-RS `credentialSubject`\n * 2. Applies VC + LER-RS contexts\n * 3. Signs via `invoke.issueCredential`\n */\n createLerRecord: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = new Date().toISOString();\n const documentId = crypto.randomUUID();\n\n const personSection: LerRsRecord['person'] = {\n name: {\n given: params.person.givenName,\n family: params.person.familyName,\n formattedName:\n params.person.formattedName ??\n `${params.person.givenName} ${params.person.familyName}`,\n },\n };\n\n const hasAddress =\n !!params.person.address?.formattedAddress ||\n !!params.person.address?.line ||\n !!params.person.address?.city ||\n !!params.person.address?.postalCode ||\n !!params.person.address?.countryCode;\n const webEntries = (params.person.web || []).filter(entry => entry?.url);\n const socialEntries = (params.person.social || []).filter(entry => entry?.uri);\n\n const communication: LerRsRecord['communication'] | undefined =\n params.person.email ||\n params.person.phone ||\n hasAddress ||\n webEntries.length > 0 ||\n socialEntries.length > 0\n ? {\n ...(params.person.email\n ? { email: [{ address: params.person.email }] }\n : {}),\n ...(params.person.phone\n ? { phone: [{ formattedNumber: params.person.phone }] }\n : {}),\n ...(webEntries.length\n ? { web: webEntries.map(entry => ({ url: entry.url, name: entry.name })) }\n : {}),\n ...(socialEntries.length\n ? {\n social: socialEntries.map(entry => ({\n uri: entry.uri,\n ...(entry.name ? { name: entry.name } : {}),\n })),\n }\n : {}),\n ...(hasAddress\n ? {\n address: [\n {\n ...(params.person.address?.formattedAddress\n ? {\n formattedAddress:\n params.person.address.formattedAddress,\n }\n : {}),\n ...(params.person.address?.line\n ? { line: params.person.address.line }\n : {}),\n ...(params.person.address?.city\n ? { city: params.person.address.city }\n : {}),\n ...(params.person.address?.postalCode\n ? { postalCode: params.person.address.postalCode }\n : {}),\n ...(params.person.address?.countryCode\n ? {\n countryCode:\n params.person.address.countryCode,\n }\n : {}),\n },\n ],\n }\n : {}),\n }\n : undefined;\n\n const lerRecord: LerRsRecord = {\n type: LER_RS_TYPE_URI_V45,\n documentId: { value: documentId },\n person: personSection,\n ...(communication ? { communication } : {}),\n skills: (params.skills || []).map(s => ({ name: s })),\n narratives: params.narratives,\n employmentHistories: params.workHistory\n ? buildEmploymentHistories(params.workHistory)\n : undefined,\n educationAndLearnings: params.educationHistory\n ? buildEducationAndLearnings(params.educationHistory)\n : undefined,\n certifications: params.certifications\n ? buildCertifications(params.certifications)\n : undefined,\n attachments: params.attachments,\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineLerRsContext],\n id: `urn:uuid:${documentId}`,\n type: ['VerifiableCredential', LER_RS_TYPE_URI_V45],\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: params.person.id,\n ...lerRecord,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n\n /**\n * Issues a VP containing at least one LER-RS credential.\n *\n * Throws if:\n * - credentials list is empty\n * - none of the credentials match LER-RS type checks\n */\n createLerPresentation: async (_learnCard, params): Promise<VerifiablePresentation> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n\n if (!params.credentials.length)\n throw new Error(\n 'createLerPresentation: credentials array must contain at least one credential'\n );\n const containsLer = params.credentials.some(credentialHasLerRsType);\n if (!containsLer)\n throw new Error(\n 'createLerPresentation: credentials must include at least one LER-RS credential'\n );\n\n const vp: UnsignedVP = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2],\n type: ['VerifiablePresentation'],\n holder: did,\n verifiableCredential:\n params.credentials.length === 1\n ? params.credentials[0]\n : params.credentials,\n };\n\n return initLearnCard.invoke.issuePresentation(vp, {\n ...(params.domain ? { domain: params.domain } : {}),\n ...(params.challenge ? { challenge: params.challenge } : {}),\n });\n },\n\n /**\n * Verifies a LER-focused VP and returns structured result details.\n *\n * Overall `verified` allows explicitly self-issued items when determining\n * final status, while still surfacing per-credential verification results.\n */\n verifyLerPresentation: async (\n _learnCard,\n { presentation, domain, challenge }: VerifyLerPresentationParams\n ): Promise<VerificationResult> => {\n const presCheck = await initLearnCard.invoke.verifyPresentation(presentation, {\n ...(domain ? { domain } : {}),\n ...(challenge ? { challenge } : {}),\n });\n\n const presentationResult = {\n verified: presCheck.errors.length === 0,\n errors: presCheck.errors.length ? presCheck.errors : undefined,\n };\n\n const credentialResults: VerificationResult['credentialResults'] = [];\n\n if (typeof presentation !== 'string') {\n const holder = presentation.holder;\n const vcs = toArray<VerifiableCredential>(\n presentation.verifiableCredential as any\n );\n\n for (const credential of vcs) {\n try {\n const credCheck = await initLearnCard.invoke.verifyCredential(\n credential\n );\n const issuerDid =\n typeof credential.issuer === 'string'\n ? credential.issuer\n : credential.issuer?.id;\n const isSelfIssued =\n credentialHasLerRsType(credential) ||\n (!!holder && !!issuerDid && issuerDid === holder);\n\n credentialResults.push({\n credential,\n verified: credCheck.errors.length === 0,\n isSelfIssued,\n errors: credCheck.errors.length ? credCheck.errors : undefined,\n });\n } catch (err) {\n credentialResults.push({\n credential,\n verified: false,\n isSelfIssued: false,\n errors: [\n err instanceof Error\n ? err.message\n : 'Unknown error verifying credential',\n ],\n });\n }\n }\n }\n\n return {\n verified:\n presentationResult.verified &&\n credentialResults.every(r => r.verified || r.isSelfIssued),\n presentationResult,\n credentialResults,\n };\n },\n\n /**\n * Issues a signed TrustedCareerProfile wrapper VC for resume package publishing.\n *\n * Includes:\n * - public PDF URL\n * - PDF SHA-256 hash\n * - included credential references\n * - generation timestamp\n *\n * Co-sign fields are intentionally stubbed for MVP and currently rejected.\n */\n createTcpWrapperVc: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = params.issuanceDate ?? new Date().toISOString();\n const generatedAt = params.generatedAt ?? issuedAt;\n const subjectDid = params.subjectDid ?? did;\n\n if (params.enableCoSign) {\n throw new Error('createTcpWrapperVc: co-signing is not enabled in MVP');\n }\n\n if (params.coSignerDid) {\n throw new Error(\n 'createTcpWrapperVc: coSignerDid is reserved for future co-sign support'\n );\n }\n\n // NOTE: We inline the TCP context for local testing while the hosted\n // context URL is not yet available in all environments.\n const inlineTcpContext = {\n '@version': 1.1,\n id: '@id',\n type: '@type',\n TrustedCareerProfile: 'https://ctx.learncard.com/tcp#TrustedCareerProfile',\n ResumePackage: 'https://ctx.learncard.com/tcp#ResumePackage',\n pdfUrl: {\n '@id': 'https://ctx.learncard.com/tcp#pdfUrl',\n '@type': '@id',\n },\n pdfHash: 'https://ctx.learncard.com/tcp#pdfHash',\n hashAlgorithm: 'https://ctx.learncard.com/tcp#hashAlgorithm',\n includedCredentials: {\n '@id': 'https://ctx.learncard.com/tcp#includedCredentials',\n '@container': '@set',\n },\n category: 'https://ctx.learncard.com/tcp#category',\n generatedAt: {\n '@id': 'https://ctx.learncard.com/tcp#generatedAt',\n '@type': 'http://www.w3.org/2001/XMLSchema#dateTime',\n },\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineTcpContext],\n type: ['VerifiableCredential', TCP_WRAPPER_TYPE],\n id: params.wrapperId,\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: subjectDid,\n type: 'ResumePackage',\n pdfUrl: params.pdfUrl,\n pdfHash: params.pdfHash,\n hashAlgorithm: 'SHA-256',\n includedCredentials: params.includedCredentials,\n generatedAt,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n },\n };\n};\n"],
|
|
5
|
-
"mappings": ";;;;AAaO,IAAM,+BAA+B;AAIrC,IAAM,+BAA+B;AAIrC,IAAM,wBACT;AAIG,IAAM,sBACT;AAIG,IAAM,6BACT;AAIG,IAAM,2BAA2B;AAMjC,IAAM,iBAAiB;AAOvB,IAAM,mBAAmB;;;ACvBhC,IAAM,uBAAuB,wBAAC,SAGA;AAC1B,MAAI,KAAK,eAAe,OAAQ,QAAO,KAAK;AAC5C,MAAI,KAAK,qBAAsB,QAAO,CAAC,KAAK,oBAAoB;AAChE,SAAO,CAAC;AACZ,GAP6B;AAY7B,IAAM,UAAU,wBAAI,UAChB,SAAS,OAAO,CAAC,IAAI,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,GAD9C;AAUhB,IAAM,qBAAqB;AAAA,EACvB,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,UAAU;
|
|
4
|
+
"sourcesContent": ["import { Plugin, LearnCard } from '@learncard/core';\nimport {\n VC as VerifiableCredential,\n VP as VerifiablePresentation,\n UnsignedVC,\n UnsignedVP,\n VerificationCheck,\n} from '@learncard/types';\nimport type { VCPluginMethods, VCPluginDependentMethods } from '@learncard/vc-plugin';\n\n/**\n * Legacy W3C VC v1 context kept for interop with previously issued records.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V1 = 'https://www.w3.org/2018/credentials/v1';\n/**\n * Base W3C VC v2 context used by newly issued LER-RS credentials and presentations.\n */\nexport const LER_RS_CREDENTIAL_CONTEXT_V2 = 'https://www.w3.org/ns/credentials/v2';\n/**\n * HR Open Standards VC wrapper context for LER-RS v4.5.\n */\nexport const LER_RS_VC_CONTEXT_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/VerifiableCredentialLER-RSType.json';\n/**\n * Canonical LER-RS type URI for v4.5.\n */\nexport const LER_RS_TYPE_URI_V45 =\n 'http://schema.hropenstandards.org/4.5/recruiting/json/LER-RSType.json';\n/**\n * Legacy LER-RS type URI for v4.4 interop.\n */\nexport const LEGACY_LER_RS_TYPE_URI_V44 =\n 'http://schema.hropenstandards.org/4.4/recruiting/json/ler-rs/LER-RSType.json';\n/**\n * Legacy short type token used by older issuers.\n */\nexport const LEGACY_LER_RS_TYPE_TOKEN = 'LERRS';\n/**\n * Hosted TCP JSON-LD context URL.\n *\n * Note: current local wrapper issuance can inline context during local testing.\n */\nexport const TCP_CONTEXT_V1 = 'https://ctx.learncard.com/tcp/1.0.0.json';\n/**\n * LearnCard-defined wrapper VC type for TCP resume package artifacts.\n *\n * This is intentionally NOT a canonical HR Open Standards LER-RS type;\n * it is a custom wrapper used to bind PDF URL/hash + included credential refs.\n */\nexport const TCP_WRAPPER_TYPE = 'TrustedCareerProfile';\n\n/**\n * Identity details used to populate `credentialSubject.person`.\n */\nexport interface PersonProfile {\n /** Subject DID for the issued LER-RS record. */\n id: string;\n /** Given/first name. */\n givenName: string;\n /** Family/last name. */\n familyName: string;\n /** Optional display name override. */\n formattedName?: string;\n /** Optional contact email to include in communication block. */\n email?: string;\n /** Optional contact phone to include in communication block. */\n phone?: string;\n /** Optional physical/mailing address to include in communication block. */\n address?: {\n formattedAddress?: string;\n line?: string;\n city?: string;\n postalCode?: string;\n countryCode?: string;\n };\n /** Optional website URLs to include in communication block. */\n web?: Array<{ url: string; name?: string }>;\n /** Optional social profile URLs to include in communication block. */\n social?: Array<{ uri: string; name?: string }>;\n}\n\n/**\n * Skill item structure used inside generated LER-RS records.\n */\nexport interface LerSkill {\n name: string;\n comments?: string[];\n description?: string;\n yearsOfExperience?: number;\n endorsers?: Array<{\n person?: { name?: { formattedName?: string } };\n organization?: { name?: string };\n }>;\n}\n\n/**\n * Source work history entry. Can be self-asserted fields and/or third-party verification VCs.\n */\nexport interface WorkHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n // Common self-asserted fields\n position?: string;\n employer?: string;\n start?: string;\n end?: string;\n current?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * Source education entry. Can include freeform fields and optional verification VCs.\n */\nexport interface EducationHistoryItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n institution?: string;\n start?: string;\n end?: string;\n current?: boolean;\n degree?: string;\n specializations?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Source certification entry for `credentialSubject.certifications`.\n */\nexport interface CertificationItem {\n narrative?: string;\n descriptions?: string[];\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n name?: string;\n issuingAuthority?: string | Record<string, unknown>;\n status?: string;\n start?: string;\n end?: string;\n effectiveTimePeriod?: { validFrom?: string; validTo?: string };\n [key: string]: unknown;\n}\n\n/**\n * Narrative section block supported by LER-RS schema.\n */\nexport interface LerNarrative {\n name: string;\n texts: Array<{\n name: string;\n lines: string[];\n }>;\n}\n\n/**\n * Typed shape of the LER-RS object embedded into `credentialSubject`.\n */\nexport interface LerRsRecord {\n type: string;\n documentId?: { value: string };\n person: {\n name: {\n given: string;\n family: string;\n formattedName?: string;\n };\n };\n communication?: {\n email?: { address: string }[];\n web?: { url: string; name?: string }[];\n phone?: Array<Record<string, unknown>>;\n address?: Array<Record<string, unknown>>;\n social?: Array<Record<string, unknown>>;\n };\n skills?: LerSkill[];\n narratives?: LerNarrative[];\n educationAndLearnings?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n employmentHistories?: Array<\n { verifications?: VerifiableCredential[] } & Record<string, unknown>\n >;\n licenses?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n certifications?: Array<{ verifications?: VerifiableCredential[] } & Record<string, unknown>>;\n employmentPreferences?: Array<Record<string, unknown>>;\n positionPreferences?: Array<Record<string, unknown>>;\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a signed LER-RS VC from normalized source data.\n */\nexport interface CreateLerRecordParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n person: PersonProfile;\n workHistory?: WorkHistoryItem[];\n educationHistory?: EducationHistoryItem[];\n certifications?: CertificationItem[];\n skills?: string[];\n narratives?: LerNarrative[];\n attachments?: Array<Record<string, unknown>>;\n}\n\n/**\n * Parameters for issuing a VP that packages one or more credentials including at least one LER-RS credential.\n */\nexport interface CreateLerPresentationParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n credentials: VerifiableCredential[];\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Parameters for verifying a LER-focused VP and nested credentials.\n */\nexport interface VerifyLerPresentationParams {\n presentation: VerifiablePresentation | string;\n domain?: string;\n challenge?: string;\n}\n\n/**\n * Credential reference stored in TCP wrapper VC.\n */\nexport interface TcpIncludedCredentialRef {\n /** Resolved VC id when available; falls back to URI if id is unavailable. */\n id: string;\n /** Category label used for UI grouping and downstream filtering. */\n category: string;\n}\n\n/**\n * Parameters for issuing TrustedCareerProfile wrapper VCs.\n */\nexport interface CreateTcpWrapperVcParams {\n learnCard: LearnCard<any, 'id', VCPluginMethods & VCPluginDependentMethods>;\n wrapperId: string;\n subjectDid?: string;\n pdfUrl: string;\n pdfHash: string;\n includedCredentials: TcpIncludedCredentialRef[];\n generatedAt?: string;\n /** Timestamp used as the issued credential's `validFrom` value. */\n issuanceDate?: string;\n coSignerDid?: string;\n enableCoSign?: boolean;\n}\n\n/**\n * Structured verification output for LER presentation verification.\n */\nexport interface VerificationResult {\n verified: boolean; // Overall status\n presentationResult: {\n verified: boolean;\n errors?: string[];\n };\n credentialResults: {\n credential: VerifiableCredential;\n verified: boolean;\n isSelfIssued: boolean;\n errors?: string[];\n }[];\n}\n\n/**\n * LearnCard dependency contract required by this plugin.\n */\nexport type LERRSDependentLearnCard = LearnCard<\n any,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n\n/**\n * Public invoke methods exposed by the LER-RS plugin.\n */\nexport type LERRSPluginMethods = {\n createLerRecord: (params: CreateLerRecordParams) => Promise<VerifiableCredential>;\n createLerPresentation: (params: CreateLerPresentationParams) => Promise<VerifiablePresentation>;\n verifyLerPresentation: (params: VerifyLerPresentationParams) => Promise<VerificationResult>;\n createTcpWrapperVc: (params: CreateTcpWrapperVcParams) => Promise<VerifiableCredential>;\n};\n\n/**\n * Plugin type definition for registration in LearnCard.\n */\nexport type LERRSPlugin = Plugin<\n 'LER-RS',\n never,\n LERRSPluginMethods,\n 'id',\n VCPluginMethods & VCPluginDependentMethods\n>;\n", "import {\n VC as VerifiableCredential,\n UnsignedVC,\n VP as VerifiablePresentation,\n UnsignedVP,\n} from '@learncard/types';\nimport {\n LERRSDependentLearnCard,\n LERRSPlugin,\n CreateLerRecordParams,\n CreateLerPresentationParams,\n VerifyLerPresentationParams,\n VerificationResult,\n LerRsRecord,\n LER_RS_CREDENTIAL_CONTEXT_V2,\n LER_RS_TYPE_URI_V45,\n LEGACY_LER_RS_TYPE_URI_V44,\n LEGACY_LER_RS_TYPE_TOKEN,\n TCP_WRAPPER_TYPE,\n} from './types';\n\n/**\n * Normalizes verification containers from either:\n * - `verifications: VC[]`\n * - `verifiableCredential: VC`\n */\nconst getItemVerifications = (item: {\n verifiableCredential?: VerifiableCredential;\n verifications?: VerifiableCredential[];\n}): VerifiableCredential[] => {\n if (item.verifications?.length) return item.verifications;\n if (item.verifiableCredential) return [item.verifiableCredential];\n return [];\n};\n\n/**\n * Converts scalar-or-array values into a normalized array.\n */\nconst toArray = <T>(maybe: T | T[] | undefined): T[] =>\n maybe == null ? [] : Array.isArray(maybe) ? maybe : [maybe];\n\n/**\n * Inline LER-RS JSON-LD context used for signing stability.\n *\n * The published HR Open URL is schema-oriented and can trigger additional remote\n * context resolution during expansion. Inlining this base context avoids network\n * dependency at issue time while preserving deterministic term expansion.\n */\nconst inlineLerRsContext = {\n '@version': 1.1,\n hrrec: 'http://schema.hropenstandards.org/recruiting/',\n '@vocab': 'http://schema.hropenstandards.org/recruiting/',\n // Bind complete source credentials as JSON without inheriting the wrapper's\n // protected VC v2 terms into older VC v1 contexts or altering issuer proofs.\n verifications: { '@id': 'hrrec:verifications', '@type': '@json' },\n};\n\n/**\n * Determines whether a VC represents a LER-RS credential (legacy and current forms).\n *\n * Checks:\n * - VC `type` array/token values\n * - `credentialSubject.type`\n * - nested `credentialSubject.lerrsType.type`\n */\nconst credentialHasLerRsType = (credential: VerifiableCredential): boolean => {\n const typeList = Array.isArray(credential.type) ? credential.type : [credential.type];\n if (\n typeList.some(type =>\n [LEGACY_LER_RS_TYPE_TOKEN, LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(\n type\n )\n )\n )\n return true;\n\n const credentialSubject = credential.credentialSubject as Record<string, unknown> | undefined;\n if (!credentialSubject) return false;\n\n const inlineType = credentialSubject.type;\n if (\n typeof inlineType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(inlineType)\n )\n return true;\n\n const nestedType = (credentialSubject.lerrsType as Record<string, unknown> | undefined)?.type;\n return (\n typeof nestedType === 'string' &&\n [LEGACY_LER_RS_TYPE_URI_V44, LER_RS_TYPE_URI_V45].includes(nestedType)\n );\n};\n\n/**\n * Maps application work history items to LER-RS `employmentHistories` shape.\n */\nconst buildEmploymentHistories = (\n items: NonNullable<CreateLerRecordParams['workHistory']>\n): LerRsRecord['employmentHistories'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n position,\n employer,\n start,\n end,\n current,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (typeof current === 'boolean') container.current = current;\n\n if (employer) container.organization = { tradeName: employer };\n if (position || start || end || typeof current === 'boolean') {\n const ph: Record<string, unknown> = {};\n if (position) ph.title = position;\n if (start) ph.start = start;\n if (end) ph.end = end;\n if (typeof current === 'boolean') ph.current = current;\n if (descriptions?.length) ph.descriptions = descriptions;\n container.positionHistories = [ph];\n }\n if (narrative) container.narrative = narrative;\n if (descriptions?.length && !container.positionHistories)\n container.descriptions = descriptions;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps education source items into LER-RS `educationAndLearnings`.\n */\nconst buildEducationAndLearnings = (\n items: NonNullable<CreateLerRecordParams['educationHistory']>\n): LerRsRecord['educationAndLearnings'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n verifiableCredential,\n verifications,\n institution,\n start,\n end,\n current,\n degree,\n specializations,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (institution) container.institution = { name: institution };\n if (start) container.start = start;\n if (end) container.end = end;\n if (typeof current === 'boolean') container.current = current;\n if (descriptions?.length) container.descriptions = descriptions;\n if (degree || specializations) {\n container.educationDegrees = [\n {\n ...(degree ? { name: degree } : {}),\n ...(specializations\n ? {\n specializations: specializations.map(specialization => ({\n name: specialization,\n })),\n }\n : {}),\n },\n ];\n }\n if (narrative) container.narrative = narrative;\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Maps certification source items to LER-RS `certifications`.\n */\nconst buildCertifications = (\n items: NonNullable<CreateLerRecordParams['certifications']>\n): LerRsRecord['certifications'] => {\n return items.map(item => {\n const {\n narrative,\n descriptions,\n start,\n end,\n effectiveTimePeriod,\n verifiableCredential,\n verifications,\n ...rest\n } = item;\n\n const container: Record<string, unknown> = { ...rest };\n if (narrative) container.narrative = narrative;\n if (descriptions?.length) container.descriptions = descriptions;\n if (effectiveTimePeriod || start || end) {\n container.effectiveTimePeriod = {\n ...(effectiveTimePeriod ?? {}),\n ...(start ? { validFrom: start } : {}),\n ...(end ? { validTo: end } : {}),\n };\n }\n\n const containerVerifications = getItemVerifications({\n verifiableCredential,\n verifications,\n });\n return {\n ...container,\n ...(containerVerifications.length ? { verifications: containerVerifications } : {}),\n };\n });\n};\n\n/**\n * Returns the LearnCard LER-RS plugin with methods for:\n * - issuing LER-RS VCs\n * - packaging/verifying LER presentations\n * - issuing TCP wrapper VCs for resume packages\n */\nexport const getLerRsPlugin = (initLearnCard: LERRSDependentLearnCard): LERRSPlugin => {\n return {\n name: 'LER-RS',\n displayName: 'LER-RS',\n description:\n 'Create, package, and verify Learning & Employment Record Resume (LER-RS) credentials',\n methods: {\n /**\n * Issues a signed LER-RS VC from normalized person/work/education/certification data.\n *\n * The method:\n * 1. Builds a compliant LER-RS `credentialSubject`\n * 2. Applies VC + LER-RS contexts\n * 3. Signs via `invoke.issueCredential`\n */\n createLerRecord: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = new Date().toISOString();\n const documentId = crypto.randomUUID();\n\n const personSection: LerRsRecord['person'] = {\n name: {\n given: params.person.givenName,\n family: params.person.familyName,\n formattedName:\n params.person.formattedName ??\n `${params.person.givenName} ${params.person.familyName}`,\n },\n };\n\n const hasAddress =\n !!params.person.address?.formattedAddress ||\n !!params.person.address?.line ||\n !!params.person.address?.city ||\n !!params.person.address?.postalCode ||\n !!params.person.address?.countryCode;\n const webEntries = (params.person.web || []).filter(entry => entry?.url);\n const socialEntries = (params.person.social || []).filter(entry => entry?.uri);\n\n const communication: LerRsRecord['communication'] | undefined =\n params.person.email ||\n params.person.phone ||\n hasAddress ||\n webEntries.length > 0 ||\n socialEntries.length > 0\n ? {\n ...(params.person.email\n ? { email: [{ address: params.person.email }] }\n : {}),\n ...(params.person.phone\n ? { phone: [{ formattedNumber: params.person.phone }] }\n : {}),\n ...(webEntries.length\n ? {\n web: webEntries.map(entry => ({\n url: entry.url,\n name: entry.name,\n })),\n }\n : {}),\n ...(socialEntries.length\n ? {\n social: socialEntries.map(entry => ({\n uri: entry.uri,\n ...(entry.name ? { name: entry.name } : {}),\n })),\n }\n : {}),\n ...(hasAddress\n ? {\n address: [\n {\n ...(params.person.address?.formattedAddress\n ? {\n formattedAddress:\n params.person.address\n .formattedAddress,\n }\n : {}),\n ...(params.person.address?.line\n ? { line: params.person.address.line }\n : {}),\n ...(params.person.address?.city\n ? { city: params.person.address.city }\n : {}),\n ...(params.person.address?.postalCode\n ? {\n postalCode:\n params.person.address.postalCode,\n }\n : {}),\n ...(params.person.address?.countryCode\n ? {\n countryCode:\n params.person.address.countryCode,\n }\n : {}),\n },\n ],\n }\n : {}),\n }\n : undefined;\n\n const lerRecord: LerRsRecord = {\n type: LER_RS_TYPE_URI_V45,\n documentId: { value: documentId },\n person: personSection,\n ...(communication ? { communication } : {}),\n skills: (params.skills || []).map(s => ({ name: s })),\n narratives: params.narratives,\n employmentHistories: params.workHistory\n ? buildEmploymentHistories(params.workHistory)\n : undefined,\n educationAndLearnings: params.educationHistory\n ? buildEducationAndLearnings(params.educationHistory)\n : undefined,\n certifications: params.certifications\n ? buildCertifications(params.certifications)\n : undefined,\n attachments: params.attachments,\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineLerRsContext],\n id: `urn:uuid:${documentId}`,\n type: ['VerifiableCredential', LER_RS_TYPE_URI_V45],\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: params.person.id,\n ...lerRecord,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n\n /**\n * Issues a VP containing at least one LER-RS credential.\n *\n * Throws if:\n * - credentials list is empty\n * - none of the credentials match LER-RS type checks\n */\n createLerPresentation: async (_learnCard, params): Promise<VerifiablePresentation> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n\n if (!params.credentials.length)\n throw new Error(\n 'createLerPresentation: credentials array must contain at least one credential'\n );\n const containsLer = params.credentials.some(credentialHasLerRsType);\n if (!containsLer)\n throw new Error(\n 'createLerPresentation: credentials must include at least one LER-RS credential'\n );\n\n const vp: UnsignedVP = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2],\n type: ['VerifiablePresentation'],\n holder: did,\n verifiableCredential:\n params.credentials.length === 1\n ? params.credentials[0]\n : params.credentials,\n };\n\n return initLearnCard.invoke.issuePresentation(vp, {\n ...(params.domain ? { domain: params.domain } : {}),\n ...(params.challenge ? { challenge: params.challenge } : {}),\n });\n },\n\n /**\n * Verifies a LER-focused VP and returns structured result details.\n *\n * Overall `verified` allows explicitly self-issued items when determining\n * final status, while still surfacing per-credential verification results.\n */\n verifyLerPresentation: async (\n _learnCard,\n { presentation, domain, challenge }: VerifyLerPresentationParams\n ): Promise<VerificationResult> => {\n const presCheck = await initLearnCard.invoke.verifyPresentation(presentation, {\n ...(domain ? { domain } : {}),\n ...(challenge ? { challenge } : {}),\n });\n\n const presentationResult = {\n verified: presCheck.errors.length === 0,\n errors: presCheck.errors.length ? presCheck.errors : undefined,\n };\n\n const credentialResults: VerificationResult['credentialResults'] = [];\n\n if (typeof presentation !== 'string') {\n const holder = presentation.holder;\n const vcs = toArray<VerifiableCredential>(\n presentation.verifiableCredential as any\n );\n\n for (const credential of vcs) {\n try {\n const credCheck =\n await initLearnCard.invoke.verifyCredential(credential);\n const issuerDid =\n typeof credential.issuer === 'string'\n ? credential.issuer\n : credential.issuer?.id;\n const isSelfIssued =\n credentialHasLerRsType(credential) ||\n (!!holder && !!issuerDid && issuerDid === holder);\n\n credentialResults.push({\n credential,\n verified: credCheck.errors.length === 0,\n isSelfIssued,\n errors: credCheck.errors.length ? credCheck.errors : undefined,\n });\n } catch (err) {\n credentialResults.push({\n credential,\n verified: false,\n isSelfIssued: false,\n errors: [\n err instanceof Error\n ? err.message\n : 'Unknown error verifying credential',\n ],\n });\n }\n }\n }\n\n return {\n verified:\n presentationResult.verified &&\n credentialResults.every(r => r.verified || r.isSelfIssued),\n presentationResult,\n credentialResults,\n };\n },\n\n /**\n * Issues a signed TrustedCareerProfile wrapper VC for resume package publishing.\n *\n * Includes:\n * - public PDF URL\n * - PDF SHA-256 hash\n * - included credential references\n * - generation timestamp\n *\n * Co-sign fields are intentionally stubbed for MVP and currently rejected.\n */\n createTcpWrapperVc: async (_learnCard, params): Promise<VerifiableCredential> => {\n const signer = params.learnCard ?? _learnCard;\n const did = signer.id.did();\n const issuedAt = params.issuanceDate ?? new Date().toISOString();\n const generatedAt = params.generatedAt ?? issuedAt;\n const subjectDid = params.subjectDid ?? did;\n\n if (params.enableCoSign) {\n throw new Error('createTcpWrapperVc: co-signing is not enabled in MVP');\n }\n\n if (params.coSignerDid) {\n throw new Error(\n 'createTcpWrapperVc: coSignerDid is reserved for future co-sign support'\n );\n }\n\n // NOTE: We inline the TCP context for local testing while the hosted\n // context URL is not yet available in all environments.\n const inlineTcpContext = {\n '@version': 1.1,\n id: '@id',\n type: '@type',\n TrustedCareerProfile: 'https://ctx.learncard.com/tcp#TrustedCareerProfile',\n ResumePackage: 'https://ctx.learncard.com/tcp#ResumePackage',\n pdfUrl: {\n '@id': 'https://ctx.learncard.com/tcp#pdfUrl',\n '@type': '@id',\n },\n pdfHash: 'https://ctx.learncard.com/tcp#pdfHash',\n hashAlgorithm: 'https://ctx.learncard.com/tcp#hashAlgorithm',\n includedCredentials: {\n '@id': 'https://ctx.learncard.com/tcp#includedCredentials',\n '@container': '@set',\n },\n category: 'https://ctx.learncard.com/tcp#category',\n generatedAt: {\n '@id': 'https://ctx.learncard.com/tcp#generatedAt',\n '@type': 'http://www.w3.org/2001/XMLSchema#dateTime',\n },\n };\n\n const unsignedVC: UnsignedVC = {\n '@context': [LER_RS_CREDENTIAL_CONTEXT_V2, inlineTcpContext],\n type: ['VerifiableCredential', TCP_WRAPPER_TYPE],\n id: params.wrapperId,\n issuer: did,\n validFrom: issuedAt,\n credentialSubject: {\n id: subjectDid,\n type: 'ResumePackage',\n pdfUrl: params.pdfUrl,\n pdfHash: params.pdfHash,\n hashAlgorithm: 'SHA-256',\n includedCredentials: params.includedCredentials,\n generatedAt,\n },\n };\n\n return initLearnCard.invoke.issueCredential(unsignedVC, {\n proofPurpose: 'assertionMethod',\n });\n },\n },\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;AAaO,IAAM,+BAA+B;AAIr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D,cAAc;AAAA,QAClB,CAAC;AAAA,MACL,GA9DoB;AAAA,IA+DxB;AAAA,EACJ;AACJ,GApU8B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/ler-rs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ler-rs.d.ts","sourceRoot":"","sources":["../src/ler-rs.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,uBAAuB,EACvB,WAAW,EAWd,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ler-rs.d.ts","sourceRoot":"","sources":["../src/ler-rs.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,uBAAuB,EACvB,WAAW,EAWd,MAAM,SAAS,CAAC;AAwNjB;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,eAAe,uBAAuB,KAAG,WAoUvE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learncard/ler-rs-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"description": "LER-RS plugin for LearnCard: create, package, and verify Learning & Employment Record Resumes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"types": "./dist/index.d.ts",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@learncard/core": "9.4.
|
|
51
|
-
"@learncard/types": "5.
|
|
52
|
-
"@learncard/vc-plugin": "1.6.
|
|
50
|
+
"@learncard/core": "9.4.38",
|
|
51
|
+
"@learncard/types": "5.23.0",
|
|
52
|
+
"@learncard/vc-plugin": "1.6.4"
|
|
53
53
|
}
|
|
54
54
|
}
|
package/src/ler-rs.ts
CHANGED
|
@@ -50,6 +50,9 @@ const inlineLerRsContext = {
|
|
|
50
50
|
'@version': 1.1,
|
|
51
51
|
hrrec: 'http://schema.hropenstandards.org/recruiting/',
|
|
52
52
|
'@vocab': 'http://schema.hropenstandards.org/recruiting/',
|
|
53
|
+
// Bind complete source credentials as JSON without inheriting the wrapper's
|
|
54
|
+
// protected VC v2 terms into older VC v1 contexts or altering issuer proofs.
|
|
55
|
+
verifications: { '@id': 'hrrec:verifications', '@type': '@json' },
|
|
53
56
|
};
|
|
54
57
|
|
|
55
58
|
/**
|
|
@@ -122,7 +125,8 @@ const buildEmploymentHistories = (
|
|
|
122
125
|
container.positionHistories = [ph];
|
|
123
126
|
}
|
|
124
127
|
if (narrative) container.narrative = narrative;
|
|
125
|
-
if (descriptions?.length && !container.positionHistories)
|
|
128
|
+
if (descriptions?.length && !container.positionHistories)
|
|
129
|
+
container.descriptions = descriptions;
|
|
126
130
|
|
|
127
131
|
const containerVerifications = getItemVerifications({
|
|
128
132
|
verifiableCredential,
|
|
@@ -289,7 +293,12 @@ export const getLerRsPlugin = (initLearnCard: LERRSDependentLearnCard): LERRSPlu
|
|
|
289
293
|
? { phone: [{ formattedNumber: params.person.phone }] }
|
|
290
294
|
: {}),
|
|
291
295
|
...(webEntries.length
|
|
292
|
-
? {
|
|
296
|
+
? {
|
|
297
|
+
web: webEntries.map(entry => ({
|
|
298
|
+
url: entry.url,
|
|
299
|
+
name: entry.name,
|
|
300
|
+
})),
|
|
301
|
+
}
|
|
293
302
|
: {}),
|
|
294
303
|
...(socialEntries.length
|
|
295
304
|
? {
|
|
@@ -306,7 +315,8 @@ export const getLerRsPlugin = (initLearnCard: LERRSDependentLearnCard): LERRSPlu
|
|
|
306
315
|
...(params.person.address?.formattedAddress
|
|
307
316
|
? {
|
|
308
317
|
formattedAddress:
|
|
309
|
-
params.person.address
|
|
318
|
+
params.person.address
|
|
319
|
+
.formattedAddress,
|
|
310
320
|
}
|
|
311
321
|
: {}),
|
|
312
322
|
...(params.person.address?.line
|
|
@@ -316,7 +326,10 @@ export const getLerRsPlugin = (initLearnCard: LERRSDependentLearnCard): LERRSPlu
|
|
|
316
326
|
? { city: params.person.address.city }
|
|
317
327
|
: {}),
|
|
318
328
|
...(params.person.address?.postalCode
|
|
319
|
-
? {
|
|
329
|
+
? {
|
|
330
|
+
postalCode:
|
|
331
|
+
params.person.address.postalCode,
|
|
332
|
+
}
|
|
320
333
|
: {}),
|
|
321
334
|
...(params.person.address?.countryCode
|
|
322
335
|
? {
|
|
@@ -434,9 +447,8 @@ export const getLerRsPlugin = (initLearnCard: LERRSDependentLearnCard): LERRSPlu
|
|
|
434
447
|
|
|
435
448
|
for (const credential of vcs) {
|
|
436
449
|
try {
|
|
437
|
-
const credCheck =
|
|
438
|
-
credential
|
|
439
|
-
);
|
|
450
|
+
const credCheck =
|
|
451
|
+
await initLearnCard.invoke.verifyCredential(credential);
|
|
440
452
|
const issuerDid =
|
|
441
453
|
typeof credential.issuer === 'string'
|
|
442
454
|
? credential.issuer
|