did-jwt-vc
Advanced tools
Comparing version 0.1.0-dev.0 to 0.1.0-dev.1
@@ -1,33 +0,5 @@ | ||
import { Signer } from 'did-jwt'; | ||
interface VC { | ||
'@context': string[]; | ||
type: string[]; | ||
credentialSubject: object; | ||
} | ||
interface VerifiableCredentialPayload { | ||
sub: string; | ||
nbf: number; | ||
vc: VC; | ||
aud?: string; | ||
exp?: number; | ||
jti?: string; | ||
} | ||
interface VP { | ||
'@context': string[]; | ||
type: string[]; | ||
verifiableCredential: string[]; | ||
} | ||
interface PresentationPayload { | ||
vp: VP; | ||
aud?: string; | ||
exp?: number; | ||
jti?: string; | ||
} | ||
interface Issuer { | ||
did: string; | ||
signer: Signer; | ||
} | ||
import { VerifiableCredentialPayload, Issuer, PresentationPayload } from './types'; | ||
export * from './VerifiableCredential'; | ||
export declare function createVerifiableCredential(payload: VerifiableCredentialPayload, issuer: Issuer): Promise<string>; | ||
export declare function createPresentation(payload: PresentationPayload, issuer: Issuer): Promise<string>; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
var e=require("did-jwt");exports.createPresentation=function(r,t){try{return 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 Promise.resolve(e.createJWT(r,{issuer:t.did,signer:t.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}}; | ||
var e=require("did-jwt"),t=/^did:([a-zA-Z0-9_]+):([:[a-zA-Z0-9_.-]+)(\/[^#]*)?(#.*)?$/,i=/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+\/=]*$/,r="https://www.w3.org/2018/credentials/v1",n="VerifiableCredential";function s(e){if(!e.match(t))throw new TypeError('"'+e+'" is not a valid DID format')}function o(e){if(!e.match(i))throw new TypeError('"'+e+'" is not a valid JWT format')}function u(e){if(!(Number.isInteger(e)&&e<1e11))throw new TypeError('"'+e+'" is not a unix timestamp in seconds')}function c(e){if(e.length<1||!e.includes(r))throw new TypeError('@context is missing default context "'+r+'"')}function a(e){if(e.length<1||!e.includes(n))throw new TypeError('type is missing default "'+n+'"')}function l(e){if(0===Object.keys(e).length)throw new TypeError("credentialSubject must not be empty")}var d=function(){this._context=["https://www.w3.org/2018/credentials/v1"],this._type=["VerifiableCredential"]},h={signer:{configurable:!0},subject:{configurable:!0},issuer:{configurable:!0},credentialSubject:{configurable:!0},context:{configurable:!0},type:{configurable:!0},validFrom:{configurable:!0},expires:{configurable:!0},id:{configurable:!0}};d.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 e={sub:this._subject,vc:{"@context":this._context,type:this._type,credentialSubject:this._credentialSubject}};return this._validFrom&&(e.nbf=this._validFrom),this._expires&&(e.exp=this._expires),this._id&&(e.jti=this._id),f(e,{did:this._issuer,signer:this._signer})}catch(e){return Promise.reject(e)}},d.prototype.setSigner=function(e){return this._signer=e,this},d.prototype.setSubject=function(e){return s(e),this._subject=e,this},d.prototype.setIssuer=function(e){return s(e),this._issuer=e,this},d.prototype.setCredentialSubject=function(e){return l(e),this._credentialSubject=e,this},d.prototype.addContext=function(e){return this._context.push(e),this},d.prototype.addType=function(e){return this._type.push(e),this},d.prototype.setValidFrom=function(e){return u(e),this._validFrom=e,this},d.prototype.setExpires=function(e){return u(e),this._expires=e,this},d.prototype.expiresIn=function(e){if(void 0===this._validFrom)throw new Error("validFrom must be set before calling expiresIn()");return this.setExpires(this._validFrom+e),this},d.prototype.setId=function(e){return this._id=e,this},h.signer.get=function(){return this._signer},h.subject.get=function(){return this._subject},h.issuer.get=function(){return this._issuer},h.credentialSubject.get=function(){return this._credentialSubject},h.context.get=function(){return this._context},h.type.get=function(){return this._type},h.validFrom.get=function(){return this._validFrom},h.expires.get=function(){return this._expires},h.id.get=function(){return this._id},Object.defineProperties(d.prototype,h);var f=function(t,i){try{return function(e){s(e.sub),c(e.vc["@context"]),a(e.vc.type),l(e.vc.credentialSubject),e.nbf&&u(e.nbf),e.exp&&u(e.exp)}(t),s(i.did),Promise.resolve(e.createJWT(t,{issuer:i.did,signer:i.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}};exports.createPresentation=function(t,i){try{return function(e){if(c(e.vp["@context"]),a(e.vp.type),e.vp.verifiableCredential.length<1)throw new TypeError("vp.verifiableCredential must not be empty");for(var t=0,i=e.vp.verifiableCredential;t<i.length;t+=1)o(i[t]);e.aud&&s(e.aud),e.exp&&u(e.exp)}(t),s(i.did),Promise.resolve(e.createJWT(t,{issuer:i.did,signer:i.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}},exports.createVerifiableCredential=f,exports.VerifiableCredentialBuilder=d; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("did-jwt")):"function"==typeof define&&define.amd?define(["exports","did-jwt"],r):r(e.didJwtVc={},e.didJwt)}(this,function(e,r){e.createPresentation=function(e,t){try{return Promise.resolve(r.createJWT(e,{issuer:t.did,signer:t.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}},e.createVerifiableCredential=function(e,t){try{return Promise.resolve(r.createJWT(e,{issuer:t.did,signer:t.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}}}); | ||
!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 i=/^did:([a-zA-Z0-9_]+):([:[a-zA-Z0-9_.-]+)(\/[^#]*)?(#.*)?$/,r=/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+\/=]*$/,n="https://www.w3.org/2018/credentials/v1",s="VerifiableCredential";function o(e){if(!e.match(i))throw new TypeError('"'+e+'" is not a valid DID format')}function u(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 d(e){if(e.length<1||!e.includes(n))throw new TypeError('@context is missing default context "'+n+'"')}function a(e){if(e.length<1||!e.includes(s))throw new TypeError('type is missing default "'+s+'"')}function f(e){if(0===Object.keys(e).length)throw new TypeError("credentialSubject must not be empty")}var l=function(){this._context=["https://www.w3.org/2018/credentials/v1"],this._type=["VerifiableCredential"]},h={signer:{configurable:!0},subject:{configurable:!0},issuer:{configurable:!0},credentialSubject:{configurable:!0},context:{configurable:!0},type:{configurable:!0},validFrom:{configurable:!0},expires:{configurable:!0},id:{configurable:!0}};l.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 e={sub:this._subject,vc:{"@context":this._context,type:this._type,credentialSubject:this._credentialSubject}};return this._validFrom&&(e.nbf=this._validFrom),this._expires&&(e.exp=this._expires),this._id&&(e.jti=this._id),p(e,{did:this._issuer,signer:this._signer})}catch(e){return Promise.reject(e)}},l.prototype.setSigner=function(e){return this._signer=e,this},l.prototype.setSubject=function(e){return o(e),this._subject=e,this},l.prototype.setIssuer=function(e){return o(e),this._issuer=e,this},l.prototype.setCredentialSubject=function(e){return f(e),this._credentialSubject=e,this},l.prototype.addContext=function(e){return this._context.push(e),this},l.prototype.addType=function(e){return this._type.push(e),this},l.prototype.setValidFrom=function(e){return c(e),this._validFrom=e,this},l.prototype.setExpires=function(e){return c(e),this._expires=e,this},l.prototype.expiresIn=function(e){if(void 0===this._validFrom)throw new Error("validFrom must be set before calling expiresIn()");return this.setExpires(this._validFrom+e),this},l.prototype.setId=function(e){return this._id=e,this},h.signer.get=function(){return this._signer},h.subject.get=function(){return this._subject},h.issuer.get=function(){return this._issuer},h.credentialSubject.get=function(){return this._credentialSubject},h.context.get=function(){return this._context},h.type.get=function(){return this._type},h.validFrom.get=function(){return this._validFrom},h.expires.get=function(){return this._expires},h.id.get=function(){return this._id},Object.defineProperties(l.prototype,h);var p=function(e,i){try{return function(e){o(e.sub),d(e.vc["@context"]),a(e.vc.type),f(e.vc.credentialSubject),e.nbf&&c(e.nbf),e.exp&&c(e.exp)}(e),o(i.did),Promise.resolve(t.createJWT(e,{issuer:i.did,signer:i.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}};e.createPresentation=function(e,i){try{return function(e){if(d(e.vp["@context"]),a(e.vp.type),e.vp.verifiableCredential.length<1)throw new TypeError("vp.verifiableCredential must not be empty");for(var t=0,i=e.vp.verifiableCredential;t<i.length;t+=1)u(i[t]);e.aud&&o(e.aud),e.exp&&c(e.exp)}(e),o(i.did),Promise.resolve(t.createJWT(e,{issuer:i.did,signer:i.signer,alg:"ES256K-R"}))}catch(e){return Promise.reject(e)}},e.createVerifiableCredential=p,e.VerifiableCredentialBuilder=l}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "did-jwt-vc", | ||
"version": "0.1.0-dev.0", | ||
"version": "0.1.0-dev.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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
86972
29
881
0
4