Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

did-jwt-vc

Package Overview
Dependencies
Maintainers
4
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

did-jwt-vc - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

68

lib/index.modern.js

@@ -1,2 +0,2 @@

import { decodeJWT, createJWT, verifyJWT } from 'did-jwt';
import { decodeJWT, JWT_ERROR, createJWT, verifyJWT } from 'did-jwt';

@@ -627,2 +627,30 @@ function _extends() {

/**
* Error prefixes used for known verification failure cases related to the
* {@link https://www.w3.org/TR/vc-data-model/ | Verifiable Credential data model }
*/
const VC_ERROR = {
/**
* Thrown when the credential or presentation being verified does not conform to the data model defined by
* {@link https://www.w3.org/TR/vc-data-model/ | the spec}
*/
SCHEMA_ERROR: 'schema_error',
/**
* Thrown when the input is not a JWT string
*/
FORMAT_ERROR: 'format_error',
/**
* Thrown when verifying a presentation where `challenge` and/or `domain` don't match the expected values.
*/
AUTH_ERROR: 'auth_error'
};
/**
* Known validation or verification error prefixes.
*/
const VC_JWT_ERROR = _extends({}, VC_ERROR, JWT_ERROR); // eslint-disable-next-line @typescript-eslint/no-explicit-any
function isDateObject(input) {

@@ -634,5 +662,3 @@ return input && !isNaN(input) && Object.prototype.toString.call(input) === '[object Date]';

if (typeof value === 'string' && !value.match(JWT_FORMAT)) {
throw new TypeError(`${"format_error"
/* VC_ERROR.FORMAT_ERROR */
}: "${value}" is not a valid JWT format`);
throw new TypeError(`${VC_ERROR.FORMAT_ERROR}: "${value}" is not a valid JWT format`);
}

@@ -650,5 +676,3 @@ } // The main scenario we want to guard against is having a timestamp in milliseconds

if (!(Number.isInteger(value) && value < 100000000000)) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: "${value}" is not a unix timestamp in seconds`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: "${value}" is not a unix timestamp in seconds`);
}

@@ -658,5 +682,3 @@ } else if (typeof value === 'string') {

} else if (!isDateObject(value)) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: "${value}" is not a valid time`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: "${value}" is not a valid time`);
}

@@ -668,5 +690,3 @@ }

if (input.length < 1 || input.indexOf(DEFAULT_CONTEXT) === -1) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: @context is missing default context "${DEFAULT_CONTEXT}"`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: @context is missing default context "${DEFAULT_CONTEXT}"`);
}

@@ -678,5 +698,3 @@ }

if (input.length < 1 || input.indexOf(DEFAULT_VC_TYPE) === -1) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: type is missing default "${DEFAULT_VC_TYPE}"`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: type is missing default "${DEFAULT_VC_TYPE}"`);
}

@@ -688,5 +706,3 @@ }

if (input.length < 1 || input.indexOf(DEFAULT_VP_TYPE) === -1) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: type is missing default "${DEFAULT_VP_TYPE}"`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: type is missing default "${DEFAULT_VP_TYPE}"`);
}

@@ -696,5 +712,3 @@ }

if (Object.keys(value).length === 0) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: credentialSubject must not be empty`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: credentialSubject must not be empty`);
}

@@ -869,5 +883,3 @@ }

if (options.challenge && options.challenge !== payload.nonce) {
throw new Error(`${"auth_error"
/* VC_ERROR.AUTH_ERROR */
}: Presentation does not contain the mandatory challenge (JWT: nonce) for : ${options.challenge}`);
throw new Error(`${VC_ERROR.AUTH_ERROR}: Presentation does not contain the mandatory challenge (JWT: nonce) for : ${options.challenge}`);
}

@@ -885,5 +897,3 @@

if (typeof matchedAudience === 'undefined') {
throw new Error(`${"auth_error"
/* VC_ERROR.AUTH_ERROR */
}: Presentation does not contain the mandatory domain (JWT: aud) for : ${options.domain}`);
throw new Error(`${VC_ERROR.AUTH_ERROR}: Presentation does not contain the mandatory domain (JWT: aud) for : ${options.domain}`);
}

@@ -930,3 +940,3 @@ }

export { createVerifiableCredentialJwt, createVerifiablePresentationJwt, normalizeCredential, normalizePresentation, transformCredentialInput, transformPresentationInput, validateCredentialPayload, validateJwtCredentialPayload, validateJwtPresentationPayload, validatePresentationPayload, verifyCredential, verifyPresentation, verifyPresentationPayloadOptions };
export { VC_ERROR, VC_JWT_ERROR, createVerifiableCredentialJwt, createVerifiablePresentationJwt, normalizeCredential, normalizePresentation, transformCredentialInput, transformPresentationInput, validateCredentialPayload, validateJwtCredentialPayload, validateJwtPresentationPayload, validatePresentationPayload, verifyCredential, verifyPresentation, verifyPresentationPayloadOptions };
//# sourceMappingURL=index.modern.js.map

@@ -1,2 +0,2 @@

import { decodeJWT, verifyJWT, createJWT } from 'did-jwt';
import { decodeJWT, JWT_ERROR, verifyJWT, createJWT } from 'did-jwt';

@@ -602,2 +602,32 @@ const JWT_ALG = 'ES256K';

/**
* Error prefixes used for known verification failure cases related to the
* {@link https://www.w3.org/TR/vc-data-model/ | Verifiable Credential data model }
*/
const VC_ERROR = {
/**
* Thrown when the credential or presentation being verified does not conform to the data model defined by
* {@link https://www.w3.org/TR/vc-data-model/ | the spec}
*/
SCHEMA_ERROR: 'schema_error',
/**
* Thrown when the input is not a JWT string
*/
FORMAT_ERROR: 'format_error',
/**
* Thrown when verifying a presentation where `challenge` and/or `domain` don't match the expected values.
*/
AUTH_ERROR: 'auth_error'
};
/**
* Known validation or verification error prefixes.
*/
const VC_JWT_ERROR = { ...VC_ERROR,
...JWT_ERROR
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
function isDateObject(input) {

@@ -609,5 +639,3 @@ return input && !isNaN(input) && Object.prototype.toString.call(input) === '[object Date]';

if (typeof value === 'string' && !value.match(JWT_FORMAT)) {
throw new TypeError(`${"format_error"
/* VC_ERROR.FORMAT_ERROR */
}: "${value}" is not a valid JWT format`);
throw new TypeError(`${VC_ERROR.FORMAT_ERROR}: "${value}" is not a valid JWT format`);
}

@@ -625,5 +653,3 @@ } // The main scenario we want to guard against is having a timestamp in milliseconds

if (!(Number.isInteger(value) && value < 100000000000)) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: "${value}" is not a unix timestamp in seconds`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: "${value}" is not a unix timestamp in seconds`);
}

@@ -633,5 +659,3 @@ } else if (typeof value === 'string') {

} else if (!isDateObject(value)) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: "${value}" is not a valid time`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: "${value}" is not a valid time`);
}

@@ -643,5 +667,3 @@ }

if (input.length < 1 || input.indexOf(DEFAULT_CONTEXT) === -1) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: @context is missing default context "${DEFAULT_CONTEXT}"`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: @context is missing default context "${DEFAULT_CONTEXT}"`);
}

@@ -653,5 +675,3 @@ }

if (input.length < 1 || input.indexOf(DEFAULT_VC_TYPE) === -1) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: type is missing default "${DEFAULT_VC_TYPE}"`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: type is missing default "${DEFAULT_VC_TYPE}"`);
}

@@ -663,5 +683,3 @@ }

if (input.length < 1 || input.indexOf(DEFAULT_VP_TYPE) === -1) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: type is missing default "${DEFAULT_VP_TYPE}"`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: type is missing default "${DEFAULT_VP_TYPE}"`);
}

@@ -671,5 +689,3 @@ }

if (Object.keys(value).length === 0) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: credentialSubject must not be empty`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: credentialSubject must not be empty`);
}

@@ -903,5 +919,3 @@ }

if (options.challenge && options.challenge !== payload.nonce) {
throw new Error(`${"auth_error"
/* VC_ERROR.AUTH_ERROR */
}: Presentation does not contain the mandatory challenge (JWT: nonce) for : ${options.challenge}`);
throw new Error(`${VC_ERROR.AUTH_ERROR}: Presentation does not contain the mandatory challenge (JWT: nonce) for : ${options.challenge}`);
}

@@ -919,5 +933,3 @@

if (typeof matchedAudience === 'undefined') {
throw new Error(`${"auth_error"
/* VC_ERROR.AUTH_ERROR */
}: Presentation does not contain the mandatory domain (JWT: aud) for : ${options.domain}`);
throw new Error(`${VC_ERROR.AUTH_ERROR}: Presentation does not contain the mandatory domain (JWT: aud) for : ${options.domain}`);
}

@@ -927,3 +939,3 @@ }

export { createVerifiableCredentialJwt, createVerifiablePresentationJwt, normalizeCredential, normalizePresentation, transformCredentialInput, transformPresentationInput, validateCredentialPayload, validateJwtCredentialPayload, validateJwtPresentationPayload, validatePresentationPayload, verifyCredential, verifyPresentation, verifyPresentationPayloadOptions };
export { VC_ERROR, VC_JWT_ERROR, createVerifiableCredentialJwt, createVerifiablePresentationJwt, normalizeCredential, normalizePresentation, transformCredentialInput, transformPresentationInput, validateCredentialPayload, validateJwtCredentialPayload, validateJwtPresentationPayload, validatePresentationPayload, verifyCredential, verifyPresentation, verifyPresentationPayloadOptions };
//# sourceMappingURL=index.module.js.map

@@ -605,2 +605,32 @@ (function (global, factory) {

/**
* Error prefixes used for known verification failure cases related to the
* {@link https://www.w3.org/TR/vc-data-model/ | Verifiable Credential data model }
*/
const VC_ERROR = {
/**
* Thrown when the credential or presentation being verified does not conform to the data model defined by
* {@link https://www.w3.org/TR/vc-data-model/ | the spec}
*/
SCHEMA_ERROR: 'schema_error',
/**
* Thrown when the input is not a JWT string
*/
FORMAT_ERROR: 'format_error',
/**
* Thrown when verifying a presentation where `challenge` and/or `domain` don't match the expected values.
*/
AUTH_ERROR: 'auth_error'
};
/**
* Known validation or verification error prefixes.
*/
const VC_JWT_ERROR = { ...VC_ERROR,
...didJwt.JWT_ERROR
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
function isDateObject(input) {

@@ -612,5 +642,3 @@ return input && !isNaN(input) && Object.prototype.toString.call(input) === '[object Date]';

if (typeof value === 'string' && !value.match(JWT_FORMAT)) {
throw new TypeError(`${"format_error"
/* VC_ERROR.FORMAT_ERROR */
}: "${value}" is not a valid JWT format`);
throw new TypeError(`${VC_ERROR.FORMAT_ERROR}: "${value}" is not a valid JWT format`);
}

@@ -628,5 +656,3 @@ } // The main scenario we want to guard against is having a timestamp in milliseconds

if (!(Number.isInteger(value) && value < 100000000000)) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: "${value}" is not a unix timestamp in seconds`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: "${value}" is not a unix timestamp in seconds`);
}

@@ -636,5 +662,3 @@ } else if (typeof value === 'string') {

} else if (!isDateObject(value)) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: "${value}" is not a valid time`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: "${value}" is not a valid time`);
}

@@ -646,5 +670,3 @@ }

if (input.length < 1 || input.indexOf(DEFAULT_CONTEXT) === -1) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: @context is missing default context "${DEFAULT_CONTEXT}"`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: @context is missing default context "${DEFAULT_CONTEXT}"`);
}

@@ -656,5 +678,3 @@ }

if (input.length < 1 || input.indexOf(DEFAULT_VC_TYPE) === -1) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: type is missing default "${DEFAULT_VC_TYPE}"`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: type is missing default "${DEFAULT_VC_TYPE}"`);
}

@@ -666,5 +686,3 @@ }

if (input.length < 1 || input.indexOf(DEFAULT_VP_TYPE) === -1) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: type is missing default "${DEFAULT_VP_TYPE}"`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: type is missing default "${DEFAULT_VP_TYPE}"`);
}

@@ -674,5 +692,3 @@ }

if (Object.keys(value).length === 0) {
throw new TypeError(`${"schema_error"
/* VC_ERROR.SCHEMA_ERROR */
}: credentialSubject must not be empty`);
throw new TypeError(`${VC_ERROR.SCHEMA_ERROR}: credentialSubject must not be empty`);
}

@@ -906,5 +922,3 @@ }

if (options.challenge && options.challenge !== payload.nonce) {
throw new Error(`${"auth_error"
/* VC_ERROR.AUTH_ERROR */
}: Presentation does not contain the mandatory challenge (JWT: nonce) for : ${options.challenge}`);
throw new Error(`${VC_ERROR.AUTH_ERROR}: Presentation does not contain the mandatory challenge (JWT: nonce) for : ${options.challenge}`);
}

@@ -922,5 +936,3 @@

if (typeof matchedAudience === 'undefined') {
throw new Error(`${"auth_error"
/* VC_ERROR.AUTH_ERROR */
}: Presentation does not contain the mandatory domain (JWT: aud) for : ${options.domain}`);
throw new Error(`${VC_ERROR.AUTH_ERROR}: Presentation does not contain the mandatory domain (JWT: aud) for : ${options.domain}`);
}

@@ -930,2 +942,4 @@ }

exports.VC_ERROR = VC_ERROR;
exports.VC_JWT_ERROR = VC_JWT_ERROR;
exports.createVerifiableCredentialJwt = createVerifiableCredentialJwt;

@@ -932,0 +946,0 @@ exports.createVerifiablePresentationJwt = createVerifiablePresentationJwt;

import { JwtCredentialSubject, DateType } from './types';
import { VerifiableCredential } from '.';
import { JWT_ERROR } from 'did-jwt';
/**

@@ -8,3 +7,3 @@ * Error prefixes used for known verification failure cases related to the

*/
export declare const enum VC_ERROR {
export declare const VC_ERROR: {
/**

@@ -14,16 +13,36 @@ * Thrown when the credential or presentation being verified does not conform to the data model defined by

*/
SCHEMA_ERROR = "schema_error",
SCHEMA_ERROR: string;
/**
* Thrown when the input is not a JWT string
*/
FORMAT_ERROR = "format_error",
FORMAT_ERROR: string;
/**
* Thrown when verifying a presentation where `challenge` and/or `domain` don't match the expected values.
*/
AUTH_ERROR = "auth_error"
}
AUTH_ERROR: string;
};
/**
* Known validation or verification error prefixes.
*/
export declare type VC_JWT_ERROR = VC_ERROR | JWT_ERROR;
export declare const VC_JWT_ERROR: {
INVALID_JWT: string;
INVALID_AUDIENCE: string;
INVALID_SIGNATURE: string;
NO_SUITABLE_KEYS: string;
NOT_SUPPORTED: string;
RESOLVER_ERROR: string;
/**
* Thrown when the credential or presentation being verified does not conform to the data model defined by
* {@link https://www.w3.org/TR/vc-data-model/ | the spec}
*/
SCHEMA_ERROR: string;
/**
* Thrown when the input is not a JWT string
*/
FORMAT_ERROR: string;
/**
* Thrown when verifying a presentation where `challenge` and/or `domain` don't match the expected values.
*/
AUTH_ERROR: string;
};
export declare function validateJwtFormat(value: VerifiableCredential): void;

@@ -30,0 +49,0 @@ export declare function validateTimestamp(value: number | DateType): void;

{
"name": "did-jwt-vc",
"version": "3.0.1",
"version": "3.1.0",
"description": "Create and verify W3C Verifiable Credentials and Presentations in JWT format",

@@ -39,3 +39,3 @@ "type": "module",

"dependencies": {
"did-jwt": "^6.5.0",
"did-jwt": "^6.6.0",
"did-resolver": "^4.0.0"

@@ -42,0 +42,0 @@ },

@@ -11,3 +11,3 @@ import { DEFAULT_CONTEXT, DEFAULT_VC_TYPE, DEFAULT_VP_TYPE, JWT_FORMAT } from './types'

*/
export const enum VC_ERROR {
export const VC_ERROR = {
/**

@@ -17,3 +17,3 @@ * Thrown when the credential or presentation being verified does not conform to the data model defined by

*/
SCHEMA_ERROR = 'schema_error',
SCHEMA_ERROR: 'schema_error',

@@ -23,3 +23,3 @@ /**

*/
FORMAT_ERROR = 'format_error',
FORMAT_ERROR: 'format_error',

@@ -29,3 +29,3 @@ /**

*/
AUTH_ERROR = 'auth_error',
AUTH_ERROR: 'auth_error',
}

@@ -36,3 +36,3 @@

*/
export type VC_JWT_ERROR = VC_ERROR | JWT_ERROR
export const VC_JWT_ERROR = { ...VC_ERROR, ...JWT_ERROR }

@@ -39,0 +39,0 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc