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

@unumid/server-sdk

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unumid/server-sdk - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

2

build/verifier/sendRequest.js

@@ -69,2 +69,3 @@ "use strict";

var uuid = helpers_1.getUUID();
var id = helpers_1.getUUID();
// any/all default values must be set before signing, or signature will always fail to verify

@@ -87,2 +88,3 @@ var now = new Date();

uuid: uuid,
id: id,
verifier: verifier

@@ -89,0 +91,0 @@ };

10

build/verifier/verifyNoPresentationHelper.js

@@ -58,3 +58,3 @@ "use strict";

exports.validateNoPresentationParams = function (noPresentation) {
var type = noPresentation.type, proof = noPresentation.proof, presentationRequestUuid = noPresentation.presentationRequestUuid, verifiableCredential = noPresentation.verifiableCredential, verifierDid = noPresentation.verifierDid;
var type = noPresentation.type, proof = noPresentation.proof, presentationRequestId = noPresentation.presentationRequestId, verifiableCredential = noPresentation.verifiableCredential, verifierDid = noPresentation.verifierDid;
if (!type) {

@@ -72,7 +72,7 @@ throw new error_1.CustError(400, 'Invalid Presentation: type is required.');

}
if (!presentationRequestUuid) {
throw new error_1.CustError(400, 'Invalid Presentation: presentationRequestUuid is required.');
if (!presentationRequestId) {
throw new error_1.CustError(400, 'Invalid Presentation: presentationRequestId is required.');
}
if (typeof presentationRequestUuid !== 'string') {
throw new error_1.CustError(400, 'Invalid presentationRequestUuid: must be a string.');
if (typeof presentationRequestId !== 'string') {
throw new error_1.CustError(400, 'Invalid presentationRequestId: must be a string.');
}

@@ -79,0 +79,0 @@ if (verifiableCredential || helpers_1.isArrayNotEmpty(verifiableCredential)) {

@@ -76,3 +76,3 @@ "use strict";

var context = presentation['@context'];
var type = presentation.type, proof = presentation.proof, presentationRequestUuid = presentation.presentationRequestUuid, verifierDid = presentation.verifierDid;
var type = presentation.type, proof = presentation.proof, presentationRequestId = presentation.presentationRequestId, verifierDid = presentation.verifierDid;
// const retObj: JSONObj = {};

@@ -89,4 +89,4 @@ // validate required fields

}
if (!presentationRequestUuid) {
throw new error_1.CustError(400, 'Invalid Presentation: presentationRequestUuid is required.');
if (!presentationRequestId) {
throw new error_1.CustError(400, 'Invalid Presentation: presentationRequestId is required.');
}

@@ -179,4 +179,4 @@ // if (!verifiableCredential || isArrayEmpty(verifiableCredential)) {

// verify the presentation request uuid match
if (presentationRequest && presentationRequest.presentationRequest.uuid !== presentation.presentationRequestUuid) {
throw new error_1.CustError(400, "presentation request uuid provided, " + presentationRequest.presentationRequest.uuid + ", does not match the presentationRequestUuid that the presentation was in response to, " + presentation.presentationRequestUuid + ".");
if (presentationRequest && presentationRequest.presentationRequest.id !== presentation.presentationRequestId) {
throw new error_1.CustError(400, "presentation request id provided, " + presentationRequest.presentationRequest.id + ", does not match the presentationRequestId that the presentation was in response to, " + presentation.presentationRequestId + ".");
}

@@ -183,0 +183,0 @@ if (!(presentationRequest && presentationRequest.presentationRequest)) return [3 /*break*/, 2];

@@ -160,3 +160,3 @@ "use strict";

var context = presentation['@context'];
var type = presentation.type, verifiableCredential = presentation.verifiableCredential, proof = presentation.proof, presentationRequestUuid = presentation.presentationRequestUuid, verifierDid = presentation.verifierDid;
var type = presentation.type, verifiableCredential = presentation.verifiableCredential, proof = presentation.proof, presentationRequestId = presentation.presentationRequestId, verifierDid = presentation.verifierDid;
var retObj = {};

@@ -173,4 +173,4 @@ // validate required fields

}
if (!presentationRequestUuid) {
throw new error_1.CustError(400, 'Invalid Presentation: presentationRequestUuid is required.');
if (!presentationRequestId) {
throw new error_1.CustError(400, 'Invalid Presentation: presentationRequestId is required.');
}

@@ -177,0 +177,0 @@ if (!verifiableCredential || helpers_1.isArrayEmpty(verifiableCredential)) {

{
"name": "@unumid/server-sdk",
"version": "2.1.1",
"version": "2.1.2",
"main": "build/index.js",

@@ -47,3 +47,3 @@ "repository": "git@github.com:UnumID/Server-SDK-TypeScript.git",

"@unumid/library-crypto": "https://github.com/UnumID/Library-Crypto-TypeScript.git#v1.2.0",
"@unumid/types": "https://github.com/UnumID/types.git#2.1.1",
"@unumid/types": "2.1.3",
"@unumid/types-v1": "https://github.com/UnumID/types.git#1.5.1",

@@ -50,0 +50,0 @@ "dotenv": "^8.2.0",

@@ -0,1 +1,3 @@

**Note**: This branch was a modification that was necessary as part of version 2 of the sdk. It was made after version 3 had already been merged into main. Thus it will live as this special branch for perpetuity or until the use of the sdk version 2 is no more.
This SDK combines the functionality of an [**Issuer**](#issuer) and [**Verifier**](#verifier) entities to work with UnumID's SaaS. For necessary account creation and API keys please email admin@unum.id.

@@ -2,0 +4,0 @@ ## Distribution

@@ -29,2 +29,3 @@ import { configData } from '../config';

const uuid = getUUID();
const id = getUUID();

@@ -49,2 +50,3 @@ // any/all default values must be set before signing, or signature will always fail to verify

uuid,
id,
verifier

@@ -51,0 +53,0 @@ };

@@ -24,3 +24,3 @@

proof,
presentationRequestUuid,
presentationRequestId,
verifiableCredential,

@@ -46,8 +46,8 @@ verifierDid

if (!presentationRequestUuid) {
throw new CustError(400, 'Invalid Presentation: presentationRequestUuid is required.');
if (!presentationRequestId) {
throw new CustError(400, 'Invalid Presentation: presentationRequestId is required.');
}
if (typeof presentationRequestUuid !== 'string') {
throw new CustError(400, 'Invalid presentationRequestUuid: must be a string.');
if (typeof presentationRequestId !== 'string') {
throw new CustError(400, 'Invalid presentationRequestId: must be a string.');
}

@@ -54,0 +54,0 @@

@@ -28,3 +28,3 @@

const context = presentation['@context'];
const { type, proof, presentationRequestUuid, verifierDid } = presentation;
const { type, proof, presentationRequestId, verifierDid } = presentation;
// const retObj: JSONObj = {};

@@ -45,4 +45,4 @@

if (!presentationRequestUuid) {
throw new CustError(400, 'Invalid Presentation: presentationRequestUuid is required.');
if (!presentationRequestId) {
throw new CustError(400, 'Invalid Presentation: presentationRequestId is required.');
}

@@ -143,4 +143,4 @@

// verify the presentation request uuid match
if (presentationRequest && presentationRequest.presentationRequest.uuid !== presentation.presentationRequestUuid) {
throw new CustError(400, `presentation request uuid provided, ${presentationRequest.presentationRequest.uuid}, does not match the presentationRequestUuid that the presentation was in response to, ${presentation.presentationRequestUuid}.`);
if (presentationRequest && presentationRequest.presentationRequest.id !== presentation.presentationRequestId) {
throw new CustError(400, `presentation request id provided, ${presentationRequest.presentationRequest.id}, does not match the presentationRequestId that the presentation was in response to, ${presentation.presentationRequestId}.`);
}

@@ -147,0 +147,0 @@

@@ -142,3 +142,3 @@ import { omit } from 'lodash';

const context = presentation['@context'];
const { type, verifiableCredential, proof, presentationRequestUuid, verifierDid } = presentation;
const { type, verifiableCredential, proof, presentationRequestId, verifierDid } = presentation;
let retObj: JSONObj = {};

@@ -159,4 +159,4 @@

if (!presentationRequestUuid) {
throw new CustError(400, 'Invalid Presentation: presentationRequestUuid is required.');
if (!presentationRequestId) {
throw new CustError(400, 'Invalid Presentation: presentationRequestId is required.');
}

@@ -163,0 +163,0 @@

@@ -46,3 +46,3 @@ import { omit } from 'lodash';

const dummyNoPresentation: NoPresentation = {
presentationRequestUuid: 'd5cc3673-d72f-45fa-bc87-36c305f8d0a5',
presentationRequestId: 'd5cc3673-d72f-45fa-bc87-36c305f8d0a5',
type: [

@@ -64,3 +64,3 @@ 'NoPresentation',

const dummyNoPresentationWithoutType = omit(dummyNoPresentation, 'type') as NoPresentation;
const dummyNoPresentationWithoutRequestUuid = omit(dummyNoPresentation, 'presentationRequestUuid') as NoPresentation;
const dummyNoPresentationWithoutRequestId = omit(dummyNoPresentation, 'presentationRequestId') as NoPresentation;
const dummyNoPresentationWithoutHolder = omit(dummyNoPresentation, 'holder') as NoPresentation;

@@ -71,3 +71,3 @@ const dummyNoPresentationWithoutProof = omit(dummyNoPresentation, 'proof') as NoPresentation;

const dummyNoPresentationBadTypeKeywordMissing = { ...dummyNoPresentation, type: ['No No Presenation'] } as NoPresentation;
const dummyNoPresentationBadRequestUuid = { ...dummyNoPresentation, presentationRequestUuid: {} } as NoPresentation;
const dummyNoPresentationBadRequestId = { ...dummyNoPresentation, presentationRequestId: {} } as NoPresentation;
const dummyNoPresentationBadHolder = { ...dummyNoPresentation, holder: {} } as NoPresentation;

@@ -156,9 +156,9 @@ const dummyNoPresentationBadProof = { ...dummyNoPresentation, proof: {} } as NoPresentation;

it('returns a 400 status code with a descriptive error presentationRequestUuid if holder is missing', async () => {
it('returns a 400 status code with a descriptive error presentationRequestId if holder is missing', async () => {
try {
await callVerifyNoPresentation(dummyNoPresentationWithoutRequestUuid, verifier, authHeader);
await callVerifyNoPresentation(dummyNoPresentationWithoutRequestId, verifier, authHeader);
fail();
} catch (e) {
expect(e.code).toEqual(400);
expect(e.message).toEqual('Invalid Presentation: presentationRequestUuid is required.');
expect(e.message).toEqual('Invalid Presentation: presentationRequestId is required.');
}

@@ -176,8 +176,8 @@ });

it('returns a 400 status code with a descriptive error message if presentationRequestUuid is invalid', async () => {
it('returns a 400 status code with a descriptive error message if presentationRequestId, is invalid', async () => {
try {
await callVerifyNoPresentation(dummyNoPresentationBadRequestUuid, verifier, authHeader);
await callVerifyNoPresentation(dummyNoPresentationBadRequestId, verifier, authHeader);
} catch (e) {
expect(e.code).toEqual(400);
expect(e.message).toEqual('Invalid presentationRequestUuid: must be a string.');
expect(e.message).toEqual('Invalid presentationRequestId: must be a string.');
}

@@ -184,0 +184,0 @@ });

@@ -82,3 +82,3 @@ import { NoPresentation, Presentation, VerifiedStatus, UnumDto, CustError } from '../../src/index';

const callVerifyEncryptedPresentation = (context, type, verifiableCredential, presentationRequestUuid, proof, verifier, auth = '', presentationRequest?): Promise<UnumDto<DecryptedPresentation>> => {
const callVerifyEncryptedPresentation = (context, type, verifiableCredential, presentationRequestId, proof, verifier, auth = '', presentationRequest?): Promise<UnumDto<DecryptedPresentation>> => {
const presentation: Presentation = {

@@ -88,3 +88,4 @@ '@context': context,

verifiableCredential,
presentationRequestUuid,
// presentationRequestUuid,
presentationRequestId,
verifierDid: verifier,

@@ -151,2 +152,3 @@ proof,

const presentationRequestUuid = '0cebee3b-3295-4ef6-a4d6-7dfea413b3aa';
const presentationRequestId = '0cebee3b-3295-4ef6-a4d6-7dfea413b3ab';
const verifier = 'did:unum:f2054199-1069-4337-a588-83d099e79d44';

@@ -156,2 +158,3 @@ const presentationRequest: PresentationRequestDto = {

uuid: presentationRequestUuid,
id: presentationRequestId,
createdAt: new Date('2021-04-07T01:21:41.059Z'),

@@ -207,2 +210,3 @@ updatedAt: new Date('2021-04-07T01:21:41.059Z'),

presentationRequestUuid,
presentationRequestId,
presentationRequest,

@@ -219,3 +223,3 @@ proof,

const { context, type, verifiableCredentials, presentationRequestUuid, proof, authHeader, verifier } = populateMockData();
const { context, type, verifiableCredentials, presentationRequestId, proof, authHeader, verifier } = populateMockData();

@@ -232,3 +236,3 @@ beforeAll(async () => {

mockMakeNetworkRequest.mockResolvedValue({ body: { success: true }, headers: dummyResponseHeaders });
response = await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
response = await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
verStatus = response.body.isVerified;

@@ -283,3 +287,3 @@ });

mockVerifyCredential.mockResolvedValue({ authToken: undefined, body: true });
response = await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
response = await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
expect(response.authToken).toBeUndefined();

@@ -292,3 +296,3 @@ });

let verStatus: boolean;
const { context, type, verifiableCredentials, presentationRequestUuid, proof, authHeader, verifier } = populateMockData();
const { context, type, verifiableCredentials, presentationRequestId, proof, authHeader, verifier } = populateMockData();

@@ -305,3 +309,3 @@ beforeAll(async () => {

verifiableCredentials[0].proof.verificationMethod = proof.verificationMethod;
response = await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
response = await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
verStatus = response.body.isVerified;

@@ -334,3 +338,3 @@ });

mockGetDIDDoc.mockResolvedValueOnce({ body: dummyDidDocWithoutKeys, headers: dummyResponseHeaders });
const response = await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
const response = await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
expect(response.body.isVerified).toBe(false);

@@ -344,3 +348,3 @@ expect(response.body.message).toBe('Public key not found for the DID associated with the proof.verificationMethod');

try {
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -354,3 +358,3 @@ } catch (e) {

describe('verifyEncryptedPresentation - Validation Failures', () => {
const { context, type, verifiableCredentials, presentationRequestUuid, proof, authHeader, verifier, presentationRequest } = populateMockData();
const { context, type, verifiableCredentials, presentationRequestId, proof, authHeader, verifier, presentationRequest } = populateMockData();

@@ -398,3 +402,3 @@ it('returns a 400 status code with a descriptive error message when encryptedPresentation is missing', async () => {

it('returns a 400 status code with a descriptive error message when if presentationRequest uuid provided does not match is the presentation presentationRequestUuid.', async () => {
it('returns a 400 status code with a descriptive error message when if presentationRequest id provided does not match is the presentation presentationRequestId.', async () => {
try {

@@ -405,3 +409,3 @@ await callVerifyEncryptedPresentation(context, type, verifiableCredentials, 'uuid:123', proof, verifier, authHeader, presentationRequest);

expect(e.code).toBe(400);
expect(e.message).toBe(`presentation request uuid provided, ${presentationRequest.presentationRequest.uuid}, does not match the presentationRequestUuid that the presentation was in response to, uuid:123.`);
expect(e.message).toBe(`presentation request id provided, ${presentationRequest.presentationRequest.id}, does not match the presentationRequestId that the presentation was in response to, uuid:123.`);
}

@@ -412,7 +416,7 @@ });

describe('verifyEncryptedPresentation - Decrypted presentation validation Failures', () => {
const { context, type, verifiableCredentials, presentationRequestUuid, proof, authHeader, verifier } = populateMockData();
const { context, type, verifiableCredentials, presentationRequestId, proof, authHeader, verifier } = populateMockData();
it('returns a 400 status code with a descriptive error message when @context is missing', async () => {
try {
await callVerifyEncryptedPresentation('', type, verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation('', type, verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -427,3 +431,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, '', verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, '', verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -438,3 +442,3 @@ } catch (e) {

// try {
// await callVerifyEncryptedPresentation(context, type, undefined, presentationRequestUuid, proof, verifier, authHeader);
// await callVerifyEncryptedPresentation(context, type, undefined, presentationRequestId, proof, verifier, authHeader);
// fail();

@@ -447,3 +451,3 @@ // } catch (e) {

it('returns a 400 status code with a descriptive error message when presentationRequestUuid is missing', async () => {
it('returns a 400 status code with a descriptive error message when presentationRequestId is missing', async () => {
try {

@@ -454,3 +458,3 @@ await callVerifyEncryptedPresentation(context, type, verifiableCredentials, '', proof, verifier, authHeader);

expect(e.code).toBe(400);
expect(e.message).toBe('Invalid Presentation: presentationRequestUuid is required.');
expect(e.message).toBe('Invalid Presentation: presentationRequestId is required.');
}

@@ -461,3 +465,3 @@ });

try {
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, '', verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, '', verifier, authHeader);
fail();

@@ -472,3 +476,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation('https://www.w3.org/2018/credentials/v1', type, verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation('https://www.w3.org/2018/credentials/v1', type, verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -483,3 +487,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation([], type, verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation([], type, verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -494,3 +498,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, 'VerifiablePresentation', verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, 'VerifiablePresentation', verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -505,3 +509,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, [], verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, [], verifiableCredentials, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -516,3 +520,3 @@ } catch (e) {

// try {
// await callVerifyEncryptedPresentation(context, type, undefined, presentationRequestUuid, proof, verifier, authHeader);
// await callVerifyEncryptedPresentation(context, type, undefined, presentationRequestId, proof, verifier, authHeader);
// fail();

@@ -527,3 +531,3 @@ // } catch (e) {

// try {
// await callVerifyEncryptedPresentation(context, type, [], presentationRequestUuid, proof, verifier, authHeader);
// await callVerifyEncryptedPresentation(context, type, [], presentationRequestId, proof, verifier, authHeader);
// fail();

@@ -538,3 +542,3 @@ // } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, proof, verifier, '');
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, proof, verifier, '');
fail();

@@ -549,3 +553,3 @@ } catch (e) {

let response: JSONObj, preReq: JSONObj;
const { context, type, verifiableCredentials, presentationRequestUuid, proof, authHeader, verifier } = populateMockData();
const { context, type, verifiableCredentials, presentationRequestId, proof, authHeader, verifier } = populateMockData();

@@ -556,3 +560,3 @@ let cred;

try {
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -568,3 +572,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -580,3 +584,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -592,3 +596,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -604,3 +608,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -616,3 +620,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -628,3 +632,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -640,3 +644,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader);
fail();

@@ -651,3 +655,3 @@ } catch (e) {

describe('verifyEncryptedPresentation - presentationRequestSignature check', () => {
const { context, type, verifiableCredential, presentationRequestUuid, proof, authHeader, verifier } = populateMockData();
const { context, type, verifiableCredential, presentationRequestId, proof, authHeader, verifier } = populateMockData();
it('returns response body with proper validation error message if presentation request signature can not be verified', async () => {

@@ -664,3 +668,3 @@ const dummyDidDoc = await makeDummyDidDocument({ id: dummyNoPresentation.holder });

verifiableCredential,
presentationRequestUuid,
presentationRequestId,
verifierDid: verifier,

@@ -675,3 +679,3 @@ proof,

presentationRequest: {
uuid: presentationRequestUuid,
id: presentationRequestId,
proof: { signatureValue: 'signature' }

@@ -683,3 +687,2 @@ },

};
// const response = await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, proof, verifier, authHeader);
const response = await verifyPresentation(authHeader, encryptedPresentation, verifier, dummyRsaPrivateKey, fakeBadPresentationRequestDto);

@@ -693,3 +696,3 @@

describe('verifyEncryptedPresentation - Validation for proof object', () => {
const { context, type, verifiableCredentials, presentationRequestUuid, proof, authHeader, verifier } = populateMockData();
const { context, type, verifiableCredentials, presentationRequestId, proof, authHeader, verifier } = populateMockData();

@@ -699,3 +702,3 @@ it('returns a 400 status code with a descriptive error message when created is missing', async () => {

try {
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, invalidProof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, invalidProof, verifier, authHeader);
fail();

@@ -711,3 +714,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, invalidProof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, invalidProof, verifier, authHeader);
fail();

@@ -723,3 +726,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, invalidProof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, invalidProof, verifier, authHeader);
fail();

@@ -735,3 +738,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, invalidProof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, invalidProof, verifier, authHeader);
fail();

@@ -747,3 +750,3 @@ } catch (e) {

try {
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestUuid, invalidProof, verifier, authHeader);
await callVerifyEncryptedPresentation(context, type, verifiableCredentials, presentationRequestId, invalidProof, verifier, authHeader);
fail();

@@ -750,0 +753,0 @@ } catch (e) {

@@ -48,3 +48,3 @@ // import * as utilLib from '../../src/utils';

const callVerifyPresentation = (context, type, verifiableCredential, presentationRequestUuid, proof, verifier, auth = '', credentialRequests): Promise<UnumDto<VerifiedStatus>> => {
const callVerifyPresentation = (context, type, verifiableCredential, presentationRequestId, proof, verifier, auth = '', credentialRequests): Promise<UnumDto<VerifiedStatus>> => {
const presentation: Presentation = {

@@ -54,3 +54,3 @@ '@context': context,

verifiableCredential,
presentationRequestUuid,
presentationRequestId,
verifierDid: verifier,

@@ -120,2 +120,3 @@ proof,

const presentationRequestUuid = '0cebee3b-3295-4ef6-a4d6-7dfea413b3aa';
const presentationRequestId = '0cebee3b-3295-4ef6-a4d6-7dfea413b3ab';
const invalidProof: JSONObj = {

@@ -135,3 +136,3 @@ created: '2020-09-03T18:50:52.105Z',

'@context': ['https://www.w3.org/2018/credentials/v1'],
presentationRequestUuid,
presentationRequestId,
verifiableCredential: [verifiableCredential],

@@ -170,2 +171,3 @@ type: ['VerifiablePresentation']

presentationRequestUuid,
presentationRequestId,
proof,

@@ -184,3 +186,3 @@ invalidProof,

const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestUuid, proof, authHeader, verifier, credentialRequests } = populateMockData();
const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestId, proof, authHeader, verifier, credentialRequests } = populateMockData();

@@ -197,3 +199,3 @@ beforeAll(async () => {

mockMakeNetworkRequest.mockResolvedValue({ body: { success: true }, headers: dummyResponseHeaders });
response = await callVerifyPresentation(context, type, verifiableCredentialString, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
response = await callVerifyPresentation(context, type, verifiableCredentialString, presentationRequestId, proof, verifier, authHeader, credentialRequests);
verStatus = response.body.isVerified;

@@ -249,3 +251,3 @@ });

mockDoVerify.mockReturnValueOnce(true);
response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
expect(response.authToken).toBeUndefined();

@@ -259,3 +261,3 @@ });

const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestUuid, proof, authHeader, verifier, credentialRequests } = populateMockData();
const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestId, proof, authHeader, verifier, credentialRequests } = populateMockData();

@@ -272,3 +274,3 @@ beforeAll(async () => {

mockMakeNetworkRequest.mockResolvedValue({ body: { success: true }, headers: dummyResponseHeaders });
response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
verStatus = response.body.isVerified;

@@ -324,3 +326,3 @@ });

mockDoVerify.mockReturnValueOnce(true);
response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
expect(response.authToken).toBeUndefined();

@@ -333,3 +335,3 @@ });

let verStatus: boolean;
const { context, type, verifiableCredential, presentationRequestUuid, proof, invalidProof, authHeader, verifier, credentialRequests } = populateMockData();
const { context, type, verifiableCredential, presentationRequestId, proof, invalidProof, authHeader, verifier, credentialRequests } = populateMockData();

@@ -355,3 +357,3 @@ beforeAll(async () => {

mockGetDIDDoc.mockResolvedValueOnce({ body: dummySubjectDidDoc, headers: dummyResponseHeaders });
response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, invalidProof, verifier, authHeader, credentialRequests);
response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, invalidProof, verifier, authHeader, credentialRequests);
verStatus = response.body.isVerified;

@@ -377,3 +379,3 @@ expect(mockGetDIDDoc).toBeCalled();

mockGetDIDDoc.mockResolvedValueOnce({ body: dummyDidDocWithoutKeys, headers: dummyResponseHeaders });
const response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
const response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
expect(response.body.isVerified).toBe(false);

@@ -387,3 +389,3 @@ expect(response.body.message).toBe('Public key not found for the DID associated with the proof.verificationMethod');

try {
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -407,3 +409,3 @@ } catch (e) {

verifiableCredential,
presentationRequestUuid,
presentationRequestId,
verifierDid: verifier,

@@ -415,3 +417,3 @@ proof,

// const response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
// const response = await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
expect(response.body.isVerified).toBe(false);

@@ -423,7 +425,7 @@ expect(response.body.message).toBe(`The presentation was meant for verifier, ${presentation.verifierDid}, not the provided verifier, fakeVerifierDid.`);

describe('verifyPresentationHelper - Validation Failures', () => {
const { context, type, verifiableCredential, presentationRequestUuid, proof, authHeader, verifier, credentialRequests } = populateMockData();
const { context, type, verifiableCredential, presentationRequestId, proof, authHeader, verifier, credentialRequests } = populateMockData();
it('returns a 400 status code with a descriptive error message when @context is missing', async () => {
try {
await callVerifyPresentation('', type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation('', type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -438,3 +440,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, '', verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, '', verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -449,3 +451,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, '', presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, '', presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -458,3 +460,3 @@ } catch (e) {

it('returns a 400 status code with a descriptive error message when presentationRequestUuid is missing', async () => {
it('returns a 400 status code with a descriptive error message when presentationRequestId is missing', async () => {
try {

@@ -465,3 +467,3 @@ await callVerifyPresentation(context, type, verifiableCredential, '', proof, verifier, authHeader, credentialRequests);

expect(e.code).toBe(400);
expect(e.message).toBe('Invalid Presentation: presentationRequestUuid is required.');
expect(e.message).toBe('Invalid Presentation: presentationRequestId is required.');
}

@@ -472,3 +474,3 @@ });

try {
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, '', verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, '', verifier, authHeader, credentialRequests);
fail();

@@ -483,3 +485,3 @@ } catch (e) {

try {
await callVerifyPresentation('https://www.w3.org/2018/credentials/v1', type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation('https://www.w3.org/2018/credentials/v1', type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -494,3 +496,3 @@ } catch (e) {

try {
await callVerifyPresentation([], type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation([], type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -505,3 +507,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, 'VerifiablePresentation', verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, 'VerifiablePresentation', verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -516,3 +518,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, [], verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, [], verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -527,3 +529,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, 'verifiableCredential', presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, 'verifiableCredential', presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -538,3 +540,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, undefined, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, undefined, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -549,3 +551,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, proof, verifier, '', credentialRequests);
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, proof, verifier, '', credentialRequests);
fail();

@@ -560,3 +562,3 @@ } catch (e) {

let response: JSONObj, preReq: JSONObj;
const { context, type, verifiableCredential, presentationRequestUuid, proof, authHeader, verifier, credentialRequests } = populateMockData();
const { context, type, verifiableCredential, presentationRequestId, proof, authHeader, verifier, credentialRequests } = populateMockData();

@@ -567,3 +569,3 @@ let cred;

try {
await callVerifyPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -579,3 +581,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -591,3 +593,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -603,3 +605,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -615,3 +617,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -627,3 +629,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -639,3 +641,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -651,3 +653,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, cred, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, cred, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -662,4 +664,4 @@ } catch (e) {

describe('verifyPresentation credential matches requests', () => {
// let context, type, cred, presentationRequestUuid, proof, verifier, authHeader, credentialRequests;
// const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestUuid, proof, authHeader, verifier, credentialRequests } = populateMockData();
// let context, type, cred, presentationRequestId, proof, verifier, authHeader, credentialRequests;
// const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestId, proof, authHeader, verifier, credentialRequests } = populateMockData();
beforeAll(async () => {

@@ -675,12 +677,12 @@ // const dummySubjectDidDoc = await makeDummyDidDocument();

// mockMakeNetworkRequest.mockResolvedValue({ body: { success: true }, headers: dummyResponseHeaders });
// response = await callVerifyPresentation(context, type, verifiableCredentialString, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
// response = await callVerifyPresentation(context, type, verifiableCredentialString, presentationRequestId, proof, verifier, authHeader, credentialRequests);
// verStatus = response.body.isVerified;
// const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestUuid, proof, authHeader, verifier, credentialRequests } = populateMockData();
// const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestId, proof, authHeader, verifier, credentialRequests } = populateMockData();
});
it('Response code should be ' + 400 + ' when credentials do not meet credential request type requirements', async () => {
const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestUuid, proof, authHeader, verifier, credentialRequests } = populateMockData();
const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestId, proof, authHeader, verifier, credentialRequests } = populateMockData();
verifiableCredential[0].type = ['VerifiableCredential', 'AddressCredential'];
try {
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -694,6 +696,6 @@ } catch (e) {

it('Response code should be ' + 400 + ' when credentials do not meet credential request issuer requirements', async () => {
const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestUuid, proof, authHeader, verifier, credentialRequests } = populateMockData();
const { context, type, verifiableCredential, verifiableCredentialString, presentationRequestId, proof, authHeader, verifier, credentialRequests } = populateMockData();
verifiableCredential[0].issuer = dummyIssuerDid;
try {
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, proof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, proof, verifier, authHeader, credentialRequests);
fail();

@@ -708,3 +710,3 @@ } catch (e) {

describe('verifyPresentationHelper - Validation for proof object', () => {
const { context, type, verifiableCredential, presentationRequestUuid, proof, authHeader, verifier, credentialRequests } = populateMockData();
const { context, type, verifiableCredential, presentationRequestId, proof, authHeader, verifier, credentialRequests } = populateMockData();

@@ -714,3 +716,3 @@ it('returns a 400 status code with a descriptive error message when created is missing', async () => {

try {
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, invalidProof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, invalidProof, verifier, authHeader, credentialRequests);
fail();

@@ -726,3 +728,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, invalidProof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, invalidProof, verifier, authHeader, credentialRequests);
fail();

@@ -738,3 +740,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, invalidProof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, invalidProof, verifier, authHeader, credentialRequests);
fail();

@@ -750,3 +752,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, invalidProof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, invalidProof, verifier, authHeader, credentialRequests);
fail();

@@ -762,3 +764,3 @@ } catch (e) {

try {
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestUuid, invalidProof, verifier, authHeader, credentialRequests);
await callVerifyPresentation(context, type, verifiableCredential, presentationRequestId, invalidProof, verifier, authHeader, credentialRequests);
fail();

@@ -765,0 +767,0 @@ } catch (e) {

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

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

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