valaxy 0.14.46 → 0.14.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import { useDecrypt, useFrontmatter } from 'valaxy'
3
3
  import type { Ref } from 'vue'
4
- import { defineComponent, h, inject, ref } from 'vue'
4
+ import { defineComponent, h, inject, onMounted, ref } from 'vue'
5
5
 
6
6
  const props = defineProps<{
7
7
  encryptedContent: string
@@ -59,6 +59,12 @@ const ValaxyDeprecatedContent = defineComponent({
59
59
  })
60
60
  },
61
61
  })
62
+
63
+ const hasWarning = ref(false)
64
+ onMounted(() => {
65
+ if (location.protocol !== 'https:')
66
+ hasWarning.value = true
67
+ })
62
68
  </script>
63
69
 
64
70
  <template>
@@ -84,6 +90,12 @@ const ValaxyDeprecatedContent = defineComponent({
84
90
  text-gray hover:text-black
85
91
  @click="decryptContent"
86
92
  />
93
+
94
+ <div v-if="hasWarning" class="-bottom-6" absolute text-xs op="50">
95
+ <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API" target="_blank">
96
+ <span>Web Crypto API</span>
97
+ </a> Only works in HTTPS
98
+ </div>
87
99
  </div>
88
100
  </div>
89
101
  <div v-else>
@@ -0,0 +1,68 @@
1
+ <script lang="ts" setup>
2
+ import { useDecrypt } from 'valaxy'
3
+ import { ref } from 'vue'
4
+
5
+ const props = defineProps<{
6
+ encryptedPhotos: string
7
+ }>()
8
+
9
+ const password = ref('')
10
+ const decryptedContent = ref('')
11
+
12
+ const hasError = ref(false)
13
+
14
+ const { decrypt } = useDecrypt()
15
+ async function decryptContent() {
16
+ const ciphertext = props.encryptedPhotos
17
+ if (!ciphertext)
18
+ return
19
+ try {
20
+ const result = await decrypt(password.value, ciphertext)
21
+ decryptedContent.value = result || ''
22
+ }
23
+ catch (e) {
24
+ hasError.value = true
25
+ }
26
+ }
27
+
28
+ function encryptAgain() {
29
+ decryptedContent.value = ''
30
+ password.value = ''
31
+ }
32
+ </script>
33
+
34
+ <template>
35
+ <div>
36
+ <div v-if="!decryptedContent" w-full pt-14 pb-10>
37
+ <div
38
+ class="decrypt-password-container w-full sm:w-1/2"
39
+ flex-center m-auto relative
40
+ >
41
+ <input
42
+ v-model="password"
43
+ w-full
44
+ border pl-5 pr-11 py-3 rounded hover:shadow transition
45
+ type="password" placeholder="Enter password"
46
+ :class="hasError && 'border-red'"
47
+ @input="hasError = false"
48
+ @keyup.enter="decryptContent"
49
+ >
50
+ <div
51
+ cursor-pointer
52
+ absolute text-2xl
53
+ i-ri-arrow-right-circle-line right-3
54
+ text-gray hover:text-black
55
+ @click="decryptContent"
56
+ />
57
+ </div>
58
+ </div>
59
+ <div v-else>
60
+ <YunGallery :photos="JSON.parse(decryptedContent)" />
61
+ <div w-full text-center mt-8>
62
+ <button m-auto class="btn" font-bold @click="encryptAgain">
63
+ Encrypt Again
64
+ </button>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </template>