szafran98 commited on
Commit
e75c279
·
1 Parent(s): bca351a

Removed token, fixed text search

Browse files
src/components/PluginImageUploader.vue CHANGED
@@ -16,7 +16,6 @@ import PluginLoader from "@plugin/components/PluginLoader.vue";
16
  import PluginSearchInput from "@plugin/components/PluginSearchInput.vue";
17
  import axios from "axios";
18
  import useSnackbar from "@plugin/composables/snackbar.ts";
19
- import { dawajKlucz } from "@plugin/services/Token.ts";
20
 
21
  type VariantType = 'area' | 'button-card' | 'button'
22
 
@@ -58,9 +57,9 @@ const emit = defineEmits<{
58
 
59
  const { createNotification } = useSnackbar();
60
 
61
- // Refs
62
  const acceptedFileExtensions = ref('.jpg, .jpeg, .png, .webp')
63
- const additionalFileExtentions = ref('.tiff, .heic, .heif, .avif')
64
  const minimumBase64FileChars = ref(512)
65
  const minDimension = ref(100)
66
  const isDragging = ref(false)
@@ -71,7 +70,6 @@ const inputSearch = ref('')
71
  const isTextSearch = ref(false)
72
  const uploadImg = useTemplateRef<HTMLInputElement>('uploadImg')
73
  const dragArea = useTemplateRef<HTMLDivElement>('dragArea')
74
- const tkn = ref('')
75
 
76
  const hostAddress = inject('hostAddress')
77
  const utmMedium = inject('utmMedium')
@@ -92,7 +90,8 @@ const newTextSearch = (): void => {
92
 
93
  isTextSearch.value = true
94
 
95
- emit('upload', `${hostAddress}/en/search-by-text?desc=${inputSearch.value}&type=relatedText&page=1?utm_source=plugin&utm_medium=${utmMedium}&utm_campaign=${utmCampaign}`)
 
96
  }
97
 
98
  const onDragEnter = (): void => {
@@ -154,18 +153,14 @@ const processAndSendSelectedFile = async (): Promise<void> => {
154
  }
155
  const fileExtension = selectedFile.value.name.split('.').pop()?.toLowerCase() || ''
156
  if (additionalFileExtentions.value.includes(fileExtension)) {
157
- const [token, tokenEncrypted] = [tkn.value, dawajKlucz(tkn.value)]
158
 
159
  const formData = new FormData()
160
  formData.append('file', selectedFile.value)
161
- formData.append("facial_search_consent", 'false');
162
- formData.append("token", token);
163
- formData.append("tokenEncrypted", tokenEncrypted);
164
  const headers = { 'Content-Type': 'multipart/form-data' }
165
  try {
166
  const response = await axios.post(`${hostAddress}/api/upload/process/file`, formData, { headers })
167
  const sentFileId = response.data.id
168
- emit('upload', `${hostAddress}/en/results/${sentFileId}?utm_source=plugin&utm_medium=${utmMedium}&utm_campaign=${utmCampaign}`)
169
  isFileProcessing.value = false
170
  } catch (exception: any) {
171
  resetProcessedFile()
@@ -181,8 +176,6 @@ const processAndSendSelectedFile = async (): Promise<void> => {
181
  })
182
  }
183
  isFileProcessing.value = false
184
- } finally {
185
- await fetchTkn()
186
  }
187
  } else {
188
  const base64File = await convertFileToBase64(selectedFile.value)
@@ -196,7 +189,7 @@ const processAndSendSelectedFile = async (): Promise<void> => {
196
  return
197
  }
198
  isFileProcessing.value = false
199
- // emit('upload', `${hostAddress}/en/results/${sentFileId}?utm_source=plugin&utm_medium=${utmMedium}&utm_campaign=${utmCampaign}`)
200
  emit('upload', sentFileId)
201
  }
202
  }
@@ -247,7 +240,7 @@ const validateFileExtension = (file: File): boolean => {
247
  }
248
  if (!isValidFileExtenstion) {
249
  createNotification({
250
- message: `File should be: JPG, PNG, WEBP, TIFF, HEIC, AVIF`,
251
  type: 'error',
252
  })
253
  return false
@@ -280,7 +273,6 @@ const sendFileToServer = async (base64File: string): Promise<string | null> => {
280
  try {
281
  const response = await axios.post(`${hostAddress}/api/hugging-upload`, {
282
  image: base64File,
283
- facial_search_consent: false,
284
  })
285
  const data: UploadResponse = response.data
286
  return data.id
@@ -304,20 +296,6 @@ const sendFileToServer = async (base64File: string): Promise<string | null> => {
304
  })
305
  }
306
  return null
307
- } finally {
308
- await fetchTkn()
309
- }
310
- }
311
-
312
- const fetchTkn = async () => {
313
- try {
314
- const response = await axios.get(`${hostAddress}/api/shared-data`);
315
-
316
- if (response.data) {
317
- tkn.value = response.data.tkn
318
- }
319
- } catch (err: any) {
320
- console.log(err);
321
  }
322
  }
323
 
@@ -350,13 +328,12 @@ const selectFile = (): void => {
350
  }
351
  }
352
 
353
- // Lifecycle hooks
354
  onMounted(async () => {
355
  if (props.enablePasteListener) {
356
  window.addEventListener('paste', onPaste)
357
  }
358
 
359
- await fetchTkn();
360
  })
361
 
362
  onBeforeUnmount(() => {
 
16
  import PluginSearchInput from "@plugin/components/PluginSearchInput.vue";
17
  import axios from "axios";
18
  import useSnackbar from "@plugin/composables/snackbar.ts";
 
19
 
20
  type VariantType = 'area' | 'button-card' | 'button'
21
 
 
57
 
58
  const { createNotification } = useSnackbar();
59
 
60
+
61
  const acceptedFileExtensions = ref('.jpg, .jpeg, .png, .webp')
62
+ const additionalFileExtentions = ref('')
63
  const minimumBase64FileChars = ref(512)
64
  const minDimension = ref(100)
65
  const isDragging = ref(false)
 
70
  const isTextSearch = ref(false)
71
  const uploadImg = useTemplateRef<HTMLInputElement>('uploadImg')
72
  const dragArea = useTemplateRef<HTMLDivElement>('dragArea')
 
73
 
74
  const hostAddress = inject('hostAddress')
75
  const utmMedium = inject('utmMedium')
 
90
 
91
  isTextSearch.value = true
92
 
93
+
94
+ window.open(`${hostAddress}/en/search-by-text?desc=${inputSearch.value}&type=relatedText&page=1?utm_source=referral&utm_medium=${utmMedium}&utm_campaign=${utmCampaign}`, '_blank')
95
  }
96
 
97
  const onDragEnter = (): void => {
 
153
  }
154
  const fileExtension = selectedFile.value.name.split('.').pop()?.toLowerCase() || ''
155
  if (additionalFileExtentions.value.includes(fileExtension)) {
 
156
 
157
  const formData = new FormData()
158
  formData.append('file', selectedFile.value)
 
 
 
159
  const headers = { 'Content-Type': 'multipart/form-data' }
160
  try {
161
  const response = await axios.post(`${hostAddress}/api/upload/process/file`, formData, { headers })
162
  const sentFileId = response.data.id
163
+ emit('upload', `${hostAddress}/en/results/${sentFileId}?utm_source=referral&utm_medium=${utmMedium}&utm_campaign=${utmCampaign}`)
164
  isFileProcessing.value = false
165
  } catch (exception: any) {
166
  resetProcessedFile()
 
176
  })
177
  }
178
  isFileProcessing.value = false
 
 
179
  }
180
  } else {
181
  const base64File = await convertFileToBase64(selectedFile.value)
 
189
  return
190
  }
191
  isFileProcessing.value = false
192
+
193
  emit('upload', sentFileId)
194
  }
195
  }
 
240
  }
241
  if (!isValidFileExtenstion) {
242
  createNotification({
243
+ message: `File should be: JPG, JPEG, PNG, WEBP`,
244
  type: 'error',
245
  })
246
  return false
 
273
  try {
274
  const response = await axios.post(`${hostAddress}/api/hugging-upload`, {
275
  image: base64File,
 
276
  })
277
  const data: UploadResponse = response.data
278
  return data.id
 
296
  })
297
  }
298
  return null
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  }
300
  }
301
 
 
328
  }
329
  }
330
 
331
+
332
  onMounted(async () => {
333
  if (props.enablePasteListener) {
334
  window.addEventListener('paste', onPaste)
335
  }
336
 
 
337
  })
338
 
339
  onBeforeUnmount(() => {
src/services/Token.ts DELETED
@@ -1,7 +0,0 @@
1
- import { MD5 } from 'crypto-js';
2
-
3
- var dawajKlucz;
4
-
5
- function _0x2ac5(){const _0xebea84=['137870GPVHjN','ersed','pmgek','143LKBQDI','51102JBIZmP','lengt','map','17560tHiBDn','6jLPcwG','fromC','slice','push','ing','582126acVJSk','Drnoy','333Taoqnr','encod','toRev','553352HRYYZW','143065FShtjH','hXCEW','pbtAf','JpHrq','1007818zKdUCy','eARGA','harCo','toStr','85NvRnxc','join'];_0x2ac5=function(){return _0xebea84;};return _0x2ac5();}function _0x40a8(_0x2f9652,_0x26245a){const _0x58f244=_0x2ac5();return _0x40a8=function(_0xd7dd25,_0x2f30d8){_0xd7dd25=_0xd7dd25-(-0x19b2+-0x1*0x41d+0x1f7a);let _0x36cb8a=_0x58f244[_0xd7dd25];return _0x36cb8a;},_0x40a8(_0x2f9652,_0x26245a);}(function(_0x414eee,_0x1612da){const _0x42ecd7=_0x414eee();function _0x1e504f(_0x4be498,_0x42f998,_0x2e3ba1,_0x4e4825,_0x23a426){return _0x40a8(_0x4be498-0x45,_0x2e3ba1);}function _0x45ab6d(_0x542558,_0x28cdd7,_0x52fe03,_0x351224,_0x118a31){return _0x40a8(_0x351224- -0x35a,_0x52fe03);}function _0xd58536(_0xb526c3,_0x13dad3,_0x3cf43d,_0xe665e9,_0x3fa771){return _0x40a8(_0xe665e9-0x250,_0x13dad3);}function _0x4ebd90(_0x1869b2,_0x1ccf94,_0x1f0ada,_0x3ed7c3,_0x16aafb){return _0x40a8(_0x3ed7c3- -0x1d1,_0x16aafb);}function _0x43c558(_0x2c90b9,_0x29b652,_0x6e4bfc,_0x17b045,_0x15aabd){return _0x40a8(_0x6e4bfc-0x300,_0x15aabd);}while(!![]){try{const _0x39f9b9=parseInt(_0x45ab6d(-0x19e,-0x196,-0x18e,-0x197,-0x18b))/(-0x1b34+-0xc54*0x2+0xbb*0x47)+-parseInt(_0x45ab6d(-0x192,-0x1a4,-0x1a6,-0x19d,-0x192))/(0x970+-0xb85*-0x1+-0x14f3)+parseInt(_0xd58536(0x3ff,0x3fe,0x40b,0x408,0x413))/(0x1*-0x19c7+0x2*0xfd7+-0x5e4)*(parseInt(_0xd58536(0x40f,0x412,0x40c,0x412,0x413))/(0xf*-0x66+0x8d1*0x1+0x3*-0xf1))+-parseInt(_0x4ebd90(-0x23,-0x1d,-0x19,-0x23,-0x1a))/(0x1*-0x4b4+0x1b03+0x12*-0x13d)*(parseInt(_0x45ab6d(-0x19c,-0x1a2,-0x1ad,-0x1a6,-0x199))/(0x7e0+-0x194e+0x2*0x8ba))+parseInt(_0x1e504f(0x20c,0x202,0x21a,0x211,0x205))/(-0x75f*-0x2+-0x1*0x153+-0x2*0x6b2)+-parseInt(_0xd58536(0x40f,0x414,0x3f9,0x407,0x400))/(-0x2443+-0x1*0x260b+0xede*0x5)*(parseInt(_0x4ebd90(-0xe,-0xd,-0x5,-0x12,-0xb))/(-0x95e+-0x2*-0xea2+0x153*-0xf))+parseInt(_0xd58536(0x40e,0x401,0x40e,0x400,0x401))/(0x12db+0x2406+-0x36d7*0x1)*(parseInt(_0x4ebd90(-0x21,-0x1d,-0x1b,-0x1e,-0x2c))/(-0x28b+0x1875+-0x15df));if(_0x39f9b9===_0x1612da)break;else _0x42ecd7['push'](_0x42ecd7['shift']());}catch(_0x401a8b){_0x42ecd7['push'](_0x42ecd7['shift']());}}}(_0x2ac5,-0x2*-0x23948+-0xbf21+0x1046*-0x4),dawajKlucz=_0x1bd060=>{const _0x470f00={'pmgek':function(_0x1152ed,_0x59dbe0){return _0x1152ed<_0x59dbe0;},'JpHrq':function(_0x470cb6,_0x257d3e){return _0x470cb6^_0x257d3e;},'hXCEW':function(_0x544f35,_0x19fd30){return _0x544f35-_0x19fd30;},'pbtAf':function(_0x4ada59,_0x42a6c1){return _0x4ada59(_0x42a6c1);},'Drnoy':function(_0xf7d9d7,_0x21e60a){return _0xf7d9d7===_0x21e60a;},'eARGA':function(_0x37c9a7,_0x3df7cd){return _0x37c9a7+_0x3df7cd;}},_0x34c00d=new TextEncoder()[_0x4ebea2(0x2e2,0x2e0,0x2d8,0x2d4,0x2cd)+'e'](_0x1bd060),_0x58a556=_0x34c00d[_0x4ebea2(0x2c6,0x2c8,0x2ce,0x2d2,0x2c5)](_0xff86e4=>_0xff86e4^-0x15f7+0xa*-0xa+0x1705);function _0x4ebea2(_0x256d6f,_0x2be25d,_0x2e8fd5,_0x72ac2,_0x45ae61){return _0x40a8(_0x2e8fd5-0x118,_0x2be25d);}for(let _0x32577d=0x223e+0x536*0x3+-0x31e0;_0x470f00[_0x54ba9c(0x51f,0x52d,0x529,0x52c,0x522)](_0x32577d,_0x58a556[_0x54ba9c(0x52e,0x528,0x531,0x52f,0x52a)+'h']);_0x32577d++){_0x58a556[_0x32577d]=_0x470f00[_0x4ebea2(0x2cf,0x2e4,0x2de,0x2d6,0x2ec)](~_0x58a556[_0x32577d],_0x32577d);}let _0x3bfe47=String[_0x4ebea2(0x2d9,0x2df,0x2d1,0x2c2,0x2ce)+_0x2d38f1(0x3ea,0x3dd,0x3e6,0x3d8,0x3e9)+'de'](..._0x58a556);_0x3bfe47=_0x3bfe47[_0x54ba9c(0x533,0x531,0x540,0x534,0x527)](-0x54+-0x923+0x979,_0x470f00[_0x300053(0xc3,0xbd,0xc2,0xd1,0xb5)](_0x3bfe47[_0x4ebea2(0x2c0,0x2d4,0x2cd,0x2cf,0x2be)+'h'],0x909+-0x24d0+-0x943*-0x3));function _0x311659(_0x2163c0,_0x175efa,_0x8ff85,_0x4b5029,_0x2e5292){return _0x40a8(_0x2e5292-0x2a,_0x175efa);}const _0x15efa7=_0x470f00[_0x311659(0x1fd,0x1f7,0x1fd,0x1e1,0x1ef)](MD5,_0x3bfe47)[_0x4ebea2(0x2be,0x2c9,0x2c5,0x2b7,0x2d0)+_0x54ba9c(0x540,0x53d,0x52b,0x536,0x53c)]();function _0x2d38f1(_0x5bb0e8,_0x2f8d0c,_0x1eeb65,_0x2be7a5,_0x24e2a3){return _0x40a8(_0x1eeb65-0x23a,_0x2be7a5);}function _0x300053(_0x3eb725,_0x2a4017,_0x143d60,_0x531f07,_0x9103aa){return _0x40a8(_0x3eb725- -0x101,_0x143d60);}function _0x54ba9c(_0x352405,_0xf3b00,_0x3742b9,_0x48c770,_0xbecfcf){return _0x40a8(_0x48c770-0x37a,_0xf3b00);}let _0x30976a=[];for(let _0x4bd592=-0x21bb+-0x1f67*-0x1+0x12a*0x2;_0x470f00[_0x300053(0xb1,0xc0,0xba,0xa3,0xab)](_0x4bd592,_0x15efa7[_0x311659(0x1df,0x1e7,0x1e6,0x1e7,0x1df)+'h']);_0x4bd592+=-0x1*-0x17c9+-0x8e6+-0x4f5*0x3){if(_0x470f00[_0x4ebea2(0x2c7,0x2de,0x2d6,0x2ce,0x2d0)](_0x4bd592,-0x17b3*-0x1+-0xc75*0x2+0x137)||_0x470f00[_0x300053(0xbd,0xbd,0xc2,0xae,0xb0)](_0x4bd592,0x4c3+-0x2*0x4d5+0x4ef)||_0x470f00[_0x54ba9c(0x539,0x534,0x541,0x538,0x53f)](_0x4bd592,0x2676+0xe99*-0x1+-0x17cd)||_0x470f00[_0x54ba9c(0x52b,0x533,0x53d,0x538,0x546)](_0x4bd592,0x2*-0x656+0x549+0x77b))continue;_0x30976a[_0x4ebea2(0x2d0,0x2da,0x2d3,0x2de,0x2d4)](_0x15efa7[_0x54ba9c(0x52d,0x526,0x535,0x534,0x541)](_0x4bd592,_0x470f00[_0x2d38f1(0x3e2,0x3d9,0x3e5,0x3ea,0x3ea)](_0x4bd592,0x11f*0x13+0x12cb+-0x5a*0x72)));}const _0x40afd5=_0x30976a[_0x311659(0x1e3,0x1e5,0x1e4,0x1f2,0x1eb)+_0x54ba9c(0x52b,0x53a,0x533,0x52b,0x52d)]()[_0x2d38f1(0x3f3,0x3e8,0x3e9,0x3ed,0x3f8)]('');return _0x40afd5;});
6
-
7
- export { dawajKlucz }