From 0689da7e3fde62096c46417db3f0673e995fc758 Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Sun, 24 Sep 2023 14:42:41 +0300 Subject: [PATCH 1/4] WIP: Removed the exstra line for encoding base24. --- packages/UI/examples/server-example/src/server.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/UI/examples/server-example/src/server.ts b/packages/UI/examples/server-example/src/server.ts index eea033cdc6..679dde433b 100644 --- a/packages/UI/examples/server-example/src/server.ts +++ b/packages/UI/examples/server-example/src/server.ts @@ -27,8 +27,7 @@ type Payload = { const verify = async (payload: Payload) => { try { - const content = Uint8Array.from(Buffer.from(payload.content || "", "base64")); - const hash = MD5(content.toString()).toString(); + const hash = MD5(payload.content!).toString(); const messageBytes = Uint8Array.from(Buffer.from(hash.toString(), "hex")); const keyring = new Keyring({ type: payload.keypairType }); @@ -38,9 +37,8 @@ const verify = async (payload: Payload) => { const key = keyring.addFromAddress(payload.pubkey); const sig = Uint8Array.from(Buffer.from(payload.signature, "hex")); - // Verify the signature - const isValid = key.verify(messageBytes, sig, key.publicKey); - return { isValid }; + // Verify and return the signature + return key.verify(messageBytes, sig, key.publicKey); } catch (error) { console.error(error); // Handle any errors that occur during the verification process From 29ffec414de6c213663667a3132619a543d22fd2 Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Wed, 4 Oct 2023 14:45:48 +0300 Subject: [PATCH 2/4] Update the path in the web_component.md. --- packages/UI/docs/web_component.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/UI/docs/web_component.md b/packages/UI/docs/web_component.md index 55006ee8e4..8924f69644 100644 --- a/packages/UI/docs/web_component.md +++ b/packages/UI/docs/web_component.md @@ -22,7 +22,7 @@ $ tfgrid-sdk-ts/packages/UI: yarn build ```sh $ tfgrid-sdk-ts/packages/UI: cd ... -$ tfgrid-sdk-ts: cp packages/UI/dist packages/UI/examples/html-tag-example/ +$ tfgrid-sdk-ts: cp -r packages/UI/dist packages/UI/examples/html-tag-example/ ``` 4. Run the `index.html` file in a local server and navigate to it. This will allow you to test and interact with the `` and `` tags within your web application. From 5e14831ffb9ecc7897d80335cc3d4d8748e6b805 Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Mon, 9 Oct 2023 14:48:44 +0300 Subject: [PATCH 3/4] Fix comments. --- README.md | 1 + packages/UI/docs/pdf_viewer.md | 10 +++++++--- packages/UI/docs/script_editor.md | 8 +++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 21f25e2d7a..d163caa7cf 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ This repo contains the typescript clients and projects for Threefold grid. - [rmb peer client](./packages/rmb_peer_client/README.md) - [rmb peer server](./packages/rmb_peer_server/README.md) - [Playground](./packages/playground/README.md) +- [UI](./packages/UI/README.md) ## Requirements diff --git a/packages/UI/docs/pdf_viewer.md b/packages/UI/docs/pdf_viewer.md index 2d20e1d3e2..b0aa105a68 100644 --- a/packages/UI/docs/pdf_viewer.md +++ b/packages/UI/docs/pdf_viewer.md @@ -28,11 +28,13 @@ To use the PDF Signer Web Component, follow these steps: 2. Navigate to the `repository/packages/UI` directory. -3. Run `yarn build` to generate the required distribution files. +3. Chose wich provider you gonna use [see providers section](#using-providers-and-extensions) -4. Locate the `dist` folder created in the previous step. +4. Run `yarn build` to generate the required distribution files. -5. Copy the `dist/threefold-ui.umd.js` file and include it in your project's HTML files. +5. Locate the `dist` folder created in the previous step. + +6. Copy the `dist/threefold-ui.umd.js` file and include it in your project's HTML files. ```html @@ -101,6 +103,8 @@ Here's an example of how to use the PDF Signer Web Component in your HTML file: In the example above, replace `` and `` with the actual URLs for your PDF document and the destination where signed documents should be sent. Also, for the ``, use one of the following network options: `[main, test, qa, dev]`. +PS: Please make sure that you have a `PDF URL` with `CORS-ORIGIN` enabled. + Feel free to customize the HTML structure and styles to match your application's design and requirements. **Now you can serve your HTML file on any live-server plugin.** diff --git a/packages/UI/docs/script_editor.md b/packages/UI/docs/script_editor.md index d536334a58..1d7ce7e200 100644 --- a/packages/UI/docs/script_editor.md +++ b/packages/UI/docs/script_editor.md @@ -27,11 +27,13 @@ To create an instance of the Script Editor, follow these steps: 2. Navigate to the `repository/packages/UI` directory. -3. Run `yarn build` to generate the required distribution files. +3. Chose wich provider you gonna use [see providers section](#using-providers-and-extensions) -4. Locate the `dist` folder created in the previous step. +4. Run `yarn build` to generate the required distribution files. -5. Copy the `dist/threefold-ui.umd.js` file and include it in your project's HTML files. +5. Locate the `dist` folder created in the previous step. + +6. Copy the `dist/threefold-ui.umd.js` file and include it in your project's HTML files. ```html From dc7354ecac4f37c331850a5947830cee700e326b Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Mon, 9 Oct 2023 15:16:23 +0300 Subject: [PATCH 4/4] Return a hint message if the user provided a pdf url with disabled cores --- packages/UI/docs/pdf_viewer.md | 2 +- packages/UI/docs/script_editor.md | 2 +- packages/UI/src/components/PDFSignerViewComponent.vue | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/UI/docs/pdf_viewer.md b/packages/UI/docs/pdf_viewer.md index b0aa105a68..ddbc0f536b 100644 --- a/packages/UI/docs/pdf_viewer.md +++ b/packages/UI/docs/pdf_viewer.md @@ -28,7 +28,7 @@ To use the PDF Signer Web Component, follow these steps: 2. Navigate to the `repository/packages/UI` directory. -3. Chose wich provider you gonna use [see providers section](#using-providers-and-extensions) +3. Choose which provider you are going to use [see providers section](#using-providers-and-extensions) 4. Run `yarn build` to generate the required distribution files. diff --git a/packages/UI/docs/script_editor.md b/packages/UI/docs/script_editor.md index 1d7ce7e200..6b339cdf3b 100644 --- a/packages/UI/docs/script_editor.md +++ b/packages/UI/docs/script_editor.md @@ -27,7 +27,7 @@ To create an instance of the Script Editor, follow these steps: 2. Navigate to the `repository/packages/UI` directory. -3. Chose wich provider you gonna use [see providers section](#using-providers-and-extensions) +3. Choose which provider you are going to use [see providers section](#using-providers-and-extensions) 4. Run `yarn build` to generate the required distribution files. diff --git a/packages/UI/src/components/PDFSignerViewComponent.vue b/packages/UI/src/components/PDFSignerViewComponent.vue index f4c308d184..680791384b 100644 --- a/packages/UI/src/components/PDFSignerViewComponent.vue +++ b/packages/UI/src/components/PDFSignerViewComponent.vue @@ -111,7 +111,10 @@ export default { pdfData.value = data.toString(); numOfPages.value = pdf.numPages; } catch (error: any) { - showError({ isError: true, errorMessage: error.message }); + showError({ + isError: true, + errorMessage: "Please make sure that you have provided a PDF URL with CORS enabled.", + }); } finally { loadingPdf.value = false; }