@ozdao/prometheus-framework 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozdao/prometheus-framework",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Web3 Framework focused on user experience and ease of development.",
5
5
  "author": "OZ DAO <hello@ozdao.dev>",
6
6
  "license": "GPL-3.0-or-later",
@@ -153,6 +153,7 @@
153
153
  "vue": "^3.2.25"
154
154
  },
155
155
  "devDependencies": {
156
+ "@babel/preset-flow": "^7.22.15",
156
157
  "@babel/runtime": "^7.21.5",
157
158
  "@rollup/plugin-babel": "^6.0.3",
158
159
  "@rollup/plugin-commonjs": "^25.0.4",
@@ -132,12 +132,12 @@ import { useI18n } from 'vue-i18n'
132
132
  import * as auth from '@pf/src/modules/auth/store/auth'
133
133
  // Import validation
134
134
  import * as inputsValidation from '@pf/src/modules/middlewares/client/inputs.validation'
135
-
135
+ // Init localization
136
136
  const { t } = useI18n({
137
137
  inheritLocale: true,
138
138
  useScope: 'local'
139
139
  })
140
-
140
+ // Init validation
141
141
  const phoneValidation = ref(null)
142
142
  const passswordValidation = ref(null)
143
143
  const emailValidation = ref(null)
@@ -146,51 +146,39 @@ const route = useRoute()
146
146
  const router = useRouter()
147
147
  // Accessing state
148
148
  const tabAuth = ref('phone')
149
- // Apple and Google Scripts
150
-
151
- const callOnSuccess = (data) => {
152
- // Ваш код обработки успешного входа
153
- console.log("Apple login success:", data);
154
- };
155
-
156
- const callOnFailure = (error) => {
157
- // Ваш код обработки неудачного входа
158
- console.log("Apple login failure:", error);
159
- };
160
-
149
+ // OUATH ENV
161
150
  const clientId = inject('APPLE_CLIENTID')
162
151
  const redirectURI = inject('APPLE_REDIRECT_URL')
163
152
 
164
- const initAppleSignIn = () => {
165
- if (!window.AppleID) {
166
- console.error('"https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js" needs to be included as a <script>');
167
- return;
168
- }
169
-
170
- let scope = 'email'; // Укажите необходимые scope
171
- let state = '123';
172
- let usePopup = true; // Использовать попап или нет
153
+ const appleSignIn = async () => {
173
154
 
174
- window.AppleID.auth.init({
175
- clientId,
176
- scope,
177
- redirectURI,
178
- state,
179
- usePopup
180
- });
181
-
182
- document.addEventListener('AppleIDSignInOnSuccess', callOnSuccess);
183
- document.addEventListener('AppleIDSignInOnFailure', callOnFailure);
184
- };
185
-
186
-
187
-
188
- const appleSignIn = () => {
189
- try {
190
- window.AppleID.auth.signIn();
191
- } catch (error) {
192
- console.error("Error signing in with Apple:", error);
193
- }
155
+ window.AppleID.auth.init({
156
+ clientId: clientId,
157
+ scope: 'email name',
158
+ redirectURI: redirectURI,
159
+ usePopup: true,
160
+ });
161
+ /** Signin to appleID */
162
+ return window.AppleID.auth
163
+ .signIn()
164
+ .then((response) => {
165
+ /** This is only called in case usePopup is true */
166
+ if (onSuccess) {
167
+ onSuccess(response);
168
+ }
169
+ /** resolve with the reponse */
170
+ return response;
171
+ })
172
+ .catch((err) => {
173
+ if (onError) {
174
+ /** Call onError catching the error */
175
+ onError(err);
176
+ } else {
177
+ /** Log the error to help debug */
178
+ console.error(err);
179
+ }
180
+ return null;
181
+ });
194
182
  };
195
183
 
196
184
  const loadExternalScript = (src) => {
@@ -205,12 +193,7 @@ const loadExternalScript = (src) => {
205
193
  }
206
194
 
207
195
  onMounted(async () => {
208
- try {
209
- await loadExternalScript('https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js');
210
- initAppleSignIn();
211
- } catch (error) {
212
- console.error('Error loading AppleID script:', error);
213
- }
196
+ await loadExternalScript('https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js');
214
197
  });
215
198
  // Methods
216
199
  async function onSubmit() {