@saooti/octopus-sdk 33.0.4 → 33.0.5

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.
package/README.md CHANGED
@@ -691,3 +691,4 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
691
691
 
692
692
  * 33.0.3 SpeechToText player octopus
693
693
  * 33.0.4 Image webp
694
+ * 33.0.5 Change recaptcha
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saooti/octopus-sdk",
3
- "version": "33.0.4",
3
+ "version": "33.0.5",
4
4
  "private": false,
5
5
  "description": "Javascript SDK for using octopus",
6
6
  "author": "Saooti",
@@ -37,7 +37,7 @@
37
37
  "vue": "^3.2.37",
38
38
  "vue-i18n": "^9.2.0-beta.40",
39
39
  "vue-multiselect": "^3.0.0-alpha.2",
40
- "vue-recaptcha-v3": "^2.0.1",
40
+ "vue-recaptcha": "^2.0.3",
41
41
  "vue-router": "^4.1.2",
42
42
  "vue3-lazyload": "^0.2.5-beta",
43
43
  "vue3-swatches": "^1.0.10",
@@ -45,11 +45,20 @@
45
45
  >
46
46
  {{ $t('Close') }}
47
47
  </button>
48
+ <vue-recaptcha
49
+ ref="invisibleRecaptcha"
50
+ :load-recaptcha-script="true"
51
+ @verify="handleSuccess"
52
+ @expired="handleError"
53
+ size="invisible"
54
+ sitekey="6LfyP_4ZAAAAAPODj8nov2LvosIwcX0GYeBSungh"
55
+ >
56
+ </vue-recaptcha>
48
57
  <button
49
58
  v-if="!sending"
50
59
  class="btn btn-primary m-1"
51
60
  :disabled="0 === countName || !validName"
52
- @click="validateName"
61
+ @click="submit"
53
62
  >
54
63
  {{ $t('Validate') }}
55
64
  </button>
@@ -63,9 +72,13 @@
63
72
  import Constants from '../../../../public/config';
64
73
  import { state } from '../../../store/paramStore';
65
74
  import api from '@/api/initialize';
66
- import { defineComponent } from 'vue'
75
+ import { VueRecaptcha } from 'vue-recaptcha';
76
+ import { defineComponent } from 'vue';
67
77
  export default defineComponent({
68
78
  name: 'AddCommentModal',
79
+ components:{
80
+ VueRecaptcha
81
+ },
69
82
 
70
83
  props: {},
71
84
  emits: ['close','validate'],
@@ -74,8 +87,8 @@ export default defineComponent({
74
87
  return {
75
88
  name: '' as string,
76
89
  sending: false as boolean,
77
- needVerify: true as boolean,
78
90
  sendError: false as boolean,
91
+ isVerify: false as boolean,
79
92
  maxName : Constants.MAX_COMMENT_NAME as number
80
93
  };
81
94
  },
@@ -97,34 +110,26 @@ export default defineComponent({
97
110
  },
98
111
  },
99
112
 
100
- mounted() {
101
- this.displayCaptcha('block');
113
+ created() {
102
114
  this.initAuthenticatedName();
103
115
  },
104
- unmounted() {
105
- this.displayCaptcha('none');
106
- },
107
116
  methods: {
108
117
  initAuthenticatedName():void{
109
118
  if (!state.generalParameters.authenticated) { return; }
110
119
  this.name = (`${this.$store.state.profile.firstname||''} ${this.$store.state.profile.lastname||''}`).trim();
111
- this.needVerify = false;
120
+ this.isVerify = true;
121
+ },
122
+ async handleSuccess(token: string) {
123
+ this.isVerify = await api.checkToken(token);
124
+ this.sendComment();
112
125
  },
113
- displayCaptcha(displayStyle: string): void{
114
- const captcha = document.getElementsByClassName('grecaptcha-badge')[0];
115
- if (!captcha) {return;}
116
- (captcha as HTMLElement).style.display = displayStyle;
126
+ handleError() {
127
+ this.isVerify = false;
128
+ this.sendError = true;
117
129
  },
118
- async validateName(): Promise<void> {
119
- if (this.needVerify && this.isCaptchaTest) {
120
- try {
121
- await this.$recaptchaLoaded()
122
- const token = await this.$recaptcha('login');
123
- this.sendError = !await api.checkToken(token);
124
- } catch {
125
- this.sendError = true;
126
- }
127
- if(this.sendError){return;}
130
+ async submit(): Promise<void> {
131
+ if (!this.isVerify && !this.isCaptchaTest) {
132
+ return (this.$refs.invisibleRecaptcha as InstanceType<typeof VueRecaptcha>).execute();
128
133
  }
129
134
  this.sendComment();
130
135
  },
package/src/main.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { createApp } from 'vue';
2
- import { VueReCaptcha } from 'vue-recaptcha-v3';
3
2
  import VueLazyLoad from 'vue3-lazyload';
4
3
  import App from './App.vue';
5
4
  import {setupI18n} from './i18n';
@@ -57,5 +56,4 @@ createApp(App)
57
56
  .use(store)
58
57
  .use(router)
59
58
  .use(VueLazyLoad)
60
- .use(VueReCaptcha, { siteKey: '6LfyP_4ZAAAAAPODj8nov2LvosIwcX0GYeBSungh' })
61
59
  .mount('#app');