@learncard/vc-plugin 1.5.0 → 1.5.2
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.cjs +7 -0
- package/dist/index.d.cts +3 -0
- package/dist/{vc-plugin.cjs.development.js → vc-plugin.cjs.development.cjs} +1 -1
- package/dist/{vc-plugin.cjs.production.min.js → vc-plugin.cjs.production.min.cjs} +1 -1
- package/package.json +19 -6
- package/dist/index.js +0 -7
- /package/dist/{vc-plugin.cjs.development.js.map → vc-plugin.cjs.development.cjs.map} +0 -0
- /package/dist/{vc-plugin.cjs.production.min.js.map → vc-plugin.cjs.production.min.cjs.map} +0 -0
package/dist/index.cjs
ADDED
package/dist/index.d.cts
ADDED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";var U=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var i=(r,e)=>U(r,"name",{value:e,configurable:!0});var _=(r,e)=>{for(var t in e)U(r,t,{get:e[t],enumerable:!0})},ee=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Y(e))!H.call(r,o)&&o!==t&&U(r,o,{get:()=>e[o],enumerable:!(n=W(e,o))||n.enumerable});return r};var te=r=>ee(U({},"__esModule",{value:!0}),r);var ae={};_(ae,{getVCPlugin:()=>G});module.exports=te(ae);function re(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var f=r.charAt(o),c=f.charCodeAt(0);if(t[c]!==255)throw new TypeError(f+" is ambiguous");t[c]=o}var s=r.length,a=r.charAt(0),p=Math.log(s)/Math.log(256),m=Math.log(256)/Math.log(s);function P(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var u=0,C=0,h=0,w=d.length;h!==w&&d[h]===0;)h++,u++;for(var g=(w-h)*m+1>>>0,l=new Uint8Array(g);h!==w;){for(var b=d[h],x=0,y=g-1;(b!==0||x<C)&&y!==-1;y--,x++)b+=256*l[y]>>>0,l[y]=b%s>>>0,b=b/s>>>0;if(b!==0)throw new Error("Non-zero carry");C=x,h++}for(var v=g-C;v!==g&&l[v]===0;)v++;for(var A=a.repeat(u);v<g;++v)A+=r.charAt(l[v]);return A}i(P,"encode");function K(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var u=0;if(d[u]!==" "){for(var C=0,h=0;d[u]===a;)C++,u++;for(var w=(d.length-u)*p+1>>>0,g=new Uint8Array(w);d[u];){var l=t[d.charCodeAt(u)];if(l===255)return;for(var b=0,x=w-1;(l!==0||b<h)&&x!==-1;x--,b++)l+=s*g[x]>>>0,g[x]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");h=b,u++}if(d[u]!==" "){for(var y=w-h;y!==w&&g[y]===0;)y++;for(var v=new Uint8Array(C+(w-y)),A=C;y!==w;)v[A++]=g[y++];return v}}}i(K,"decodeUnsafe");function Q(d){var u=K(d);if(u)return u;throw new Error(`Non-${e} character`)}return i(Q,"decode"),{encode:P,decodeUnsafe:K,decode:Q}}i(re,"base");var ne=re,oe=ne,B=oe;var pe=new Uint8Array(0);var F=i(r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},"coerce");var I=class I{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};i(I,"Encoder");var E=I,O=class O{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return J(this,e)}};i(O,"Decoder");var S=O,T=class T{constructor(e){this.decoders=e}or(e){return J(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};i(T,"ComposedDecoder");var D=T,J=i((r,e)=>new D({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),"or"),z=class z{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new E(e,t,n),this.decoder=new S(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};i(z,"Codec");var M=z,R=i(({name:r,prefix:e,encode:t,decode:n})=>new M(r,e,t,n),"from"),L=i(({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=B(t,e);return R({prefix:r,name:e,encode:n,decode:i(f=>F(o(f)),"decode")})},"baseX"),ie=i((r,e,t,n)=>{let o={};for(let m=0;m<e.length;++m)o[e[m]]=m;let f=r.length;for(;r[f-1]==="=";)--f;let c=new Uint8Array(f*t/8|0),s=0,a=0,p=0;for(let m=0;m<f;++m){let P=o[r[m]];if(P===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|P,s+=t,s>=8&&(s-=8,c[p++]=255&a>>s)}if(s>=t||255&a<<8-s)throw new SyntaxError("Unexpected end of data");return c},"decode"),se=i((r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,f="",c=0,s=0;for(let a=0;a<r.length;++a)for(s=s<<8|r[a],c+=8;c>t;)c-=t,f+=e[o&s>>c];if(c&&(f+=e[o&s<<t-c]),n)for(;f.length*t&7;)f+="=";return f},"encode"),V=i(({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>R({prefix:e,name:r,encode(o){return se(o,n,t)},decode(o){return ie(o,n,t,r)}}),"rfc4648");var N=L({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),be=L({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ce=V({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ve=V({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),j=V({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pe=V({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var k=i(async(r,e)=>{let t=r.id.keypair();if(!t)throw new Error("Cannot get default verification method: unable to get subject keypair");let n=await r.invoke.resolveDid(e),o=i(s=>{if(!(!s||typeof s=="string")){if(s.publicKeyJwk?.x)return s.publicKeyJwk.x;if(s.publicKeyMultibase){let a=N.decode(s.publicKeyMultibase),p=a[0]===237&&a[1]===1?a.slice(2):a;return j.encode(p).slice(1)}if(s.publicKeyBase58){let a=N.baseDecode(s.publicKeyBase58);return j.encode(a).slice(1)}}},"toX"),f=typeof n=="string"?void 0:n?.verificationMethod?.find(s=>o(s)===t.x);return typeof f!="string"&&f?.id||await r.invoke.didToVerificationMethod(e)},"getDefaultVerificationMethod");var X=i(r=>async(e,t,n={})=>{let o=e.id.keypair();if(!o)throw new Error("Cannot issue credential: Could not get subject keypair");let s=(Array.isArray(t["@context"])?t["@context"]:[t["@context"]]).some(p=>typeof p=="string"&&(p.includes("/ns/credentials/v2")||p.includes("/credentials/v2")))&&n.type==="Ed25519Signature2018"?"Ed25519Signature2020":n.type??(n.proofFormat==="jwt"?void 0:"DataIntegrityProof"),a={proofPurpose:"assertionMethod",...n,...s?{type:s}:{}};if(a.type==="DataIntegrityProof"&&!a.cryptosuite&&(a.cryptosuite="eddsa-rdfc-2022"),!("verificationMethod"in a)){let p=typeof t.issuer=="string"?t.issuer:t.issuer.id;a.verificationMethod=await k(e,p)}return e.debug?.("Signing with these options",{credential:t,options:a,kp:o}),r.invoke.issueCredential(t,a,o)},"issueCredential");var $=i(r=>async(e,t,n={})=>{let o={...n};return o.checks||(o.checks=["proof"],t.credentialStatus&&o.checks.push("credentialStatus"),t.credentialSchema&&o.checks.push("credentialSchema")),r.invoke.verifyCredential(t,o)},"verifyCredential");var q=i(r=>async(e,t,n={})=>{let o=e.id.keypair();if(!o)throw new Error("Cannot issue credential: Could not get subject keypair");let s=(Array.isArray(t["@context"])?t["@context"]:[t["@context"]]).some(p=>typeof p=="string"&&(p.includes("/ns/credentials/v2")||p.includes("/credentials/v2")))&&n.type==="Ed25519Signature2018"?"Ed25519Signature2020":n.type??"Ed25519Signature2020",a={...n.proofFormat==="jwt"?{}:{proofPurpose:"assertionMethod",type:s},...n};return"verificationMethod"in a||(a.verificationMethod=await k(e,e.id.did())),r.invoke.issuePresentation(t,a,o)},"issuePresentation");var Z=i(r=>async(e,t,n={})=>r.invoke.verifyPresentation(t,n),"verifyPresentation");var G=i(r=>({name:"VC",displayName:"VC",description:"Handles the infrastructure needed to issue and verify credentials and presentations",methods:{issueCredential:X(r),verifyCredential:$(r),issuePresentation:q(r),verifyPresentation:Z(r),getTestVc:i((e,t="did:example:d23dd687a7dc6787646f2eb98d0")=>{let n=e.id.did();return{"@context":["https://www.w3.org/ns/credentials/v2"],id:`urn:uuid:${crypto.randomUUID()}`,type:["VerifiableCredential"],issuer:n,validFrom:new Date().toISOString(),credentialSubject:{id:t}}},"getTestVc"),getTestVp:i(async(e,t)=>{let n=t||await e.invoke.issueCredential(e.invoke.getTestVc()),o=e.id.did();return{"@context":["https://www.w3.org/ns/credentials/v2"],type:["VerifiablePresentation"],holder:o,verifiableCredential:n}},"getTestVp"),getDidAuthVp:i(async(e,t={})=>{let n=e.id.did(),o={"@context":["https://www.w3.org/ns/credentials/v2"],type:["VerifiablePresentation"],holder:n};return e.invoke.issuePresentation(o,{proofPurpose:"authentication",...t})},"getDidAuthVp")}}),"getVCPlugin");
|
|
2
|
-
//# sourceMappingURL=vc-plugin.cjs.production.min.
|
|
2
|
+
//# sourceMappingURL=vc-plugin.cjs.production.min.cjs.map
|
package/package.json
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learncard/vc-plugin",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
6
7
|
"module": "./dist/vc-plugin.esm.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/vc-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
|
"multiformats": "^11.0.1",
|
|
34
|
-
"@learncard/
|
|
35
|
-
"@learncard/
|
|
36
|
-
"@learncard/
|
|
47
|
+
"@learncard/didkit-plugin": "^1.9.2",
|
|
48
|
+
"@learncard/types": "5.17.2",
|
|
49
|
+
"@learncard/core": "9.4.22"
|
|
37
50
|
},
|
|
38
51
|
"sideEffects": false,
|
|
39
52
|
"scripts": {
|
|
40
|
-
"build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.
|
|
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\""
|
package/dist/index.js
DELETED
|
File without changes
|
|
File without changes
|