From 96c40815433379a3f8893629bb0953b81406887e Mon Sep 17 00:00:00 2001 From: GopherDID <74898029+vmidyllic@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:35:04 +0300 Subject: [PATCH 1/2] fixed linter (#87) * fixed linter --- test/auth.test.ts | 441 ++++++++++++++++++++++------------------------ 1 file changed, 214 insertions(+), 227 deletions(-) diff --git a/test/auth.test.ts b/test/auth.test.ts index ba7ae7d..0b2936a 100644 --- a/test/auth.test.ts +++ b/test/auth.test.ts @@ -8,8 +8,7 @@ import { NativeProver, PROTOCOL_CONSTANTS, PackageManager, - ZeroKnowledgeProofRequest, - ZeroKnowledgeProofResponse + ZeroKnowledgeProofRequest } from '@0xpolygonid/js-sdk'; import { AuthPubSignalsV2 } from '@lib/circuits/authV2'; import { @@ -94,10 +93,8 @@ describe('auth tests', () => { }); it('TestVerifyWithAtomicMTPProof', async () => { - const sender = 'did:iden3:polygon:amoy:xCRp75DgAdS63W65fmXHz6p9DwdonuRU9e46DifhX'; const callback = 'https://test.com/callback'; - const userId = 'did:iden3:polygon:amoy:x7Z95VkUuyo6mqraJw2VGwCfqTzdqhM1RVjRHzcpK'; const reason = 'test'; const message = 'message to sign'; const request: AuthorizationRequestMessage = createAuthorizationRequestWithMessage( @@ -111,7 +108,7 @@ describe('auth tests', () => { expect(request.body.reason).toEqual(reason); expect(request.from).toEqual(sender); - request.thid = '3bfc628a-6d16-4af7-8358-59656ca30600"'; + request.thid = '3bfc628a-6d16-4af7-8358-59656ca30600'; const proofRequest: ZeroKnowledgeProofRequest = { id: 1, @@ -133,129 +130,125 @@ describe('auth tests', () => { expect(request.body.scope.length).toEqual(1); const response: AuthorizationResponseMessage = { - "id": "d61ca0e1-0fb4-42e1-9baf-10926d76588a", - "typ": PROTOCOL_CONSTANTS.MediaType.ZKPMessage, - "type": "https://iden3-communication.io/authorization/1.0/response", - "thid": "3bfc628a-6d16-4af7-8358-59656ca30600", - "body": { - "message": "message to sign", - "scope": [ + id: 'd61ca0e1-0fb4-42e1-9baf-10926d76588a', + typ: PROTOCOL_CONSTANTS.MediaType.ZKPMessage, + type: 'https://iden3-communication.io/authorization/1.0/response', + thid: '3bfc628a-6d16-4af7-8358-59656ca30600', + body: { + message: 'message to sign', + scope: [ { - "id": 1, - "circuitId": "credentialAtomicQueryMTPV2", - "proof": { - "pi_a": [ - "10193646151489765961716165294209441914505373340739978345545023009943374940812", - "19540734080723747303959563086264670275414339236530195261122226272390746855937", - "1" + id: 1, + circuitId: 'credentialAtomicQueryMTPV2', + proof: { + pi_a: [ + '10193646151489765961716165294209441914505373340739978345545023009943374940812', + '19540734080723747303959563086264670275414339236530195261122226272390746855937', + '1' ], - "pi_b": [ + pi_b: [ [ - "19467942677882193293944841488842174190120571613164887280488852508969862343027", - "17106577273687108884214556012243492970215151434611531033321585163414364507509" + '19467942677882193293944841488842174190120571613164887280488852508969862343027', + '17106577273687108884214556012243492970215151434611531033321585163414364507509' ], [ - "14498015884038973042346029647348006632739743736155378028992421520463893750183", - "19621104134440461747561213754446927179909482545004438474015524348062312609080" + '14498015884038973042346029647348006632739743736155378028992421520463893750183', + '19621104134440461747561213754446927179909482545004438474015524348062312609080' ], - [ - "1", - "0" - ] + ['1', '0'] ], - "pi_c": [ - "14006417320092906277546140755451080235060132073017953616831608713184292562687", - "15061888463009562171895687986245706187439910096872145065899377525706148091513", - "1" + pi_c: [ + '14006417320092906277546140755451080235060132073017953616831608713184292562687', + '15061888463009562171895687986245706187439910096872145065899377525706148091513', + '1' ], - "protocol": "groth16" + protocol: 'groth16' }, - "pub_signals": [ - "1", - "21575127216236248869702276246037557119007466180301957762196593786733007617", - "1", - "25198543381200665770805816046271594885604002445105767653616878167826895617", - "18537029360774351903277257040237420954645495647417042860442609334172554965092", - "1", - "4487386332479489158003597844990487984925471813907462483907054425759564175341", - "1712132038", - "74977327600848231385663280181476307657", - "0", - "20376033832371109177683048456014525905119173674985843915445634726167450989630", - "0", - "2", - "20010101", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0" + pub_signals: [ + '1', + '21575127216236248869702276246037557119007466180301957762196593786733007617', + '1', + '25198543381200665770805816046271594885604002445105767653616878167826895617', + '18537029360774351903277257040237420954645495647417042860442609334172554965092', + '1', + '4487386332479489158003597844990487984925471813907462483907054425759564175341', + '1712132038', + '74977327600848231385663280181476307657', + '0', + '20376033832371109177683048456014525905119173674985843915445634726167450989630', + '0', + '2', + '20010101', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0' ] } ] }, - "from": "did:iden3:polygon:amoy:x7Z95VkUuyo6mqraJw2VGwCfqTzdqhM1RVjRHzcpK", - "to": "did:iden3:polygon:amoy:xCRp75DgAdS63W65fmXHz6p9DwdonuRU9e46DifhX" - } ; - + from: 'did:iden3:polygon:amoy:x7Z95VkUuyo6mqraJw2VGwCfqTzdqhM1RVjRHzcpK', + to: 'did:iden3:polygon:amoy:xCRp75DgAdS63W65fmXHz6p9DwdonuRU9e46DifhX' + }; const verifier = await Verifier.newVerifier({ stateResolver: resolvers, circuitsDir: path.join(__dirname, './testdata'), @@ -301,131 +294,126 @@ describe('auth tests', () => { expect(request.body.scope.length).toEqual(1); - - const response: AuthorizationResponseMessage = { - "id": "fe05a780-3a91-4a12-84bd-a23223004543", - "typ": PROTOCOL_CONSTANTS.MediaType.ZKPMessage, - "type": "https://iden3-communication.io/authorization/1.0/response", - "thid": "cbeb7e95-49a6-4107-ad5d-33de4620a2c7", - "body": { - "message": "message to sign", - "scope": [ + id: 'fe05a780-3a91-4a12-84bd-a23223004543', + typ: PROTOCOL_CONSTANTS.MediaType.ZKPMessage, + type: 'https://iden3-communication.io/authorization/1.0/response', + thid: 'cbeb7e95-49a6-4107-ad5d-33de4620a2c7', + body: { + message: 'message to sign', + scope: [ { - "id": 1, - "circuitId": "credentialAtomicQuerySigV2", - "proof": { - "pi_a": [ - "3978283874506757525802957933408570785578432271724288548246348383068810207211", - "3839462864594627131752113404967812699538444256660443277198360774263348025078", - "1" + id: 1, + circuitId: 'credentialAtomicQuerySigV2', + proof: { + pi_a: [ + '3978283874506757525802957933408570785578432271724288548246348383068810207211', + '3839462864594627131752113404967812699538444256660443277198360774263348025078', + '1' ], - "pi_b": [ + pi_b: [ [ - "1362896848909471153554522290024953846910293534485680267453780104481811422290", - "15020898560978280120037685310228488598606735402262450207703916904657862338124" + '1362896848909471153554522290024953846910293534485680267453780104481811422290', + '15020898560978280120037685310228488598606735402262450207703916904657862338124' ], [ - "21332978512889427960726931487036095435728978762819963806724151119728932608790", - "21196976187509848930911656208458284240239739037067667132440783059540157723036" + '21332978512889427960726931487036095435728978762819963806724151119728932608790', + '21196976187509848930911656208458284240239739037067667132440783059540157723036' ], - [ - "1", - "0" - ] + ['1', '0'] ], - "pi_c": [ - "20396313416829218018504461507621482120133611229332817627860821702949693461370", - "10644256358167652530995066552061972678660124036948547117328217950416688452505", - "1" + pi_c: [ + '20396313416829218018504461507621482120133611229332817627860821702949693461370', + '10644256358167652530995066552061972678660124036948547117328217950416688452505', + '1' ], - "protocol": "groth16" + protocol: 'groth16' }, - "pub_signals": [ - "0", - "21575127216236248869702276246037557119007466180301957762196593786733007617", - "4487386332479489158003597844990487984925471813907462483907054425759564175341", - "1", - "25198543381200665770805816046271594885604002445105767653616878167826895617", - "1", - "4487386332479489158003597844990487984925471813907462483907054425759564175341", - "1712132869", - "198285726510688200335207273836123338699", - "1", - "0", - "2", - "2", - "20010101", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0", - "0" + pub_signals: [ + '0', + '21575127216236248869702276246037557119007466180301957762196593786733007617', + '4487386332479489158003597844990487984925471813907462483907054425759564175341', + '1', + '25198543381200665770805816046271594885604002445105767653616878167826895617', + '1', + '4487386332479489158003597844990487984925471813907462483907054425759564175341', + '1712132869', + '198285726510688200335207273836123338699', + '1', + '0', + '2', + '2', + '20010101', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0', + '0' ] } ] }, - "from": "did:iden3:polygon:amoy:x7Z95VkUuyo6mqraJw2VGwCfqTzdqhM1RVjRHzcpK", - "to": "did:iden3:polygon:amoy:xCRp75DgAdS63W65fmXHz6p9DwdonuRU9e46DifhX" - } + from: 'did:iden3:polygon:amoy:x7Z95VkUuyo6mqraJw2VGwCfqTzdqhM1RVjRHzcpK', + to: 'did:iden3:polygon:amoy:xCRp75DgAdS63W65fmXHz6p9DwdonuRU9e46DifhX' + }; const verifier = await Verifier.newVerifier({ stateResolver: resolvers, @@ -544,7 +532,6 @@ describe('auth tests', () => { await expect(verifier.fullVerify(token, request, testOpts)).resolves.not.toThrow(); }); - it('registry: get existing circuit', () => { const type = Circuits.getCircuitPubSignals('authV2'); const instance = new type([ From aad0e2d7f1a0af6ab086a6bbb978eb031092875e Mon Sep 17 00:00:00 2001 From: volodymyr-basiuk <31999965+volodymyr-basiuk@users.noreply.github.com> Date: Mon, 8 Apr 2024 11:56:58 +0300 Subject: [PATCH 2/2] fix issue "Credential revocation not working" (#88) * fix issue "Credential revocation not working" --- package-lock.json | 12 ++++++------ package.json | 4 ++-- src/state/resolver.ts | 7 ++++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index af7f983..b880c65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@iden3/js-iden3-auth", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@iden3/js-iden3-auth", - "version": "1.3.0", + "version": "1.3.1", "license": "AGPL-3.0", "dependencies": { - "@0xpolygonid/js-sdk": "1.10.0", + "@0xpolygonid/js-sdk": "1.10.3", "@iden3/js-crypto": "1.1.0", "@iden3/js-iden3-core": "1.3.1", "@iden3/js-jsonld-merklization": "1.2.0", @@ -47,9 +47,9 @@ } }, "node_modules/@0xpolygonid/js-sdk": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@0xpolygonid/js-sdk/-/js-sdk-1.10.0.tgz", - "integrity": "sha512-DRU8Ed/jePaWTCMLn0F+Rf8rD10k7klUytK7fgsBH7aCoDxZTEuZ8IPkSPLCF5HsjVtQKadPjyhwGNf/lLRpNw==", + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/@0xpolygonid/js-sdk/-/js-sdk-1.10.3.tgz", + "integrity": "sha512-NJdlu2o7uyXXht2GyzLd7VFPMwh3bR1SR+Omiu7zA81d1jf9CAUXpBBlJLIUCN94toA3qcTO+wfKFgK/rXbYHg==", "dependencies": { "@noble/curves": "^1.4.0", "ajv": "8.12.0", diff --git a/package.json b/package.json index 32ea85e..025ef03 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@iden3/js-iden3-auth", - "version": "1.3.0", + "version": "1.3.1", "description": "iden3-auth implementation in JavaScript", "main": "dist/cjs/index.js", "source": "./src/index.ts", @@ -33,7 +33,7 @@ }, "dependencies": { "@iden3/js-crypto": "1.1.0", - "@0xpolygonid/js-sdk": "1.10.0", + "@0xpolygonid/js-sdk": "1.10.3", "@iden3/js-iden3-core": "1.3.1", "@iden3/js-jsonld-merklization": "1.2.0", "@iden3/js-jwz": "1.4.0", diff --git a/src/state/resolver.ts b/src/state/resolver.ts index ca20c75..d31f7ad 100644 --- a/src/state/resolver.ts +++ b/src/state/resolver.ts @@ -74,7 +74,12 @@ export class EthStateResolver implements IStateResolver { }; } - return { latest: true, genesis: isGenesis, state, transitionTimestamp: 0 }; + return { + latest: contractState.replacedAtTimestamp.isZero(), + genesis: isGenesis, + state, + transitionTimestamp: contractState.replacedAtTimestamp.toNumber() + }; } public async rootResolve(state: bigint): Promise {