@learncard/vc-api-plugin 1.1.20 → 1.1.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.
- package/dist/{index.js → index.cjs} +2 -2
- package/dist/index.d.cts +10 -0
- package/dist/{vc-api-plugin.cjs.development.js → vc-api-plugin.cjs.development.cjs} +1 -1
- package/dist/{vc-api-plugin.cjs.production.min.js → vc-api-plugin.cjs.production.min.cjs} +1 -1
- package/package.json +18 -5
- /package/dist/{vc-api-plugin.cjs.development.js.map → vc-api-plugin.cjs.development.cjs.map} +0 -0
- /package/dist/{vc-api-plugin.cjs.production.min.js.map → vc-api-plugin.cjs.production.min.cjs.map} +0 -0
|
@@ -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.
|
|
4
|
+
module.exports = require('./vc-api-plugin.cjs.production.min.cjs');
|
|
5
5
|
} else {
|
|
6
|
-
module.exports = require('./vc-api-plugin.cjs.development.
|
|
6
|
+
module.exports = require('./vc-api-plugin.cjs.development.cjs');
|
|
7
7
|
}
|
package/dist/index.d.cts
ADDED
|
@@ -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
|
|
@@ -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.
|
|
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.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
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.
|
|
34
|
-
"@learncard/types": "5.17.
|
|
46
|
+
"@learncard/core": "9.4.22",
|
|
47
|
+
"@learncard/types": "5.17.2"
|
|
35
48
|
},
|
|
36
49
|
"sideEffects": false,
|
|
37
50
|
"scripts": {
|
|
38
|
-
"build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.
|
|
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\""
|
/package/dist/{vc-api-plugin.cjs.development.js.map → vc-api-plugin.cjs.development.cjs.map}
RENAMED
|
File without changes
|
/package/dist/{vc-api-plugin.cjs.production.min.js.map → vc-api-plugin.cjs.production.min.cjs.map}
RENAMED
|
File without changes
|