From 13d7a3f5a26438583198352df90cae813eb8f006 Mon Sep 17 00:00:00 2001 From: ditoglez Date: Tue, 3 Dec 2024 20:59:46 +0200 Subject: [PATCH 01/10] chore: update pkg.pr action (#373) --- .github/workflows/pkg.pr.new.yml | 4 ++-- packages/idos-sdk-server-dapp/package.json | 6 +++--- packages/idos-sdk-server-dapp/tsup.config.ts | 2 ++ pnpm-lock.yaml | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pkg.pr.new.yml b/.github/workflows/pkg.pr.new.yml index 9e015fd86..e45b71277 100644 --- a/.github/workflows/pkg.pr.new.yml +++ b/.github/workflows/pkg.pr.new.yml @@ -29,8 +29,8 @@ jobs: run: pnpm install - name: Build - run: pnpm build --filter=@idos-network/issuer-sdk-js --filter=@idos-network/idos-sdk + run: pnpm build --filter=@idos-network/issuer-sdk-js --filter=@idos-network/idos-sdk --filter=@idos-network/idos-sdk-server-dapp - name: Release - run: pnpx pkg-pr-new publish --pnpm './packages/issuer-sdk-js' './packages/idos-sdk-js' + run: pnpx pkg-pr-new publish --pnpm './packages/issuer-sdk-js' './packages/idos-sdk-js' './packages/idos-sdk-server-dapp' \ No newline at end of file diff --git a/packages/idos-sdk-server-dapp/package.json b/packages/idos-sdk-server-dapp/package.json index caa0a1a46..2da771c60 100644 --- a/packages/idos-sdk-server-dapp/package.json +++ b/packages/idos-sdk-server-dapp/package.json @@ -15,8 +15,8 @@ } }, "scripts": { - "dev": "dotenvx run --convention=nextjs -- tsup --watch", - "build": "export NODE_ENV=production && dotenvx run --convention=nextjs -- tsup", + "dev": "dotenvx run --convention=nextjs -- tsup --watch --config tsup.config.ts", + "build": "export NODE_ENV=production && dotenvx run --convention=nextjs -- tsup --config tsup.config.ts", "lint": "biome check --apply ./src", "format": "biome format --write .", "test": "vitest run", @@ -33,6 +33,7 @@ }, "devDependencies": { "@dotenvx/dotenvx": "^1.6.4", + "@idos-network/kwil-nep413-signer": "workspace:*", "@near-js/types": "^0.2.1", "@near-wallet-selector/core": "^8.7.5", "@release-it/keep-a-changelog": "^5.0.0", @@ -47,7 +48,6 @@ "@digitalbazaar/ed25519-signature-2020": "^5.2.0", "@digitalbazaar/ed25519-verification-key-2020": "^4.1.0", "@digitalbazaar/vc": "^6.0.2", - "@idos-network/kwil-nep413-signer": "workspace:*", "@kwilteam/kwil-js": "0.7.1", "@stablelib/base64": "^1.0.1", "@stablelib/binary": "^1.0.1", diff --git a/packages/idos-sdk-server-dapp/tsup.config.ts b/packages/idos-sdk-server-dapp/tsup.config.ts index 0bdda1f5a..af16c323c 100644 --- a/packages/idos-sdk-server-dapp/tsup.config.ts +++ b/packages/idos-sdk-server-dapp/tsup.config.ts @@ -10,4 +10,6 @@ export default defineConfig({ env: config().parsed, format: ["esm"], outDir: "./dist", + bundle: true, + noExternal: ["@idos-network/kwil-nep413-signer", "@idos-network/idos-sdk-types"], }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index de8b3f8b7..49d0d3f11 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -633,9 +633,6 @@ importers: '@digitalbazaar/vc': specifier: ^6.0.2 version: 6.0.2(web-streams-polyfill@3.2.1) - '@idos-network/kwil-nep413-signer': - specifier: workspace:* - version: link:../kwil-nep413-signer '@kwilteam/kwil-js': specifier: 0.7.1 version: 0.7.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) @@ -676,6 +673,9 @@ importers: '@dotenvx/dotenvx': specifier: ^1.6.4 version: 1.6.4 + '@idos-network/kwil-nep413-signer': + specifier: workspace:* + version: link:../kwil-nep413-signer '@near-js/types': specifier: ^0.2.1 version: 0.2.1 From c6f6603a32ad0daa7a983191bd38e3cdadc2ccaa Mon Sep 17 00:00:00 2001 From: Mo <51370781+Mohammed-Mamoun98@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:58:07 +0200 Subject: [PATCH 02/10] refactor: remove credential v1 fallback (#372) --- apps/idos-data-dashboard/src/main.tsx | 2 +- .../routes/dashboard/credentials/index.tsx | 24 +----------------- examples/idos-example-dapp/src/main.js | 25 +------------------ examples/issuer-sdk-demo/src/app/page.tsx | 21 +--------------- 4 files changed, 4 insertions(+), 68 deletions(-) diff --git a/apps/idos-data-dashboard/src/main.tsx b/apps/idos-data-dashboard/src/main.tsx index e3989cf68..bc8f60a03 100644 --- a/apps/idos-data-dashboard/src/main.tsx +++ b/apps/idos-data-dashboard/src/main.tsx @@ -29,7 +29,7 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( - {/* @ts-expect-error: TODO: fix wagmi types */} + {/* @ts-ignore: TODO: fix wagmi types */} diff --git a/apps/idos-data-dashboard/src/routes/dashboard/credentials/index.tsx b/apps/idos-data-dashboard/src/routes/dashboard/credentials/index.tsx index e13f214df..ecbd53400 100644 --- a/apps/idos-data-dashboard/src/routes/dashboard/credentials/index.tsx +++ b/apps/idos-data-dashboard/src/routes/dashboard/credentials/index.tsx @@ -37,29 +37,7 @@ const useFetchCredentials = () => { .map((c) => c.id), })) as idOSCredentialWithShares[]; // @todo: remove once we have more type safety in the SDK. }, - select: (credentials) => - credentials - .filter((credential) => !credential.original_id) - - .map((credential) => { - const { credential_level, credential_status, credential_type, issuer } = - // biome-ignore lint/suspicious/noExplicitAny: // @todo: remove once we have successfully migrated to Credentials 2.0. - credential as any; - const fields = credential.public_notes ? JSON.parse(credential.public_notes) : {}; - - const public_notes = { - id: fields.id ?? credential.id, - level: fields.level ?? credential_level, - status: fields.status ?? credential_status, - type: fields.type ?? credential_type, - issuer: fields.issuer ?? issuer, - }; - - return { - ...credential, - public_notes: JSON.stringify(public_notes), - }; - }), + select: (credentials) => credentials.filter((credential) => !credential.original_id), }); }; diff --git a/examples/idos-example-dapp/src/main.js b/examples/idos-example-dapp/src/main.js index eeca74685..d0ddc5e3e 100644 --- a/examples/idos-example-dapp/src/main.js +++ b/examples/idos-example-dapp/src/main.js @@ -200,30 +200,7 @@ const connectWallet = { let credentials = await terminal .h1("eyes", "User's credentials") .wait("awaiting signature", cache.get("credentials") || idos.data.list("credentials")); - credentials = credentials - .filter((c) => c.original_id === null) - // @todo: remove once we have successfully migrated to Credentials 2.0. - .map((credential) => { - const { credential_level, credential_status, credential_type, issuer } = credential; - const _fields = credential.public_notes - ? typeof credential.public_notes === "string" - ? JSON.parse(credential.public_notes) - : credential.public_notes - : {}; - const { id, ...public_notes } = { - id: _fields.id ?? credential.id, - level: _fields.level ?? credential_level, - status: _fields.status ?? credential_status, - type: _fields.type ?? credential_type, - issuer: _fields.issuer ?? issuer, - }; - - return { - ...credential, - ...public_notes, - public_notes, - }; - }); + credentials = credentials.filter((c) => c.original_id === null); cache.set("credentials", credentials); diff --git a/examples/issuer-sdk-demo/src/app/page.tsx b/examples/issuer-sdk-demo/src/app/page.tsx index 48311b50c..fd23e4609 100644 --- a/examples/issuer-sdk-demo/src/app/page.tsx +++ b/examples/issuer-sdk-demo/src/app/page.tsx @@ -58,26 +58,7 @@ export default function Home() { // @ts-expect-error: types in the SDK are a bit messy. await _instance.setSigner("EVM", signer); const _credentials = await _instance.data.list("credentials"); - setCredentials( - _credentials.map((credential) => { - const { credential_level, credential_status, credential_type, issuer } = - // biome-ignore lint/suspicious/noExplicitAny: // @todo: remove once we have successfully migrated to Credentials 2.0. - credential as any; - const fields = credential.public_notes ? JSON.parse(credential.public_notes) : {}; - - const public_notes = { - id: fields.id ?? credential.id, - level: fields.level ?? credential_level, - status: fields.status ?? credential_status, - type: fields.type ?? credential_type, - issuer: fields.issuer ?? issuer, - }; - return { - ...credential, - public_notes: JSON.stringify(public_notes), - }; - }), - ); + setCredentials(_credentials); } setHasProfile(_hasProfile); From aeda550b4b5f866c91c064de1d97d1c54a6e0fb4 Mon Sep 17 00:00:00 2001 From: Mo <51370781+Mohammed-Mamoun98@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:38:48 +0200 Subject: [PATCH 03/10] feat: cleanup enclave iframe on reinitialisation (#378) --- .../src/lib/enclave-providers/iframe-enclave.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts b/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts index ce34de948..1133e7346 100644 --- a/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts +++ b/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts @@ -110,11 +110,14 @@ export class IframeEnclave implements EnclaveProvider { }) as Promise; } - async #loadEnclave() { - const hasIframe = document.getElementById(this.iframe.id); - if (hasIframe) { + async #loadEnclave(): Promise { + const container = document.querySelector(this.container); + const iframeElem = document.getElementById(this.iframe.id); + + if (iframeElem) { console.warn("An Iframe already exists in the container"); - return Promise.resolve(); + container?.removeChild(iframeElem); + return new Promise((resolve) => this.#loadEnclave().then(resolve)); } // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy#directives @@ -149,7 +152,6 @@ export class IframeEnclave implements EnclaveProvider { this.iframe.style.setProperty(k, v); } - const container = document.querySelector(this.container); if (!container) throw new Error(`Can't find container with selector ${this.container}`); container.appendChild(this.iframe); From 3534ce81085e260ad4cd629cdc954ec76f42c24a Mon Sep 17 00:00:00 2001 From: ditoglez Date: Mon, 9 Dec 2024 12:58:06 +0200 Subject: [PATCH 04/10] chore(issuer-sdk): rollback version for release (#382) --- packages/issuer-sdk-js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/issuer-sdk-js/package.json b/packages/issuer-sdk-js/package.json index e6fa5cb26..01e50b0e1 100644 --- a/packages/issuer-sdk-js/package.json +++ b/packages/issuer-sdk-js/package.json @@ -1,7 +1,7 @@ { "name": "@idos-network/issuer-sdk-js", "description": "idOS Issuer JavaScript SDK", - "version": "0.0.1", + "version": "0.0.0", "homepage": "https://idos.network", "type": "module", "repository": { From e7cec3d326f5655b268925f1445cd37773273c52 Mon Sep 17 00:00:00 2001 From: Mo <51370781+Mohammed-Mamoun98@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:00:05 +0200 Subject: [PATCH 05/10] feat: remove extra iframe creation (#380) --- .../lib/enclave-providers/iframe-enclave.ts | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts b/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts index 1133e7346..dd4eef765 100644 --- a/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts +++ b/packages/idos-sdk-js/src/lib/enclave-providers/iframe-enclave.ts @@ -110,15 +110,10 @@ export class IframeEnclave implements EnclaveProvider { }) as Promise; } - async #loadEnclave(): Promise { - const container = document.querySelector(this.container); - const iframeElem = document.getElementById(this.iframe.id); - - if (iframeElem) { - console.warn("An Iframe already exists in the container"); - container?.removeChild(iframeElem); - return new Promise((resolve) => this.#loadEnclave().then(resolve)); - } + async #loadEnclave(): Promise { + const container = + document.querySelector(this.container) || + throwNew(Error, `Can't find container with selector ${this.container}`); // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy#directives const permissionsPolicies = ["publickey-credentials-get", "storage-access"]; @@ -152,11 +147,23 @@ export class IframeEnclave implements EnclaveProvider { this.iframe.style.setProperty(k, v); } - if (!container) throw new Error(`Can't find container with selector ${this.container}`); - + let el: HTMLElement | null; + // biome-ignore lint/suspicious/noAssignInExpressions: it's on purpose + while ((el = document.getElementById(this.iframe.id))) { + console.log("reinstalling idOS iframe..."); + container.removeChild(el); + } container.appendChild(this.iframe); - return new Promise((resolve) => this.iframe.addEventListener("load", resolve)); + return new Promise((resolve) => + this.iframe.addEventListener( + "load", + () => { + resolve(); + }, + { once: true }, + ), + ); } #showEnclave() { @@ -240,3 +247,7 @@ export class IframeEnclave implements EnclaveProvider { }; } } + +function throwNew(ErrorClass: ErrorConstructor, ...args: Parameters): never { + throw new ErrorClass(...args); +} From e5d4bf2a27ce11b7d2ec2e4074bd085bf6275580 Mon Sep 17 00:00:00 2001 From: Fernando Gonzalez Goncharov Date: Mon, 9 Dec 2024 13:39:13 +0200 Subject: [PATCH 06/10] chore(issuer-sdk): public publish config --- packages/issuer-sdk-js/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/issuer-sdk-js/package.json b/packages/issuer-sdk-js/package.json index 01e50b0e1..e58095e41 100644 --- a/packages/issuer-sdk-js/package.json +++ b/packages/issuer-sdk-js/package.json @@ -2,6 +2,9 @@ "name": "@idos-network/issuer-sdk-js", "description": "idOS Issuer JavaScript SDK", "version": "0.0.0", + "publishConfig": { + "access": "public" + }, "homepage": "https://idos.network", "type": "module", "repository": { From 95643a8ac78e11f95a9a5eee8e4e5bb164fff47c Mon Sep 17 00:00:00 2001 From: Fernando Gonzalez Goncharov Date: Mon, 9 Dec 2024 13:40:37 +0200 Subject: [PATCH 07/10] chore: release @idos-network/issuer-sdk-js v0.0.1-0 --- packages/issuer-sdk-js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/issuer-sdk-js/package.json b/packages/issuer-sdk-js/package.json index e58095e41..ba2bce77a 100644 --- a/packages/issuer-sdk-js/package.json +++ b/packages/issuer-sdk-js/package.json @@ -1,7 +1,7 @@ { "name": "@idos-network/issuer-sdk-js", "description": "idOS Issuer JavaScript SDK", - "version": "0.0.0", + "version": "0.0.1-0", "publishConfig": { "access": "public" }, From fe042366a26ab6857a09de772db6ffecedfbb6a4 Mon Sep 17 00:00:00 2001 From: ditoglez Date: Tue, 10 Dec 2024 11:37:56 +0200 Subject: [PATCH 08/10] docs(issuer-sdk): update README (#383) --- packages/issuer-sdk-js/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/issuer-sdk-js/README.md b/packages/issuer-sdk-js/README.md index 38300a55a..481e0d2c3 100644 --- a/packages/issuer-sdk-js/README.md +++ b/packages/issuer-sdk-js/README.md @@ -42,7 +42,7 @@ To create a human profile in idOS, you need: 2. **A public encryption key** derived from either a password or a passkey chosen by the user in the idOS enclave app. ### Human Creation Process -Human Creation Process +Human Creation Process #### Step 1: Decide on a human id From 03231357675483b303dd9779bfffda6b0428884c Mon Sep 17 00:00:00 2001 From: Fernando Gonzalez Goncharov Date: Tue, 10 Dec 2024 11:39:47 +0200 Subject: [PATCH 09/10] chore: release @idos-network/issuer-sdk-js v0.0.1 --- packages/issuer-sdk-js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/issuer-sdk-js/package.json b/packages/issuer-sdk-js/package.json index ba2bce77a..92b3ded0a 100644 --- a/packages/issuer-sdk-js/package.json +++ b/packages/issuer-sdk-js/package.json @@ -1,7 +1,7 @@ { "name": "@idos-network/issuer-sdk-js", "description": "idOS Issuer JavaScript SDK", - "version": "0.0.1-0", + "version": "0.0.1", "publishConfig": { "access": "public" }, From bbff067ee9aa8dde788556f382743ab3356561d8 Mon Sep 17 00:00:00 2001 From: Fernando Gonzalez Goncharov Date: Tue, 10 Dec 2024 11:51:09 +0200 Subject: [PATCH 10/10] chore: release @idos-network/idos-sdk v0.3.5-0 --- packages/idos-sdk-js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/idos-sdk-js/package.json b/packages/idos-sdk-js/package.json index 3a7a5b6a8..1fb9e1930 100644 --- a/packages/idos-sdk-js/package.json +++ b/packages/idos-sdk-js/package.json @@ -1,7 +1,7 @@ { "name": "@idos-network/idos-sdk", "description": "idOS JavaScript SDK", - "version": "0.3.4", + "version": "0.3.5-0", "homepage": "https://idos.network", "repository": "https://github.com/idos-network/idos-sdk-js", "license": "MIT",