@learncard/linked-claims-plugin 0.2.20 → 0.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  if (process.env.NODE_ENV === 'production') {
4
- module.exports = require('./linked-claims-plugin.cjs.production.min.js');
4
+ module.exports = require('./linked-claims-plugin.cjs.production.min.cjs');
5
5
  } else {
6
- module.exports = require('./linked-claims-plugin.cjs.development.js');
6
+ module.exports = require('./linked-claims-plugin.cjs.development.cjs');
7
7
  }
@@ -0,0 +1,5 @@
1
+ import type { LearnCard } from '@learncard/core';
2
+ import type { LinkedClaimsPlugin, LinkedClaimsPluginDependentMethods } from './types';
3
+ export * from './types';
4
+ export declare const getLinkedClaimsPlugin: (learnCard: LearnCard<any, "id" | "store" | "index" | "read", LinkedClaimsPluginDependentMethods>) => LinkedClaimsPlugin;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -160,4 +160,4 @@ var getLinkedClaimsPlugin = /* @__PURE__ */ __name((learnCard) => ({
160
160
  }, "getEndorsements")
161
161
  }
162
162
  }), "getLinkedClaimsPlugin");
163
- //# sourceMappingURL=linked-claims-plugin.cjs.development.js.map
163
+ //# sourceMappingURL=linked-claims-plugin.cjs.development.cjs.map
@@ -1,2 +1,2 @@
1
1
  "use strict";var p=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var c=(e,t)=>p(e,"name",{value:t,configurable:!0});var E=(e,t)=>{for(var n in t)p(e,n,{get:t[n],enumerable:!0})},w=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of b(t))!C.call(e,i)&&i!==n&&p(e,i,{get:()=>t[i],enumerable:!(r=h(t,i))||r.enumerable});return e};var k=e=>w(p({},"__esModule",{value:!0}),e);var I={};E(I,{getLinkedClaimsPlugin:()=>x});module.exports=k(I);var g="https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json",f=c(e=>{let t=e.credentialSubject;return Array.isArray(t)?t.map(n=>n?.id).filter(Boolean):t?.id?[t.id]:[]},"getSubjectIds"),v=c((e,t)=>{let n=Object.keys(e.index||{}).filter(r=>!["providers","all"].includes(r));if(n.length)return t&&n.includes(t)?t:n.includes("LearnCloud")?"LearnCloud":n[0]},"pickIndexProvider"),j=c((e,t)=>{let n=Object.keys(e.store||{}).filter(r=>r!=="providers");if(n.length)return t&&n.includes(t)?t:n[0]},"pickStoreProvider"),m=c(e=>Array.isArray(e)?e:e?[e]:[],"ensureArray"),x=c(e=>({name:"LinkedClaims",displayName:"LinkedClaims",description:"Create, verify, store, and retrieve endorsement credentials linked to originals.",methods:{endorseCredential:c(async(t,n,r,i)=>{let l=e.id.did(),o=n.id,d=f(n),s=o||d[0];if(!s)throw new Error("Original credential must have either id or credentialSubject.id");let y={"@context":["https://www.w3.org/ns/credentials/v2",g],type:["VerifiableCredential","EndorsementCredential"],issuer:l,validFrom:new Date().toISOString(),credentialSubject:{type:["EndorsementSubject"],id:s,...r.endorsementComment?{endorsementComment:r.endorsementComment}:{}},...r.name?{name:r.name}:{name:`Endorsement of ${s}`},...r.description?{description:r.description}:{},...r.evidence&&{evidence:r.evidence}};return e.invoke.issueCredential(y)},"endorseCredential"),verifyEndorsement:c(async(t,n,r)=>{let i=await e.invoke.verifyCredential(n,r),l=m(n["@context"]),o=m(n.type);(!l.some(a=>a==="https://www.w3.org/ns/credentials/v2")||!l.some(a=>a===g))&&i.errors.push("linked-claims error: missing VCv2 or OBv3 context"),o.includes("EndorsementCredential")||i.errors.push("linked-claims error: missing EndorsementCredential type");let d=n.credentialSubject,s=Array.isArray(d)?d[0]:d;return m(s?.type).includes("EndorsementSubject")||i.errors.push("linked-claims error: credentialSubject.type must include EndorsementSubject"),s?.id||i.errors.push("linked-claims error: credentialSubject.id missing"),i.errors.length||i.checks.push("linked-claims"),i},"verifyEndorsement"),storeEndorsement:c(async(t,n,r)=>{let i=j(e,r?.storeName);if(!i)throw new Error("No store plane provider available");if(!e.store[i].uploadEncrypted||typeof e.store[i].uploadEncrypted!="function")throw new Error(`Store provider '${i}' does not support uploadEncrypted method`);let l=await e.store[i].uploadEncrypted(n),o=v(e,r?.indexName),d=!1,s=n.id||`urn:uuid:${globalThis.crypto?.randomUUID?.()||(()=>{throw new Error("Secure random UUID generation is not available. Please use an environment that supports crypto.randomUUID().")})()}`;if(o){let u=n.credentialSubject,a=Array.isArray(u)?u[0]:u,y={id:s,uri:l,type:m(n.type),endorsedId:a?.id,subjectId:a?.id,originalCredentialId:a?.id,issuedOn:n.validFrom||n.issuanceDate,category:"Endorsement",credentialId:r?.credentialId,sharedUri:r?.sharedUri,relationship:r?.relationship,visibility:r?.visibility??"public"};d=await e.index[o].add(y)}return{uri:l,indexed:d,id:s,indexName:o,storeName:i}},"storeEndorsement"),getEndorsements:c(async(t,n,r)=>{let i=v(e,r?.indexName);if(!i)return[];let l=f(n),o=n.id,d=o?{originalCredentialId:o}:{endorsedId:l[0]},s=await e.index[i].get(d),u=[];for(let a of s){let y=await e.read.get(a.uri);y&&u.push(y)}return u},"getEndorsements")}}),"getLinkedClaimsPlugin");
2
- //# sourceMappingURL=linked-claims-plugin.cjs.production.min.js.map
2
+ //# sourceMappingURL=linked-claims-plugin.cjs.production.min.cjs.map
package/package.json CHANGED
@@ -1,9 +1,22 @@
1
1
  {
2
2
  "name": "@learncard/linked-claims-plugin",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "description": "LinkedClaims plugin to create, verify, store, and query endorsement credentials.",
5
- "main": "./dist/index.js",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
6
7
  "module": "./dist/linked-claims-plugin.esm.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/linked-claims-plugin.esm.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.cts",
16
+ "default": "./dist/index.cjs"
17
+ }
18
+ }
19
+ },
7
20
  "files": [
8
21
  "dist"
9
22
  ],
@@ -31,13 +44,13 @@
31
44
  "types": "./dist/index.d.ts",
32
45
  "dependencies": {
33
46
  "why-is-node-running": "^2.2.2",
34
- "@learncard/types": "5.17.0",
35
- "@learncard/vc-plugin": "^1.5.0",
36
- "@learncard/core": "9.4.20"
47
+ "@learncard/vc-plugin": "^1.5.2",
48
+ "@learncard/core": "9.4.22",
49
+ "@learncard/types": "5.17.2"
37
50
  },
38
51
  "sideEffects": false,
39
52
  "scripts": {
40
- "build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.js && tsc --p tsconfig.json",
53
+ "build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.cjs && tsc --p tsconfig.json && shx cp ./dist/index.d.ts ./dist/index.d.cts",
41
54
  "test": "jest --passWithNoTests",
42
55
  "test:watch": "jest --watch",
43
56
  "test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\""