From 5160408d5e68d5ae37217ed23c2a20ca901db4fa Mon Sep 17 00:00:00 2001 From: Antonio Ivanovski Date: Tue, 23 Apr 2024 19:38:50 +0200 Subject: [PATCH 01/13] vidos resolver --- verifier-integration/js/VidosResolver.js | 114 ++++++++++++++++++++++ verifier-integration/js/package-lock.json | 1 + verifier-integration/js/package.json | 1 + 3 files changed, 116 insertions(+) create mode 100644 verifier-integration/js/VidosResolver.js diff --git a/verifier-integration/js/VidosResolver.js b/verifier-integration/js/VidosResolver.js new file mode 100644 index 0000000..999a203 --- /dev/null +++ b/verifier-integration/js/VidosResolver.js @@ -0,0 +1,114 @@ +const { Id } = require("@iden3/js-iden3-core"); +const { resolver } = require("@iden3/js-iden3-auth"); + +/** + * Implementation of {@link resolver.IStateResolver} that uses Vidos resolver service to resolve states. + * It can serve as drop-in replacement for {@link resolver.EthStateResolver}. + */ +export default class VidosResolver extends resolver.IStateResolver { + /** + * @param {string} resolverUrl + * @param {string} apiKey + */ + constructor(resolverUrl, apiKey) { + this.resolverUrl = resolverUrl; + this.apiKey = apiKey; + } + + /** + * @param {bigint} state + * @returns {Promise} + */ + async rootResolve(state) { + const stateHex = state.toString("16"); + + const zeroAddress = "11111111111111111111"; // 1 is 0 in base58 + const did = `did:polygonid:polygon:amoy:${zeroAddress}?gist=${stateHex}`; + + const response = await fetch(`${this.resolverUrl}/${encodeURIComponent(did)}`, { + method: "GET", + headers: { + Authorization: `Bearer ${this.apiKey}`, + }, + }); + const result = await response.json(); + // console.log("root result", JSON.stringify(result, null, 2)); + + const globalInfo = result.didDocument.verificationMethod[0].global; + if (globalInfo == null) throw new Error('gist info not found') + + if (globalInfo.root !== stateHex) { + throw new Error('gist info contains invalid state'); + } + + if (globalInfo.replacedByRoot !== "0") { + if (globalInfo.replacedAtTimestamp === "0") { + throw new Error('state was replaced, but replaced time unknown'); + } + return { + latest: false, + state: state, + transitionTimestamp: globalInfo.replacedAtTimestamp, + genesis: false, + }; + } + + return { + latest: true, + state: state, + transitionTimestamp: 0, + genesis: false, + }; + } + + /** + * @param {bigint} id + * @param {bigint} state + * @returns {Promise} + */ + async resolve(id, state) { + const iden3Id = Id.fromBigInt(id); + const stateHex = state.toString("16"); + + const did = `did:polygonid:polygon:amoy:${iden3Id.string()}`; + + const didWithState = `${did}?state=${stateHex}`; + const response = await fetch( + `${this.resolverUrl}/${encodeURIComponent(didWithState)}`, + { + method: "GET", + headers: { + Authorization: `Bearer ${this.apiKey}`, + }, + } + ); + const result = await response.json(); + const isGenesis = resolver.isGenesisStateId(id, state); + + const stateInfo = result.didDocument.verificationMethod[0].info; + if (stateInfo == null) throw new Error('state info not found'); + + if (stateInfo.id !== did) { + throw new Error(`state was recorded for another identity`); + } + + if (stateInfo.state !== stateHex) { + if (stateInfo.replacedAtTimestamp === "0") { + throw new Error(`no information about state transition`); + } + return { + latest: false, + genesis: false, + state: state, + transitionTimestamp: Number.parseInt(stateInfo.replacedAtTimestamp), + }; + } + + return { + latest: stateInfo.replacedAtTimestamp === "0", + genesis: isGenesis, + state, + transitionTimestamp: Number.parseInt(stateInfo.replacedAtTimestamp), + }; + } +} diff --git a/verifier-integration/js/package-lock.json b/verifier-integration/js/package-lock.json index 811373c..d589bc4 100644 --- a/verifier-integration/js/package-lock.json +++ b/verifier-integration/js/package-lock.json @@ -6,6 +6,7 @@ "": { "dependencies": { "@iden3/js-iden3-auth": "1.3.2", + "@iden3/js-iden3-core": "^1.3.1", "express": "^4.18.2" } }, diff --git a/verifier-integration/js/package.json b/verifier-integration/js/package.json index 1b926ce..ad8e8fb 100644 --- a/verifier-integration/js/package.json +++ b/verifier-integration/js/package.json @@ -1,6 +1,7 @@ { "dependencies": { "@iden3/js-iden3-auth": "1.3.2", + "@iden3/js-iden3-core": "^1.3.1", "express": "^4.18.2" } } From 904b68c921d41ced285dd5da159376daf8f9d545 Mon Sep 17 00:00:00 2001 From: Antonio Ivanovski Date: Tue, 23 Apr 2024 19:39:00 +0200 Subject: [PATCH 02/13] intercept state resolver --- .../js/interceptStateResolver.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 verifier-integration/js/interceptStateResolver.js diff --git a/verifier-integration/js/interceptStateResolver.js b/verifier-integration/js/interceptStateResolver.js new file mode 100644 index 0000000..072da8f --- /dev/null +++ b/verifier-integration/js/interceptStateResolver.js @@ -0,0 +1,34 @@ +const { resolver } = require("@iden3/js-iden3-auth"); + +/** + * Wrapper around a state resolver that logs the state resolution process. Useful for debugging and learning how state resolution works. + * + * @param {resolver.IStateResolver} resolver + * @returns {resolver.IStateResolver} + */ +export default function interceptStateResolver(resolver) { + return { + async resolve(id, state) { + try { + console.log("Resolving state", id, state); + const result = await resolver.resolve(id, state); + console.log("Resolved state", id, state, result); + return result; + } catch (e) { + console.error("Error resolving state", id, state, e); + throw e; + } + }, + async rootResolve(state) { + try { + console.log("Resolving root state", state); + const result = await resolver.rootResolve(state); + console.log("Resolved root state", state, result); + return result; + } catch (e) { + console.error("Error resolving root state", state, e); + throw e; + } + }, + }; +} From c9c61ba32eff4dd6e3a8fc60f987ce591850fcc4 Mon Sep 17 00:00:00 2001 From: Antonio Ivanovski Date: Tue, 23 Apr 2024 19:41:05 +0200 Subject: [PATCH 03/13] integrate vidos resolver --- verifier-integration/js/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/verifier-integration/js/index.js b/verifier-integration/js/index.js index eb17b6c..dafa75e 100644 --- a/verifier-integration/js/index.js +++ b/verifier-integration/js/index.js @@ -1,11 +1,15 @@ const path = require("path"); const express = require("express"); -const { auth, resolver, protocol } = require("@iden3/js-iden3-auth"); +const { auth, resolver } = require("@iden3/js-iden3-auth"); const getRawBody = require("raw-body"); +import VidosResolver from "./VidosResolver"; const app = express(); const port = 8080; +const VIDOS_RESOLVER_URL = undefined; // 'https://ugly-aqua-hummingbird-120.resolver.service.eu.vidos.local'; +const VIDOS_API_KEY = undefined; // '24b500499e7c2f0a8634831d1b9894b74d656d3e7cd6de238d706c20a5db6d41'; + app.use(express.static("../static")); app.get("/api/sign-in", (req, res) => { @@ -85,9 +89,10 @@ async function callback(req, res) { ethURL, contractAddress ); + const vidosResolver = VIDOS_RESOLVER_URL && VIDOS_API_KEY ? new VidosResolver(VIDOS_RESOLVER_URL, VIDOS_API_KEY) : undefined; const resolvers = { - ["polygon:amoy"]: ethStateResolver, + ["polygon:amoy"]: vidosResolver ?? ethStateResolver, }; // fetch authRequest from sessionID @@ -112,4 +117,4 @@ async function callback(req, res) { .status(200) .set("Content-Type", "application/json") .send(authResponse); -} +} \ No newline at end of file From 6f7aa96047146dadd2135f283435cb78777c805d Mon Sep 17 00:00:00 2001 From: Antonio Ivanovski Date: Tue, 23 Apr 2024 19:44:05 +0200 Subject: [PATCH 04/13] fix exports --- verifier-integration/js/VidosResolver.js | 6 +++++- verifier-integration/js/index.js | 2 +- verifier-integration/js/interceptStateResolver.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/verifier-integration/js/VidosResolver.js b/verifier-integration/js/VidosResolver.js index 999a203..8983a59 100644 --- a/verifier-integration/js/VidosResolver.js +++ b/verifier-integration/js/VidosResolver.js @@ -4,8 +4,10 @@ const { resolver } = require("@iden3/js-iden3-auth"); /** * Implementation of {@link resolver.IStateResolver} that uses Vidos resolver service to resolve states. * It can serve as drop-in replacement for {@link resolver.EthStateResolver}. + * + * @implements {resolver.IStateResolver} */ -export default class VidosResolver extends resolver.IStateResolver { +class VidosResolver { /** * @param {string} resolverUrl * @param {string} apiKey @@ -112,3 +114,5 @@ export default class VidosResolver extends resolver.IStateResolver { }; } } + +module.exports = VidosResolver; \ No newline at end of file diff --git a/verifier-integration/js/index.js b/verifier-integration/js/index.js index dafa75e..5d7d9e0 100644 --- a/verifier-integration/js/index.js +++ b/verifier-integration/js/index.js @@ -2,7 +2,7 @@ const path = require("path"); const express = require("express"); const { auth, resolver } = require("@iden3/js-iden3-auth"); const getRawBody = require("raw-body"); -import VidosResolver from "./VidosResolver"; +const VidosResolver = require("./VidosResolver"); const app = express(); const port = 8080; diff --git a/verifier-integration/js/interceptStateResolver.js b/verifier-integration/js/interceptStateResolver.js index 072da8f..94388cd 100644 --- a/verifier-integration/js/interceptStateResolver.js +++ b/verifier-integration/js/interceptStateResolver.js @@ -6,7 +6,7 @@ const { resolver } = require("@iden3/js-iden3-auth"); * @param {resolver.IStateResolver} resolver * @returns {resolver.IStateResolver} */ -export default function interceptStateResolver(resolver) { +function interceptStateResolver(resolver) { return { async resolve(id, state) { try { @@ -32,3 +32,5 @@ export default function interceptStateResolver(resolver) { }, }; } + +module.exports = interceptStateResolver; From d8d695eb809562c323d3e0f7d050ecd33dce5bbb Mon Sep 17 00:00:00 2001 From: Antonio Ivanovski Date: Thu, 25 Apr 2024 09:30:11 +0200 Subject: [PATCH 05/13] add dotenv --- verifier-integration/js/.env | 2 ++ verifier-integration/js/.env.example | 2 ++ verifier-integration/js/VidosResolver.js | 1 - verifier-integration/js/index.js | 14 +++++++++----- verifier-integration/js/package-lock.json | 15 +++++++++++++++ verifier-integration/js/package.json | 3 +++ 6 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 verifier-integration/js/.env create mode 100644 verifier-integration/js/.env.example diff --git a/verifier-integration/js/.env b/verifier-integration/js/.env new file mode 100644 index 0000000..f107efe --- /dev/null +++ b/verifier-integration/js/.env @@ -0,0 +1,2 @@ +VIDOS_RESOLVER_URL= +VIDOS_API_KEY= \ No newline at end of file diff --git a/verifier-integration/js/.env.example b/verifier-integration/js/.env.example new file mode 100644 index 0000000..c9b2e9e --- /dev/null +++ b/verifier-integration/js/.env.example @@ -0,0 +1,2 @@ +VIDOS_RESOLVER_URL=https://ugly-aqua-hummingbird-120.resolver.service.eu.vidos.dev +VIDOS_API_KEY=24b500499e7c2f0a8634831d1b9894b74d656d3e7cd6de238d706c20a5db6d41 \ No newline at end of file diff --git a/verifier-integration/js/VidosResolver.js b/verifier-integration/js/VidosResolver.js index 8983a59..f4fa9db 100644 --- a/verifier-integration/js/VidosResolver.js +++ b/verifier-integration/js/VidosResolver.js @@ -34,7 +34,6 @@ class VidosResolver { }, }); const result = await response.json(); - // console.log("root result", JSON.stringify(result, null, 2)); const globalInfo = result.didDocument.verificationMethod[0].global; if (globalInfo == null) throw new Error('gist info not found') diff --git a/verifier-integration/js/index.js b/verifier-integration/js/index.js index 5d7d9e0..58c7897 100644 --- a/verifier-integration/js/index.js +++ b/verifier-integration/js/index.js @@ -1,3 +1,4 @@ +require("dotenv").config(); const path = require("path"); const express = require("express"); const { auth, resolver } = require("@iden3/js-iden3-auth"); @@ -7,9 +8,6 @@ const VidosResolver = require("./VidosResolver"); const app = express(); const port = 8080; -const VIDOS_RESOLVER_URL = undefined; // 'https://ugly-aqua-hummingbird-120.resolver.service.eu.vidos.local'; -const VIDOS_API_KEY = undefined; // '24b500499e7c2f0a8634831d1b9894b74d656d3e7cd6de238d706c20a5db6d41'; - app.use(express.static("../static")); app.get("/api/sign-in", (req, res) => { @@ -89,7 +87,13 @@ async function callback(req, res) { ethURL, contractAddress ); - const vidosResolver = VIDOS_RESOLVER_URL && VIDOS_API_KEY ? new VidosResolver(VIDOS_RESOLVER_URL, VIDOS_API_KEY) : undefined; + const vidosResolver = + process.env.VIDOS_RESOLVER_URL && process.env.VIDOS_API_KEY + ? new VidosResolver( + process.env.VIDOS_RESOLVER_URL, + process.env.VIDOS_API_KEY + ) + : undefined; const resolvers = { ["polygon:amoy"]: vidosResolver ?? ethStateResolver, @@ -117,4 +121,4 @@ async function callback(req, res) { .status(200) .set("Content-Type", "application/json") .send(authResponse); -} \ No newline at end of file +} diff --git a/verifier-integration/js/package-lock.json b/verifier-integration/js/package-lock.json index d589bc4..04d4705 100644 --- a/verifier-integration/js/package-lock.json +++ b/verifier-integration/js/package-lock.json @@ -8,6 +8,9 @@ "@iden3/js-iden3-auth": "1.3.2", "@iden3/js-iden3-core": "^1.3.1", "express": "^4.18.2" + }, + "devDependencies": { + "dotenv": "^16.4.5" } }, "node_modules/@0xpolygonid/js-sdk": { @@ -1555,6 +1558,18 @@ "resolved": "https://registry.npmjs.org/did-resolver/-/did-resolver-4.1.0.tgz", "integrity": "sha512-S6fWHvCXkZg2IhS4RcVHxwuyVejPR7c+a4Go0xbQ9ps5kILa8viiYQgrM4gfTyeTjJ0ekgJH9gk/BawTpmkbZA==" }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", diff --git a/verifier-integration/js/package.json b/verifier-integration/js/package.json index ad8e8fb..d28773d 100644 --- a/verifier-integration/js/package.json +++ b/verifier-integration/js/package.json @@ -3,5 +3,8 @@ "@iden3/js-iden3-auth": "1.3.2", "@iden3/js-iden3-core": "^1.3.1", "express": "^4.18.2" + }, + "devDependencies": { + "dotenv": "^16.4.5" } } From 0d9c0e3e06a8b298e59dbc908f3c35ab8d44f08d Mon Sep 17 00:00:00 2001 From: Antonio Ivanovski Date: Thu, 25 Apr 2024 09:33:55 +0200 Subject: [PATCH 06/13] and .env to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a763f38..63fdc5a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store **/**/node_modules/ +**/.env \ No newline at end of file From 3d0926edbe653a07ff7dc43ee0444c363b7ad808 Mon Sep 17 00:00:00 2001 From: Antonio Ivanovski Date: Thu, 25 Apr 2024 09:36:47 +0200 Subject: [PATCH 07/13] make dotenv regular dep --- verifier-integration/js/package-lock.json | 5 +---- verifier-integration/js/package.json | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/verifier-integration/js/package-lock.json b/verifier-integration/js/package-lock.json index 04d4705..1787c48 100644 --- a/verifier-integration/js/package-lock.json +++ b/verifier-integration/js/package-lock.json @@ -7,10 +7,8 @@ "dependencies": { "@iden3/js-iden3-auth": "1.3.2", "@iden3/js-iden3-core": "^1.3.1", + "dotenv": "^16.4.5", "express": "^4.18.2" - }, - "devDependencies": { - "dotenv": "^16.4.5" } }, "node_modules/@0xpolygonid/js-sdk": { @@ -1562,7 +1560,6 @@ "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", - "dev": true, "engines": { "node": ">=12" }, diff --git a/verifier-integration/js/package.json b/verifier-integration/js/package.json index d28773d..140bbe8 100644 --- a/verifier-integration/js/package.json +++ b/verifier-integration/js/package.json @@ -2,9 +2,7 @@ "dependencies": { "@iden3/js-iden3-auth": "1.3.2", "@iden3/js-iden3-core": "^1.3.1", - "express": "^4.18.2" - }, - "devDependencies": { + "express": "^4.18.2", "dotenv": "^16.4.5" } } From adc757902f48b15968ba0c65aedaff579ccdb39f Mon Sep 17 00:00:00 2001 From: Rob De Feo Date: Thu, 25 Apr 2024 16:28:31 +0200 Subject: [PATCH 08/13] Update verifier-integration/js/.env.example --- verifier-integration/js/.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verifier-integration/js/.env.example b/verifier-integration/js/.env.example index c9b2e9e..0096065 100644 --- a/verifier-integration/js/.env.example +++ b/verifier-integration/js/.env.example @@ -1,2 +1,2 @@ -VIDOS_RESOLVER_URL=https://ugly-aqua-hummingbird-120.resolver.service.eu.vidos.dev +VIDOS_RESOLVER_URL=https://ugly-aqua-hummingbird-120.resolver.service.eu.vidos.id VIDOS_API_KEY=24b500499e7c2f0a8634831d1b9894b74d656d3e7cd6de238d706c20a5db6d41 \ No newline at end of file From 322a92f689acc391d0550173298f69884ba49931 Mon Sep 17 00:00:00 2001 From: Rob De Feo Date: Thu, 25 Apr 2024 16:28:38 +0200 Subject: [PATCH 09/13] Update verifier-integration/js/.env.example --- verifier-integration/js/.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verifier-integration/js/.env.example b/verifier-integration/js/.env.example index 0096065..8420416 100644 --- a/verifier-integration/js/.env.example +++ b/verifier-integration/js/.env.example @@ -1,2 +1,2 @@ VIDOS_RESOLVER_URL=https://ugly-aqua-hummingbird-120.resolver.service.eu.vidos.id -VIDOS_API_KEY=24b500499e7c2f0a8634831d1b9894b74d656d3e7cd6de238d706c20a5db6d41 \ No newline at end of file +VIDOS_API_KEY= \ No newline at end of file From bb56da030e65af6a7d57ac008660892ee07ea72c Mon Sep 17 00:00:00 2001 From: Antonio Ivanovski Date: Mon, 13 May 2024 13:17:22 +0200 Subject: [PATCH 10/13] remove old vidos resolver and intercept resolver --- verifier-integration/js/VidosResolver.js | 117 ------------------ .../js/interceptStateResolver.js | 36 ------ 2 files changed, 153 deletions(-) delete mode 100644 verifier-integration/js/VidosResolver.js delete mode 100644 verifier-integration/js/interceptStateResolver.js diff --git a/verifier-integration/js/VidosResolver.js b/verifier-integration/js/VidosResolver.js deleted file mode 100644 index f4fa9db..0000000 --- a/verifier-integration/js/VidosResolver.js +++ /dev/null @@ -1,117 +0,0 @@ -const { Id } = require("@iden3/js-iden3-core"); -const { resolver } = require("@iden3/js-iden3-auth"); - -/** - * Implementation of {@link resolver.IStateResolver} that uses Vidos resolver service to resolve states. - * It can serve as drop-in replacement for {@link resolver.EthStateResolver}. - * - * @implements {resolver.IStateResolver} - */ -class VidosResolver { - /** - * @param {string} resolverUrl - * @param {string} apiKey - */ - constructor(resolverUrl, apiKey) { - this.resolverUrl = resolverUrl; - this.apiKey = apiKey; - } - - /** - * @param {bigint} state - * @returns {Promise} - */ - async rootResolve(state) { - const stateHex = state.toString("16"); - - const zeroAddress = "11111111111111111111"; // 1 is 0 in base58 - const did = `did:polygonid:polygon:amoy:${zeroAddress}?gist=${stateHex}`; - - const response = await fetch(`${this.resolverUrl}/${encodeURIComponent(did)}`, { - method: "GET", - headers: { - Authorization: `Bearer ${this.apiKey}`, - }, - }); - const result = await response.json(); - - const globalInfo = result.didDocument.verificationMethod[0].global; - if (globalInfo == null) throw new Error('gist info not found') - - if (globalInfo.root !== stateHex) { - throw new Error('gist info contains invalid state'); - } - - if (globalInfo.replacedByRoot !== "0") { - if (globalInfo.replacedAtTimestamp === "0") { - throw new Error('state was replaced, but replaced time unknown'); - } - return { - latest: false, - state: state, - transitionTimestamp: globalInfo.replacedAtTimestamp, - genesis: false, - }; - } - - return { - latest: true, - state: state, - transitionTimestamp: 0, - genesis: false, - }; - } - - /** - * @param {bigint} id - * @param {bigint} state - * @returns {Promise} - */ - async resolve(id, state) { - const iden3Id = Id.fromBigInt(id); - const stateHex = state.toString("16"); - - const did = `did:polygonid:polygon:amoy:${iden3Id.string()}`; - - const didWithState = `${did}?state=${stateHex}`; - const response = await fetch( - `${this.resolverUrl}/${encodeURIComponent(didWithState)}`, - { - method: "GET", - headers: { - Authorization: `Bearer ${this.apiKey}`, - }, - } - ); - const result = await response.json(); - const isGenesis = resolver.isGenesisStateId(id, state); - - const stateInfo = result.didDocument.verificationMethod[0].info; - if (stateInfo == null) throw new Error('state info not found'); - - if (stateInfo.id !== did) { - throw new Error(`state was recorded for another identity`); - } - - if (stateInfo.state !== stateHex) { - if (stateInfo.replacedAtTimestamp === "0") { - throw new Error(`no information about state transition`); - } - return { - latest: false, - genesis: false, - state: state, - transitionTimestamp: Number.parseInt(stateInfo.replacedAtTimestamp), - }; - } - - return { - latest: stateInfo.replacedAtTimestamp === "0", - genesis: isGenesis, - state, - transitionTimestamp: Number.parseInt(stateInfo.replacedAtTimestamp), - }; - } -} - -module.exports = VidosResolver; \ No newline at end of file diff --git a/verifier-integration/js/interceptStateResolver.js b/verifier-integration/js/interceptStateResolver.js deleted file mode 100644 index 94388cd..0000000 --- a/verifier-integration/js/interceptStateResolver.js +++ /dev/null @@ -1,36 +0,0 @@ -const { resolver } = require("@iden3/js-iden3-auth"); - -/** - * Wrapper around a state resolver that logs the state resolution process. Useful for debugging and learning how state resolution works. - * - * @param {resolver.IStateResolver} resolver - * @returns {resolver.IStateResolver} - */ -function interceptStateResolver(resolver) { - return { - async resolve(id, state) { - try { - console.log("Resolving state", id, state); - const result = await resolver.resolve(id, state); - console.log("Resolved state", id, state, result); - return result; - } catch (e) { - console.error("Error resolving state", id, state, e); - throw e; - } - }, - async rootResolve(state) { - try { - console.log("Resolving root state", state); - const result = await resolver.rootResolve(state); - console.log("Resolved root state", state, result); - return result; - } catch (e) { - console.error("Error resolving root state", state, e); - throw e; - } - }, - }; -} - -module.exports = interceptStateResolver; From cd637f3d6fef7acc3c1096c24e3d410b6759e807 Mon Sep 17 00:00:00 2001 From: Antonio Ivanovski Date: Mon, 13 May 2024 13:18:21 +0200 Subject: [PATCH 11/13] use VidosResolver from auth package --- verifier-integration/js/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/verifier-integration/js/index.js b/verifier-integration/js/index.js index 58c7897..0f7f39a 100644 --- a/verifier-integration/js/index.js +++ b/verifier-integration/js/index.js @@ -1,9 +1,8 @@ require("dotenv").config(); const path = require("path"); const express = require("express"); -const { auth, resolver } = require("@iden3/js-iden3-auth"); +const { auth, resolver, VidosResolver } = require("@iden3/js-iden3-auth"); const getRawBody = require("raw-body"); -const VidosResolver = require("./VidosResolver"); const app = express(); const port = 8080; From 00952ba979c1e46bf230ca06139cd9267fb0dff7 Mon Sep 17 00:00:00 2001 From: Rob De Feo Date: Mon, 13 May 2024 14:38:58 +0200 Subject: [PATCH 12/13] Update verifier-integration/js/.env.example --- verifier-integration/js/.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verifier-integration/js/.env.example b/verifier-integration/js/.env.example index 8420416..718c094 100644 --- a/verifier-integration/js/.env.example +++ b/verifier-integration/js/.env.example @@ -1,2 +1,2 @@ -VIDOS_RESOLVER_URL=https://ugly-aqua-hummingbird-120.resolver.service.eu.vidos.id +VIDOS_RESOLVER_URL= VIDOS_API_KEY= \ No newline at end of file From 623f5517387a53be9f7360768aee2037c49c5f3c Mon Sep 17 00:00:00 2001 From: Antonio Ivanovski Date: Mon, 13 May 2024 15:59:22 +0200 Subject: [PATCH 13/13] add vidos resolver network --- verifier-integration/js/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/verifier-integration/js/index.js b/verifier-integration/js/index.js index 0f7f39a..034abf3 100644 --- a/verifier-integration/js/index.js +++ b/verifier-integration/js/index.js @@ -90,7 +90,8 @@ async function callback(req, res) { process.env.VIDOS_RESOLVER_URL && process.env.VIDOS_API_KEY ? new VidosResolver( process.env.VIDOS_RESOLVER_URL, - process.env.VIDOS_API_KEY + process.env.VIDOS_API_KEY, + 'amoy' ) : undefined;