@learncard/vc-api-plugin 1.1.20 → 1.1.21

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('./vc-api-plugin.cjs.production.min.js');
4
+ module.exports = require('./vc-api-plugin.cjs.production.min.cjs');
5
5
  } else {
6
- module.exports = require('./vc-api-plugin.cjs.development.js');
6
+ module.exports = require('./vc-api-plugin.cjs.development.cjs');
7
7
  }
@@ -0,0 +1,10 @@
1
+ import { VCAPIPlugin } from './types';
2
+ export * from './types';
3
+ /**
4
+ * @group Plugins
5
+ */
6
+ export declare const getVCAPIPlugin: ({ url: _url, did: _did, }: {
7
+ url: string;
8
+ did?: string;
9
+ }) => Promise<VCAPIPlugin>;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -121,4 +121,4 @@ var getVCAPIPlugin = /* @__PURE__ */ __name(async ({
121
121
  }
122
122
  };
123
123
  }, "getVCAPIPlugin");
124
- //# sourceMappingURL=vc-api-plugin.cjs.development.js.map
124
+ //# sourceMappingURL=vc-api-plugin.cjs.development.cjs.map
@@ -1,2 +1,2 @@
1
1
  "use strict";var l=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var n=(e,r)=>l(e,"name",{value:r,configurable:!0});var f=(e,r)=>{for(var o in r)l(e,o,{get:r[o],enumerable:!0})},P=(e,r,o,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of y(r))!g.call(e,s)&&s!==o&&l(e,s,{get:()=>r[s],enumerable:!(d=w(r,s))||d.enumerable});return e};var V=e=>P(l({},"__esModule",{value:!0}),e);var A={};f(A,{getVCAPIPlugin:()=>C});module.exports=V(A);var i=require("@learncard/types");var u=n(async(e,r)=>fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),"post"),p=n(e=>e.toString().startsWith("2"),"isSuccessful");var C=n(async({url:e,did:r})=>{let o=e.endsWith("/")?e.slice(0,-1):e,d=r;if(!d){let s=await fetch(`${o}/did`);s.status===200&&(d=await s.text())}if(!d)throw new Error("Could not retrieve did from VC API! Please suppy a did.");return{name:"VC API",displayName:"VC API",description:"Handles issuing and signing credentials/presentations using an external VC API",id:{did:n(()=>d,"did"),keypair:n(()=>{throw new Error("Cannot get keypair when using VC API")},"keypair")},methods:{getSubjectDid:n(()=>d,"getSubjectDid"),issueCredential:n(async(s,a,c)=>{await i.UnsignedVCValidator.parseAsync(a);let t=await u(`${o}/credentials/issue`,{credential:a,options:c});if(!p(t.status))throw new Error(`API Error: ${t.status} ${t.statusText}`);return i.VCValidator.parseAsync(await t.json())},"issueCredential"),verifyCredential:n(async(s,a,c)=>{await i.VCValidator.parseAsync(a);let t=await u(`${o}/credentials/verify`,{verifiableCredential:a,options:c});if(!p(t.status))throw new Error(`API Error: ${t.status} ${t.statusText}`);return i.VerificationCheckValidator.parseAsync(await t.json())},"verifyCredential"),issuePresentation:n(async(s,a,c)=>{await i.UnsignedVPValidator.parseAsync(a);let t=await u(`${o}/presentations/issue`,{presentation:a,options:c});if(!p(t.status))throw new Error(`API Error: ${t.status} ${t.statusText}`);return i.VPValidator.parseAsync(await t.json())},"issuePresentation"),verifyPresentation:n(async(s,a,c)=>{await i.VPValidator.parseAsync(a);let t=await u(`${o}/presentations/verify`,{verifiablePresentation:a,options:c});if(!p(t.status))throw new Error(`API Error: ${t.status} ${t.statusText}`);return i.VerificationCheckValidator.parseAsync(await t.json())},"verifyPresentation"),getTestVc:n((s,a="did:example:d23dd687a7dc6787646f2eb98d0")=>({"@context":["https://www.w3.org/2018/credentials/v1"],id:"http://example.org/credentials/3731",type:["VerifiableCredential"],issuer:d,issuanceDate:"2020-08-19T21:41:50Z",credentialSubject:{id:a}}),"getTestVc"),getTestVp:n(async(s,a)=>{let c=a||await s.invoke.issueCredential(s.invoke.getTestVc());return{"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiablePresentation"],holder:d,verifiableCredential:c}},"getTestVp")}}},"getVCAPIPlugin");
2
- //# sourceMappingURL=vc-api-plugin.cjs.production.min.js.map
2
+ //# sourceMappingURL=vc-api-plugin.cjs.production.min.cjs.map
package/package.json CHANGED
@@ -1,9 +1,22 @@
1
1
  {
2
2
  "name": "@learncard/vc-api-plugin",
3
- "version": "1.1.20",
3
+ "version": "1.1.21",
4
4
  "description": "",
5
- "main": "./dist/index.js",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
6
7
  "module": "./dist/vc-api-plugin.esm.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/vc-api-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
  ],
@@ -30,12 +43,12 @@
30
43
  },
31
44
  "types": "./dist/index.d.ts",
32
45
  "dependencies": {
33
- "@learncard/core": "9.4.20",
34
- "@learncard/types": "5.17.0"
46
+ "@learncard/core": "9.4.21",
47
+ "@learncard/types": "5.17.1"
35
48
  },
36
49
  "sideEffects": false,
37
50
  "scripts": {
38
- "build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.js && tsc --p tsconfig.json",
51
+ "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",
39
52
  "test": "jest --passWithNoTests",
40
53
  "test:watch": "jest --watch",
41
54
  "test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\""