-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo2.html
57 lines (52 loc) · 1.6 KB
/
demo2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Autogram SDK</title>
</head>
<body>
<h1>Welcome to Autogram SDK</h1>
<p>This is a basic HTML template.</p>
<!-- <script src="dist/demo.global.js" type="module"></script> -->
<script src="dist/index.global.js"></script>
<script>
async function main() {
const client = new AutogramSDK.FullClient();
const filePicker = document.createElement("input");
filePicker.type = "file";
filePicker.addEventListener("change", async (e) => {
const file = filePicker.files?.[0];
if (!file) return;
const signedObject = await client.sign(
{
content: await file.text(),
filename: file.name,
},
{
level: "XAdES_BASELINE_B",
container: "ASiC_E",
},
file.type,
true
);
console.log(signedObject);
const a = document.createElement("a");
const blob = new Blob([signedObject.content], {
type: "text/plain",
});
const url = URL.createObjectURL(blob);
a.href = url;
a.download = `${file.name}.asice`;
a.text = `Download ${a.download}`;
document.body.appendChild(a);
});
document.body.appendChild(filePicker);
}
main().then(
() => console.log("done"),
(err) => console.error(err)
);
</script>
</body>
</html>