Skip to content

Commit

Permalink
Fix content in script editor (#1212)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaelgohary authored Oct 16, 2023
1 parent 05a938a commit 0e4b3c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/UI/examples/html-tag-example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@
<title>Threefold UI</title>

<!-- Include the PDF style component, uncomment the script line after copying the build js/css in the same dir -->
<!-- <link rel="stylesheet" href="./style.css"> -->
<link rel="stylesheet" href="./tailwind.css">
</head>

<body>

<!-- Use the pdf-signer custom element with required attributes -->
<pdf-signer dest="http://localhost:3000/"
<pdf-signer dest="http://localhost:3000/api/verify"
pdfUrl="https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf"
network="dev" />

<!-- <script-editor dest="http://localhost:3000/api/verify"
network="dev" /> -->
<!-- Include the PDF Signer component script, uncomment the script line after copying the build js/css in the same dir -->
<!-- <script src="./pdf.js"></script> -->
<script src="./threefold-ui.umd.js"></script>
</body>

</html>
10 changes: 9 additions & 1 deletion packages/UI/src/utils/threefoldSignerProvider.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import axios from "axios";

import { sign, type SignReturn } from "./sign";
import { KeypairType, sign, type SignReturn } from "./sign";
import { type AcceptConfig, type ErrorType, type RequestData, type SignProps, ThreefoldProvider } from "./types";

export default class ThreefoldSigner extends ThreefoldProvider {
private MNEMONIC = import.meta.env.VITE_MNEMONIC;
private CONFIG: AcceptConfig = {
scriptContent: "",
pdfData: "",
keypairType: KeypairType.sr25519,
};

async use(props: SignProps): Promise<ErrorType> {
console.warn("Using the normal provider, Please make sure that you provide the mnemonic in the .env file.");
Expand All @@ -29,6 +34,8 @@ export default class ThreefoldSigner extends ThreefoldProvider {
let data: SignReturn;

try {
this.CONFIG = config;

if (config.pdfData) {
data = await sign(config.pdfData, this.MNEMONIC, config.keypairType);
return await this.__request(data);
Expand All @@ -45,6 +52,7 @@ export default class ThreefoldSigner extends ThreefoldProvider {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
private async __request(data: SignReturn, account?: boolean): Promise<ErrorType> {
const requestBody: RequestData = {
content: this.CONFIG.scriptContent,
pdfUrl: this.props.pdfurl,
pubkey: data.publicKey,
signature: data.signature,
Expand Down

0 comments on commit 0e4b3c4

Please sign in to comment.