did-jwt-vc
Advanced tools
Comparing version 0.1.0 to 0.1.1
import { VerifiableCredentialPayload, Issuer, PresentationPayload } from './types'; | ||
export * from './VerifiableCredential'; | ||
import { DIDDocument } from 'did-resolver'; | ||
interface Resolvable { | ||
resolve: (did: string) => Promise<DIDDocument | null>; | ||
} | ||
export declare function createVerifiableCredential(payload: VerifiableCredentialPayload, issuer: Issuer): Promise<string>; | ||
export declare function createPresentation(payload: PresentationPayload, issuer: Issuer): Promise<string>; | ||
export declare function verifyCredential(vc: string): Promise<any>; | ||
export declare function verifyCredential(vc: string, resolver: Resolvable): Promise<any>; | ||
export declare function verifyPresentation(presentation: string, resolver: Resolvable): Promise<any>; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
var t=require("did-jwt"),e=/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+\/=]*$/,i="https://www.w3.org/2018/credentials/v1",r="VerifiableCredential";function n(t){if(!t.match(e))throw new TypeError('"'+t+'" is not a valid JWT format')}function s(t){if(!(Number.isInteger(t)&&t<1e11))throw new TypeError('"'+t+'" is not a unix timestamp in seconds')}function o(t){if(t.length<1||!t.includes(i))throw new TypeError('@context is missing default context "'+i+'"')}function c(t){if(t.length<1||!t.includes(r))throw new TypeError('type is missing default "'+r+'"')}var u=function(){this._context=["https://www.w3.org/2018/credentials/v1"],this._type=["VerifiableCredential"]},a={signer:{configurable:!0},subject:{configurable:!0},issuer:{configurable:!0},credentialSubject:{configurable:!0},context:{configurable:!0},type:{configurable:!0},validFrom:{configurable:!0},validUntil:{configurable:!0},id:{configurable:!0}};u.prototype.build=function(){try{if(void 0===this._signer)throw new Error("signer must be set before calling build()");if(void 0===this._issuer)throw new Error("issuer must be set before calling build()");if(void 0===this._subject)throw new Error("subject must be set before calling build()");if(void 0===this._credentialSubject)throw new Error("credentialSubject must be set before calling build()");var t={sub:this._subject,vc:{"@context":this._context,type:this._type,credentialSubject:this._credentialSubject}};return this._validFrom&&(t.nbf=this._validFrom),this._validUntil?t.exp=this._validUntil:t.nbf&&this._expiresIn&&(t.exp=t.nbf+this._expiresIn),this._id&&(t.jti=this._id),l(t,{did:this._issuer,signer:this._signer})}catch(t){return Promise.reject(t)}},u.prototype.setSigner=function(t){return this._signer=t,this},u.prototype.setSubject=function(t){return this._subject=t,this},u.prototype.setIssuer=function(t){return this._issuer=t,this},u.prototype.setCredentialSubject=function(t){return this._credentialSubject=t,this},u.prototype.addContext=function(t){return this._context.push(t),this},u.prototype.addType=function(t){return this._type.push(t),this},u.prototype.setValidFrom=function(t){return this._validFrom=t,this},u.prototype.setValidUntil=function(t){return this._validUntil=t,this},u.prototype.expiresIn=function(t){return this._expiresIn=t,this},u.prototype.setId=function(t){return this._id=t,this},a.signer.get=function(){return this._signer},a.subject.get=function(){return this._subject},a.issuer.get=function(){return this._issuer},a.credentialSubject.get=function(){return this._credentialSubject},a.context.get=function(){return this._context},a.type.get=function(){return this._type},a.validFrom.get=function(){return this._validFrom},a.validUntil.get=function(){return this._validUntil},a.id.get=function(){return this._id},Object.defineProperties(u.prototype,a);var l=function(e,i){try{return f(e),Promise.resolve(t.createJWT(e,{issuer:i.did,signer:i.signer,alg:"ES256K-R"}))}catch(t){return Promise.reject(t)}};function f(t){o(t.vc["@context"]),c(t.vc.type),function(e){if(0===Object.keys(t.vc.credentialSubject).length)throw new TypeError("credentialSubject must not be empty")}(),t.nbf&&s(t.nbf),t.exp&&s(t.exp)}exports.verifyCredential=function(e){try{return Promise.resolve(t.verifyJWT(e)).then(function(t){var e;return(e=t.payload)instanceof Object&&e.sub&&e.iss&&e.claim&&e.iat&&(t.payload=function(t){var e=t.iat,n=t.nbf,s=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&-1===e.indexOf(r)&&(i[r]=t[r]);return i}(t,["iat","nbf","claim"]);return Object.assign({},s,{nbf:n||e,vc:{"@context":[i],type:[r],credentialSubject:t.claim}})}(t.payload)),f(t.payload),t})}catch(t){return Promise.reject(t)}},exports.createPresentation=function(e,i){try{return function(t){if(o(t.vp["@context"]),c(t.vp.type),t.vp.verifiableCredential.length<1)throw new TypeError("vp.verifiableCredential must not be empty");for(var e=0,i=t.vp.verifiableCredential;e<i.length;e+=1)n(i[e]);t.exp&&s(t.exp)}(e),Promise.resolve(t.createJWT(e,{issuer:i.did,signer:i.signer,alg:"ES256K-R"}))}catch(t){return Promise.reject(t)}},exports.createVerifiableCredential=l,exports.VerifiableCredentialBuilder=u; | ||
var e=require("did-jwt"),r=/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+\/=]*$/,t="https://www.w3.org/2018/credentials/v1",n="VerifiableCredential";function i(e){if(!e.match(r))throw new TypeError('"'+e+'" is not a valid JWT format')}function o(e){if(!(Number.isInteger(e)&&e<1e11))throw new TypeError('"'+e+'" is not a unix timestamp in seconds')}function a(e){if(e.length<1||!e.includes(t))throw new TypeError('@context is missing default context "'+t+'"')}function c(e){if(e.length<1||!e.includes(n))throw new TypeError('type is missing default "'+n+'"')}function s(e){a(e.vc["@context"]),c(e.vc.type),function(r){if(0===Object.keys(e.vc.credentialSubject).length)throw new TypeError("credentialSubject must not be empty")}(),e.nbf&&o(e.nbf),e.exp&&o(e.exp)}function l(e){if(a(e.vp["@context"]),c(e.vp.type),e.vp.verifiableCredential.length<1)throw new TypeError("vp.verifiableCredential must not be empty");for(var r=0,t=e.vp.verifiableCredential;r<t.length;r+=1)i(t[r]);e.exp&&o(e.exp)}exports.verifyPresentation=function(r,t){try{return Promise.resolve(e.verifyJWT(r,{resolver:t})).then(function(e){return l(e.payload),e})}catch(e){return Promise.reject(e)}},exports.verifyCredential=function(r,i){try{return Promise.resolve(e.verifyJWT(r,{resolver:i})).then(function(e){var r;return(r=e.payload)instanceof Object&&r.sub&&r.iss&&r.claim&&r.iat&&(e.payload=function(e){var r=e.iat,i=e.nbf,o=e.vc,a=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&-1===r.indexOf(n)&&(t[n]=e[n]);return t}(e,["iat","nbf","claim","vc"]),c=Object.assign({},a,{nbf:i||r,vc:{"@context":[t],type:[n],credentialSubject:e.claim}});return o&&(e.issVc=o),c}(e.payload)),s(e.payload),e})}catch(e){return Promise.reject(e)}},exports.createPresentation=function(r,t){try{return l(r),Promise.resolve(e.createJWT(r,{issuer:t.did,signer:t.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}},exports.createVerifiableCredential=function(r,t){try{return s(r),Promise.resolve(e.createJWT(r,{issuer:t.did,signer:t.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("did-jwt")):"function"==typeof define&&define.amd?define(["exports","did-jwt"],e):e(t.didJwtVc={},t.didJwt)}(this,function(t,e){var i=/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+\/=]*$/,r="https://www.w3.org/2018/credentials/v1",n="VerifiableCredential";function o(t){if(!t.match(i))throw new TypeError('"'+t+'" is not a valid JWT format')}function s(t){if(!(Number.isInteger(t)&&t<1e11))throw new TypeError('"'+t+'" is not a unix timestamp in seconds')}function c(t){if(t.length<1||!t.includes(r))throw new TypeError('@context is missing default context "'+r+'"')}function u(t){if(t.length<1||!t.includes(n))throw new TypeError('type is missing default "'+n+'"')}var a=function(){this._context=["https://www.w3.org/2018/credentials/v1"],this._type=["VerifiableCredential"]},l={signer:{configurable:!0},subject:{configurable:!0},issuer:{configurable:!0},credentialSubject:{configurable:!0},context:{configurable:!0},type:{configurable:!0},validFrom:{configurable:!0},validUntil:{configurable:!0},id:{configurable:!0}};a.prototype.build=function(){try{if(void 0===this._signer)throw new Error("signer must be set before calling build()");if(void 0===this._issuer)throw new Error("issuer must be set before calling build()");if(void 0===this._subject)throw new Error("subject must be set before calling build()");if(void 0===this._credentialSubject)throw new Error("credentialSubject must be set before calling build()");var t={sub:this._subject,vc:{"@context":this._context,type:this._type,credentialSubject:this._credentialSubject}};return this._validFrom&&(t.nbf=this._validFrom),this._validUntil?t.exp=this._validUntil:t.nbf&&this._expiresIn&&(t.exp=t.nbf+this._expiresIn),this._id&&(t.jti=this._id),f(t,{did:this._issuer,signer:this._signer})}catch(t){return Promise.reject(t)}},a.prototype.setSigner=function(t){return this._signer=t,this},a.prototype.setSubject=function(t){return this._subject=t,this},a.prototype.setIssuer=function(t){return this._issuer=t,this},a.prototype.setCredentialSubject=function(t){return this._credentialSubject=t,this},a.prototype.addContext=function(t){return this._context.push(t),this},a.prototype.addType=function(t){return this._type.push(t),this},a.prototype.setValidFrom=function(t){return this._validFrom=t,this},a.prototype.setValidUntil=function(t){return this._validUntil=t,this},a.prototype.expiresIn=function(t){return this._expiresIn=t,this},a.prototype.setId=function(t){return this._id=t,this},l.signer.get=function(){return this._signer},l.subject.get=function(){return this._subject},l.issuer.get=function(){return this._issuer},l.credentialSubject.get=function(){return this._credentialSubject},l.context.get=function(){return this._context},l.type.get=function(){return this._type},l.validFrom.get=function(){return this._validFrom},l.validUntil.get=function(){return this._validUntil},l.id.get=function(){return this._id},Object.defineProperties(a.prototype,l);var f=function(t,i){try{return d(t),Promise.resolve(e.createJWT(t,{issuer:i.did,signer:i.signer,alg:"ES256K-R"}))}catch(t){return Promise.reject(t)}};function d(t){c(t.vc["@context"]),u(t.vc.type),function(e){if(0===Object.keys(t.vc.credentialSubject).length)throw new TypeError("credentialSubject must not be empty")}(),t.nbf&&s(t.nbf),t.exp&&s(t.exp)}t.verifyCredential=function(t){try{return Promise.resolve(e.verifyJWT(t)).then(function(t){var e;return(e=t.payload)instanceof Object&&e.sub&&e.iss&&e.claim&&e.iat&&(t.payload=function(t){var e=t.iat,i=t.nbf,o=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&-1===e.indexOf(r)&&(i[r]=t[r]);return i}(t,["iat","nbf","claim"]);return Object.assign({},o,{nbf:i||e,vc:{"@context":[r],type:[n],credentialSubject:t.claim}})}(t.payload)),d(t.payload),t})}catch(t){return Promise.reject(t)}},t.createPresentation=function(t,i){try{return function(t){if(c(t.vp["@context"]),u(t.vp.type),t.vp.verifiableCredential.length<1)throw new TypeError("vp.verifiableCredential must not be empty");for(var e=0,i=t.vp.verifiableCredential;e<i.length;e+=1)o(i[e]);t.exp&&s(t.exp)}(t),Promise.resolve(e.createJWT(t,{issuer:i.did,signer:i.signer,alg:"ES256K-R"}))}catch(t){return Promise.reject(t)}},t.createVerifiableCredential=f,t.VerifiableCredentialBuilder=a}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("did-jwt")):"function"==typeof define&&define.amd?define(["exports","did-jwt"],t):t(e.didJwtVc={},e.didJwt)}(this,function(e,t){var r=/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+\/=]*$/,n="https://www.w3.org/2018/credentials/v1",i="VerifiableCredential";function o(e){if(!e.match(r))throw new TypeError('"'+e+'" is not a valid JWT format')}function c(e){if(!(Number.isInteger(e)&&e<1e11))throw new TypeError('"'+e+'" is not a unix timestamp in seconds')}function a(e){if(e.length<1||!e.includes(n))throw new TypeError('@context is missing default context "'+n+'"')}function s(e){if(e.length<1||!e.includes(i))throw new TypeError('type is missing default "'+i+'"')}function f(e){a(e.vc["@context"]),s(e.vc.type),function(t){if(0===Object.keys(e.vc.credentialSubject).length)throw new TypeError("credentialSubject must not be empty")}(),e.nbf&&c(e.nbf),e.exp&&c(e.exp)}function u(e){if(a(e.vp["@context"]),s(e.vp.type),e.vp.verifiableCredential.length<1)throw new TypeError("vp.verifiableCredential must not be empty");for(var t=0,r=e.vp.verifiableCredential;t<r.length;t+=1)o(r[t]);e.exp&&c(e.exp)}e.verifyPresentation=function(e,r){try{return Promise.resolve(t.verifyJWT(e,{resolver:r})).then(function(e){return u(e.payload),e})}catch(e){return Promise.reject(e)}},e.verifyCredential=function(e,r){try{return Promise.resolve(t.verifyJWT(e,{resolver:r})).then(function(e){var t;return(t=e.payload)instanceof Object&&t.sub&&t.iss&&t.claim&&t.iat&&(e.payload=function(e){var t=e.iat,r=e.nbf,o=e.vc,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&-1===t.indexOf(n)&&(r[n]=e[n]);return r}(e,["iat","nbf","claim","vc"]),a=Object.assign({},c,{nbf:r||t,vc:{"@context":[n],type:[i],credentialSubject:e.claim}});return o&&(e.issVc=o),a}(e.payload)),f(e.payload),e})}catch(e){return Promise.reject(e)}},e.createPresentation=function(e,r){try{return u(e),Promise.resolve(t.createJWT(e,{issuer:r.did,signer:r.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}},e.createVerifiableCredential=function(e,r){try{return f(e),Promise.resolve(t.createJWT(e,{issuer:r.did,signer:r.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "did-jwt-vc", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Create and verify W3C Verifiable Credentials and Presentations in JWT format", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68470
24
538
1