Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix critical dependencies during npm install #285

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
581 changes: 109 additions & 472 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xpolygonid/js-sdk",
"version": "1.21.3",
"version": "1.21.4",
"description": "SDK to work with Polygon ID",
"main": "dist/node/cjs/index.js",
"module": "dist/node/esm/index.js",
Expand Down Expand Up @@ -51,7 +51,6 @@
"homepage": "https://github.com/0xPolygonID/js-sdk#readme",
"devDependencies": {
"@cspell/eslint-plugin": "^8.14.2",
"@gr2m/fetch-mock": "9.11.0-pull-request-644.1",
"@iden3/eslint-config": "https://github.com/iden3/eslint-config",
"@microsoft/api-documenter": "^7.8.20",
"@microsoft/api-extractor": "^7.9.0",
Expand Down Expand Up @@ -80,6 +79,7 @@
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"mocha": "10.2.0",
"nock": "^14.0.0-beta.15",
"prettier": "^2.7.1",
"rimraf": "^5.0.5",
"rollup": "^4.14.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
registerKeyProvidersInMemoryKMS
} from '../../helpers';
import { DID } from '@iden3/js-iden3-core';
import fetchMock from '@gr2m/fetch-mock';
import { Proof, ZERO_HASH } from '@iden3/js-merkletree';

describe('SparseMerkleTreeProof', () => {
let idWallet: IdentityWallet;
Expand Down Expand Up @@ -51,22 +49,6 @@ describe('SparseMerkleTreeProof', () => {
});
expect(issuerAuthCredential).not.to.be.undefined;
issuerDID = didIssuer;
const mockRevStatus = JSON.stringify({
mtp: new Proof(),
issuer: {
state: ZERO_HASH.hex(),
claimsTreeRoot: ZERO_HASH.hex(),
revocationTreeRoot: ZERO_HASH.hex(),
rootOfRoots: ZERO_HASH.hex()
}
});
fetchMock.spy();
fetchMock.mock(`begin:${walletUrl}`, mockRevStatus);
fetchMock.mock(`begin:${issuerWalletUrl}`, mockRevStatus);
});

afterEach(() => {
fetchMock.restore();
});

it('issue credential', async () => {
Expand Down
93 changes: 57 additions & 36 deletions tests/credentials/credential-validation.test.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/credentials/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const credWithRefreshService = createTestCredential({
expirationDate: '2023-11-11',
issuanceDate: '2022-11-11',
refreshService: {
id: 'http://test-refresh/100',
id: 'http://test-refresh.com/refresh',
type: 'Iden3RefreshService2023'
}
});
Expand Down
14 changes: 7 additions & 7 deletions tests/handlers/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ import {

import * as uuid from 'uuid';
import { expect } from 'chai';
import fetchMock from '@gr2m/fetch-mock';
import path from 'path';
import nock from 'nock';

describe('fetch', () => {
afterEach(() => {
nock.cleanAll();
});

let idWallet: IdentityWallet;
let credWallet: CredentialWallet;

Expand Down Expand Up @@ -143,8 +147,7 @@ describe('fetch', () => {
});

it('fetch credential issued to genesis did', async () => {
fetchMock.spy();
fetchMock.post(agentUrl, JSON.parse(issuanceResponseMock));
nock(agentUrl).post('/').reply(200, issuanceResponseMock);
const { did: userDID, credential: cred } = await createIdentity(idWallet, {
seed: SEED_USER
});
Expand Down Expand Up @@ -182,7 +185,6 @@ describe('fetch', () => {
const w3cCred = W3CCredential.fromJSON(JSON.parse(issuanceResponseMock).body.credential);

expect(Object.entries(res[0]).toString()).to.equal(Object.entries(w3cCred).toString());
fetchMock.restore();
});

it('handle credential fetch and issuance requests', async () => {
Expand Down Expand Up @@ -277,9 +279,7 @@ describe('fetch', () => {
offer,
{}
);
fetchMock.restore();
fetchMock.spy();
fetchMock.post(agentUrl, issuanceResponseMock);
nock(agentUrl).post('/').reply(200, issuanceResponseMock);
expect(await credWallet.list()).to.have.length(4);

const response = await msgHandler.handleMessage(bytes, {});
Expand Down
19 changes: 10 additions & 9 deletions tests/handlers/payment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ import {
PaymentRequestInfo
} from '../../src/iden3comm/types/protocol/payment';
import { Contract, ethers, JsonRpcProvider } from 'ethers';
import fetchMock from '@gr2m/fetch-mock';
import { fail } from 'assert';
import nock from 'nock';

describe('payment-request handler', () => {
afterEach(() => {
nock.cleanAll();
});

let packageMgr: IPackageManager;
let paymentHandler: IPaymentHandler;
let userDID, issuerDID: DID;
Expand Down Expand Up @@ -146,10 +150,6 @@ describe('payment-request handler', () => {
return Promise.resolve('0x312312334');
};

afterEach(() => {
fetchMock.restore();
});

beforeEach(async () => {
const kms = registerKeyProvidersInMemoryKMS();
const dataStorage = getInMemoryDataStorage(MOCK_STATE_STORAGE);
Expand Down Expand Up @@ -189,8 +189,8 @@ describe('payment-request handler', () => {
issuerDID = issuerIdentity.did;

agentMessageResponse = createProposal(issuerDID, userDID, []);
fetchMock.spy();
fetchMock.post('https://agent-url.com', JSON.stringify(agentMessageResponse));

nock(agent).post('/').reply(200, JSON.stringify(agentMessageResponse));
});

it('payment-request handler test', async () => {
Expand All @@ -214,9 +214,10 @@ describe('payment-request handler', () => {
});

it('payment-request handler test with empty agent response', async () => {
fetchMock.post('https://agent-url.com', '', { overwriteRoutes: true });
const newAgent = `${agent}.ua`;
nock(newAgent).post('/').reply(200, '');

const paymentRequest = createPaymentRequest(issuerDID, userDID, agent, [paymentReqInfo]);
const paymentRequest = createPaymentRequest(issuerDID, userDID, newAgent, [paymentReqInfo]);
const msgBytesRequest = await packageManager.pack(
MediaType.PlainMessage,
byteEncoder.encode(JSON.stringify(paymentRequest)),
Expand Down
15 changes: 7 additions & 8 deletions tests/handlers/refresh.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PackageManager, RefreshHandler } from '../../src';
import { credWithRefreshService } from '../credentials/mock';
import { initZKPPacker } from '../iden3comm/mock/proving';
import fetchMock from '@gr2m/fetch-mock';
import nock from 'nock';
import { expect } from 'chai';

describe('refresh-service', () => {
Expand All @@ -19,20 +19,19 @@ describe('refresh-service', () => {
refreshedCred.expirationDate = new Date().setMinutes(new Date().getMinutes() + 1);
const refreshedId = 'test1_refreshed';
refreshedCred.id = refreshedId;
fetchMock.spy();
fetchMock.post('http://test-refresh/100', {
body: {

nock('http://test-refresh.com')
.post('/refresh')
.reply(200, {
// CredentialIssuanceMessage
id: 'uuid',
body: {
credential: refreshedCred
}
}
});
});

const newCred = await refreshService.refreshCredential(credToRefresh, { reason: 'expired' });
fetchMock.restore();

nock.cleanAll();
expect(newCred.id).to.be.equal(refreshedId);
});
});