signature: download storedObject document in the vuejs app

This commit is contained in:
nobohan 2024-06-19 09:51:21 +02:00
parent 9192883217
commit bbfd0caf10
2 changed files with 45 additions and 5 deletions

View File

@ -3,14 +3,56 @@
</template>
<script setup lang="ts">
import { ref, Ref } from "vue";
const msg: Ref<string> = ref('world !');
//import { build_download_info_link, download_and_decrypt_doc } from "ChillDocStoreAssets/vuejs/StoredObjectButton/helpers.js";
import {
build_download_info_link,
download_and_decrypt_doc,
} from "../StoredObjectButton/helpers";
const msg: Ref<string> = ref("world !");
//console.log('signature', window.signature);
const signature = {
id: 1,
storedObject: {
filename: "pKNlhCrQDCRsAuC8vYHDKa",
keyInfos: {
alg: "A256CBC",
ext: true,
k: "_VihnD41-VDHlpS-ouwtbMPnu-OXVdtA7ENQWWtAQYM",
key_ops: ["encrypt", "decrypt"],
kty: "oct",
},
iv: [
86, 231, 83, 148, 117, 107, 149, 173, 130, 19, 105, 194, 224, 145, 8, 48,
],
},
zones: [{ page: 1, origin: [0, 0], x: 10, y: 10 }],
};
const urlInfo = build_download_info_link(signature.storedObject.filename);
async function download_and_open(): Promise<Blob> {
let raw;
try {
raw = await download_and_decrypt_doc(
urlInfo,
signature.storedObject.keyInfos,
new Uint8Array(signature.storedObject.iv)
);
} catch (e) {
console.error("error while downloading and decrypting document", e);
throw e;
};
return raw;
}
download_and_open();
</script>
<style lang="scss">
</style>

View File

@ -1,7 +1,6 @@
import { createApp } from "vue";
// import { _createI18n } from "ChillMainAssets/vuejs/_js/i18n";
// import { appMessages } from "ChillMainAssets/vuejs/HomepageWidget/js/i18n";
//import { store } from "ChillDocStoreAssets/vuejs/DocumentSignature/store";
import App from "./App.vue";
//const i18n = _createI18n(appMessages);
@ -9,7 +8,6 @@ import App from "./App.vue";
const app = createApp({
template: `<app></app>`,
})
//.use(store)
//.use(i18n)
.component("app", App)
.mount("#document-signature");