@web3auth/modal 10.0.7 → 10.2.0
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/dist/lib.cjs/packages/modal/src/config.js +1 -1
- package/dist/lib.cjs/packages/modal/src/modalManager.js +9 -2
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +11 -7
- package/dist/lib.cjs/packages/modal/src/ui/handlers/SmsPasswordlessHandler.js +8 -10
- package/dist/lib.cjs/packages/modal/src/ui/helper/testAccounts.js +18 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/dutch.json.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +1 -0
- package/dist/lib.cjs/packages/modal/src/ui/utils.js +2 -0
- package/dist/lib.cjs/types/modalManager.d.ts +10 -1
- package/dist/lib.cjs/types/react/wagmi/constants.d.ts +1 -0
- package/dist/lib.cjs/types/ui/handlers/SmsPasswordlessHandler.d.ts +2 -2
- package/dist/lib.cjs/types/ui/helper/testAccounts.d.ts +2 -0
- package/dist/lib.cjs/types/vue/wagmi/constants.d.ts +1 -0
- package/dist/lib.esm/packages/modal/src/config.js +1 -1
- package/dist/lib.esm/packages/modal/src/modalManager.js +9 -2
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +11 -7
- package/dist/lib.esm/packages/modal/src/ui/handlers/SmsPasswordlessHandler.js +8 -10
- package/dist/lib.esm/packages/modal/src/ui/helper/testAccounts.js +16 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/dutch.json.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +1 -0
- package/dist/lib.esm/packages/modal/src/ui/utils.js +2 -0
- package/dist/modal.umd.min.js +1 -1
- package/package.json +19 -19
|
@@ -81,7 +81,10 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
81
81
|
return [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])];
|
|
82
82
|
});
|
|
83
83
|
this.options = _objectSpread({}, options);
|
|
84
|
-
if (!this.options.uiConfig) this.options.uiConfig = {
|
|
84
|
+
if (!this.options.uiConfig) this.options.uiConfig = {
|
|
85
|
+
logoLight: "",
|
|
86
|
+
logoDark: ""
|
|
87
|
+
};
|
|
85
88
|
if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
|
|
86
89
|
noModal.log.info("modalConfig", this.modalConfig);
|
|
87
90
|
}
|
|
@@ -224,9 +227,13 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
224
227
|
this.options.uiConfig = deepmerge(noModal.cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
|
|
225
228
|
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = utils.getUserLanguage(this.options.uiConfig.defaultLanguage);
|
|
226
229
|
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
|
|
227
|
-
|
|
230
|
+
const uiConfig = deepmerge.all([projectConfig.loginModal || {}, this.options.uiConfig], {
|
|
228
231
|
arrayMerge: (_, sourceArray) => sourceArray
|
|
229
232
|
});
|
|
233
|
+
this.options.uiConfig = _objectSpread(_objectSpread({}, uiConfig), {}, {
|
|
234
|
+
logoLight: uiConfig.logoLight || "",
|
|
235
|
+
logoDark: uiConfig.logoDark || ""
|
|
236
|
+
});
|
|
230
237
|
// merge login methods order from project config and user config, with user config taking precedence
|
|
231
238
|
const defaultAuthConnections = projectConfig.embeddedWalletAuth.filter(x => x.isDefault).map(x => x.authConnection);
|
|
232
239
|
const mergedAuthConnections = [...(this.options.uiConfig.loginMethodsOrder || []), ...defaultAuthConnections];
|
|
@@ -12,6 +12,7 @@ var constants = require('../../constants.js');
|
|
|
12
12
|
var AnalyticsContext = require('../../context/AnalyticsContext.js');
|
|
13
13
|
var RootContext = require('../../context/RootContext.js');
|
|
14
14
|
var factory = require('../../handlers/factory.js');
|
|
15
|
+
var testAccounts = require('../../helper/testAccounts.js');
|
|
15
16
|
var localeImport = require('../../localeImport.js');
|
|
16
17
|
var utils = require('../../utils.js');
|
|
17
18
|
var Image = require('../Image/Image.js');
|
|
@@ -162,7 +163,6 @@ function Login(props) {
|
|
|
162
163
|
}, [socialLoginsConfig, isDark, buttonRadius]);
|
|
163
164
|
const handleCustomLogin = async (authConnection, loginHint) => {
|
|
164
165
|
try {
|
|
165
|
-
var _captchaRef$current;
|
|
166
166
|
const handler = factory.createPasswordlessHandler(authConnection, {
|
|
167
167
|
loginHint,
|
|
168
168
|
web3authClientId,
|
|
@@ -171,13 +171,17 @@ function Login(props) {
|
|
|
171
171
|
authConnection,
|
|
172
172
|
authBuildEnv
|
|
173
173
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
174
|
+
let token = undefined;
|
|
175
|
+
if (!testAccounts.isTestAccountPattern(authConnection, loginHint)) {
|
|
176
|
+
var _captchaRef$current;
|
|
177
|
+
const res = await ((_captchaRef$current = captchaRef.current) === null || _captchaRef$current === void 0 ? void 0 : _captchaRef$current.execute({
|
|
178
|
+
async: true
|
|
179
|
+
}));
|
|
180
|
+
if (!res) {
|
|
181
|
+
throw noModal.WalletLoginError.connectionError("Captcha token is required");
|
|
182
|
+
}
|
|
183
|
+
token = res.response;
|
|
179
184
|
}
|
|
180
|
-
const token = res.response;
|
|
181
185
|
const result = await handler.sendVerificationCode({
|
|
182
186
|
captchaToken: token
|
|
183
187
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
4
|
var AbstractHandler = require('./AbstractHandler.js');
|
|
5
5
|
|
|
6
6
|
class SmsPasswordlessHandler extends AbstractHandler.PasswordlessHandler {
|
|
@@ -11,18 +11,15 @@ class SmsPasswordlessHandler extends AbstractHandler.PasswordlessHandler {
|
|
|
11
11
|
this.trackingId = (_window$sessionStorag = window.sessionStorage.getItem("trackingId")) !== null && _window$sessionStorag !== void 0 ? _window$sessionStorag : undefined;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
async sendVerificationCode(
|
|
15
|
-
|
|
14
|
+
async sendVerificationCode({
|
|
15
|
+
captchaToken
|
|
16
|
+
}) {
|
|
16
17
|
const {
|
|
17
18
|
loginHint,
|
|
18
19
|
network,
|
|
19
20
|
web3authClientId
|
|
20
21
|
} = this.passwordlessParams;
|
|
21
|
-
const
|
|
22
|
-
if (!captchaToken) {
|
|
23
|
-
throw noModal.WalletLoginError.connectionError("Captcha token is required");
|
|
24
|
-
}
|
|
25
|
-
const finalParams = {
|
|
22
|
+
const finalParams = _objectSpread({
|
|
26
23
|
client_id: web3authClientId,
|
|
27
24
|
web3auth_client_id: web3authClientId,
|
|
28
25
|
connection: this.connection,
|
|
@@ -30,9 +27,10 @@ class SmsPasswordlessHandler extends AbstractHandler.PasswordlessHandler {
|
|
|
30
27
|
tracking_id: this.trackingId,
|
|
31
28
|
whitelabel: this.whiteLabelParams,
|
|
32
29
|
version: this.version,
|
|
33
|
-
network
|
|
30
|
+
network
|
|
31
|
+
}, captchaToken && {
|
|
34
32
|
captcha_token: captchaToken
|
|
35
|
-
};
|
|
33
|
+
});
|
|
36
34
|
return super.start(finalParams);
|
|
37
35
|
}
|
|
38
36
|
async verifyCode(code) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var auth = require('@web3auth/auth');
|
|
4
|
+
var noModal = require('@web3auth/no-modal');
|
|
5
|
+
|
|
6
|
+
const EMAIL_TEST_ACCOUNT_PREFIX = "test_account_";
|
|
7
|
+
const EMAIL_TEST_ACCOUNT_POSTFIX = "@example.com";
|
|
8
|
+
const PHONE_TEST_ACCOUNT_PREFIX = "+1-555";
|
|
9
|
+
const isTestAccountPattern = (authConnection, loginHint) => {
|
|
10
|
+
if (authConnection === auth.AUTH_CONNECTION.EMAIL_PASSWORDLESS) {
|
|
11
|
+
return loginHint.startsWith(EMAIL_TEST_ACCOUNT_PREFIX) && loginHint.endsWith(EMAIL_TEST_ACCOUNT_POSTFIX);
|
|
12
|
+
} else if (authConnection === auth.AUTH_CONNECTION.SMS_PASSWORDLESS) {
|
|
13
|
+
return loginHint.startsWith(PHONE_TEST_ACCOUNT_PREFIX);
|
|
14
|
+
}
|
|
15
|
+
throw noModal.WalletInitializationError.invalidParams(`Unsupported auth connection: ${authConnection}`);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.isTestAccountPattern = isTestAccountPattern;
|
|
@@ -111,6 +111,7 @@ var passwordless = {
|
|
|
111
111
|
"error-plan-limit-reached": "E411. Limiet bereikt",
|
|
112
112
|
"error-recaptcha-verification-failed": "Er is iets misgegaan tijdens het verifiëren. Probeer het opnieuw door de pagina te laden.",
|
|
113
113
|
"error-sending-sms-failed": "Er is een fout opgetreden bij het verzenden van een sms. Probeer het opnieuw.",
|
|
114
|
+
"error-invalid-test-account": "Ongeldig testaccount",
|
|
114
115
|
"something-wrong-error": "Er is iets misgegaan"
|
|
115
116
|
};
|
|
116
117
|
var dutch = {
|
|
@@ -111,6 +111,7 @@ var passwordless = {
|
|
|
111
111
|
"error-plan-limit-reached": "E411. Limit Reached",
|
|
112
112
|
"error-recaptcha-verification-failed": "Captcha verification failed. Please try again.",
|
|
113
113
|
"error-sending-sms-failed": "There was an error sending an sms. Please try again.",
|
|
114
|
+
"error-invalid-test-account": "Invalid test account",
|
|
114
115
|
"something-wrong-error": "Something went wrong"
|
|
115
116
|
};
|
|
116
117
|
var en = {
|
|
@@ -109,6 +109,7 @@ var passwordless = {
|
|
|
109
109
|
"error-plan-limit-reached": "E411. Limite atteinte",
|
|
110
110
|
"error-recaptcha-verification-failed": "La vérification Captcha a échoué. Veuillez réessayer.",
|
|
111
111
|
"error-sending-sms-failed": "Une erreur s'est produite lors de l'envoi d'un SMS. Veuillez réessayer.",
|
|
112
|
+
"error-invalid-test-account": "Compte de test non valide",
|
|
112
113
|
"something-wrong-error": "Quelque chose s'est mal passé"
|
|
113
114
|
};
|
|
114
115
|
var french = {
|
|
@@ -111,6 +111,7 @@ var passwordless = {
|
|
|
111
111
|
"error-plan-limit-reached": "E411. Grenze erreicht",
|
|
112
112
|
"error-recaptcha-verification-failed": "Die Captcha-Überprüfung ist fehlgeschlagen. Bitte versuchen Sie es erneut.",
|
|
113
113
|
"error-sending-sms-failed": "Es gab einen Fehler beim Senden einer SMS. Bitte versuche es erneut.",
|
|
114
|
+
"error-invalid-test-account": "Ungültiges Testkonto",
|
|
114
115
|
"something-wrong-error": "Etwas ist schief gelaufen"
|
|
115
116
|
};
|
|
116
117
|
var german = {
|
|
@@ -111,6 +111,7 @@ var passwordless = {
|
|
|
111
111
|
"error-plan-limit-reached": "E411. 制限に達しました",
|
|
112
112
|
"error-recaptcha-verification-failed": "Captcha 検証に失敗しました。もう一度試してください。",
|
|
113
113
|
"error-sending-sms-failed": "SMSの送信エラーがありました。もう一度やり直してください。",
|
|
114
|
+
"error-invalid-test-account": "無効なテストアカウント",
|
|
114
115
|
"something-wrong-error": "何かがうまくいかなかった"
|
|
115
116
|
};
|
|
116
117
|
var japanese = {
|
|
@@ -111,6 +111,7 @@ var passwordless = {
|
|
|
111
111
|
"error-plan-limit-reached": "E411. 제한에 도달했습니다",
|
|
112
112
|
"error-recaptcha-verification-failed": "Captcha 인증에 실패했습니다. 다시 시도해 주세요.",
|
|
113
113
|
"error-sending-sms-failed": "SMS 전송 중 오류가 발생했습니다. 다시 시도해 주세요.",
|
|
114
|
+
"error-invalid-test-account": "잘못된 테스트 계정입니다",
|
|
114
115
|
"something-wrong-error": "문제가 발생했습니다"
|
|
115
116
|
};
|
|
116
117
|
var korean = {
|
|
@@ -111,6 +111,7 @@ var passwordless = {
|
|
|
111
111
|
"error-plan-limit-reached": "E411. 限制已达到",
|
|
112
112
|
"error-recaptcha-verification-failed": "Captcha 验证失败。请再试一次。",
|
|
113
113
|
"error-sending-sms-failed": "发送短信的错误。请再试一遍。",
|
|
114
|
+
"error-invalid-test-account": "测试账户无效",
|
|
114
115
|
"something-wrong-error": "出问题了"
|
|
115
116
|
};
|
|
116
117
|
var mandarin = {
|
|
@@ -111,6 +111,7 @@ var passwordless = {
|
|
|
111
111
|
"error-plan-limit-reached": "E411. Limite atingido",
|
|
112
112
|
"error-recaptcha-verification-failed": "A verificação Captcha falhou. Por favor, tente novamente.",
|
|
113
113
|
"error-sending-sms-failed": "Houve um erro de envio de um SMS. Por favor, tente novamente.",
|
|
114
|
+
"error-invalid-test-account": "Conta de teste inválida",
|
|
114
115
|
"something-wrong-error": "Algo deu errado"
|
|
115
116
|
};
|
|
116
117
|
var portuguese = {
|
|
@@ -111,6 +111,7 @@ var passwordless = {
|
|
|
111
111
|
"error-plan-limit-reached": "E411. Límite alcanzado",
|
|
112
112
|
"error-recaptcha-verification-failed": "La verificación de Captcha ha fallado. Por favor, inténtelo de nuevo.",
|
|
113
113
|
"error-sending-sms-failed": "Hubo un error al enviar el SMS. Inténtalo de nuevo.",
|
|
114
|
+
"error-invalid-test-account": "Cuenta de prueba no válida",
|
|
114
115
|
"something-wrong-error": "Algo salió mal"
|
|
115
116
|
};
|
|
116
117
|
var spanish = {
|
|
@@ -111,6 +111,7 @@ var passwordless = {
|
|
|
111
111
|
"error-plan-limit-reached": "E411. Sınır aşıldı",
|
|
112
112
|
"error-recaptcha-verification-failed": "Captcha doğrulama hatası. Lütfen tekrar deneyin.",
|
|
113
113
|
"error-sending-sms-failed": "SMS gönderilirken bir hata oldu. Lütfen tekrar deneyin.",
|
|
114
|
+
"error-invalid-test-account": "Geçersiz test hesabı",
|
|
114
115
|
"something-wrong-error": "Bir şeyler ters gitti"
|
|
115
116
|
};
|
|
116
117
|
var turkish = {
|
|
@@ -149,6 +149,8 @@ const getErrorMessages = errorCode => {
|
|
|
149
149
|
return "passwordless.error-plan-limit-reached";
|
|
150
150
|
case "E412":
|
|
151
151
|
return "passwordless.error-recaptcha-verification-failed";
|
|
152
|
+
case "E502":
|
|
153
|
+
return "passwordless.error-invalid-test-account";
|
|
152
154
|
default:
|
|
153
155
|
return "passwordless.something-wrong-error";
|
|
154
156
|
}
|
|
@@ -5,7 +5,16 @@ export interface Web3AuthOptions extends IWeb3AuthCoreOptions {
|
|
|
5
5
|
/**
|
|
6
6
|
* Config for configuring modal ui display properties
|
|
7
7
|
*/
|
|
8
|
-
uiConfig
|
|
8
|
+
uiConfig: Omit<UIConfig, "connectorListener" | "logoLight" | "logoDark"> & {
|
|
9
|
+
/**
|
|
10
|
+
* App logo to use in light mode
|
|
11
|
+
*/
|
|
12
|
+
logoLight: string;
|
|
13
|
+
/**
|
|
14
|
+
* App logo to use in dark mode
|
|
15
|
+
*/
|
|
16
|
+
logoDark: string;
|
|
17
|
+
};
|
|
9
18
|
/**
|
|
10
19
|
* Config for configuring modal ui display properties
|
|
11
20
|
*/
|
|
@@ -28,6 +28,7 @@ export declare const defaultWagmiConfig: import("wagmi").Config<readonly [{
|
|
|
28
28
|
readonly symbol: "ETH";
|
|
29
29
|
readonly decimals: 18;
|
|
30
30
|
};
|
|
31
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
31
32
|
rpcUrls: {
|
|
32
33
|
readonly default: {
|
|
33
34
|
readonly http: readonly ["https://eth.merkle.io"];
|
|
@@ -2,8 +2,8 @@ import { PasswordlessHandlerParams } from "../interfaces";
|
|
|
2
2
|
import { PasswordlessHandler } from "./AbstractHandler";
|
|
3
3
|
export default class SmsPasswordlessHandler extends PasswordlessHandler {
|
|
4
4
|
constructor(params: PasswordlessHandlerParams);
|
|
5
|
-
sendVerificationCode(
|
|
6
|
-
captchaToken
|
|
5
|
+
sendVerificationCode({ captchaToken }: {
|
|
6
|
+
captchaToken?: string;
|
|
7
7
|
}): Promise<import("..").IStartResponse>;
|
|
8
8
|
verifyCode(code: string): Promise<import("..").IVerifyResponse>;
|
|
9
9
|
}
|
|
@@ -28,6 +28,7 @@ export declare const defaultWagmiConfig: import("wagmi").Config<readonly [{
|
|
|
28
28
|
readonly symbol: "ETH";
|
|
29
29
|
readonly decimals: 18;
|
|
30
30
|
};
|
|
31
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
31
32
|
rpcUrls: {
|
|
32
33
|
readonly default: {
|
|
33
34
|
readonly http: readonly ["https://eth.merkle.io"];
|
|
@@ -81,7 +81,10 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
81
81
|
return [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])];
|
|
82
82
|
});
|
|
83
83
|
this.options = _objectSpread({}, options);
|
|
84
|
-
if (!this.options.uiConfig) this.options.uiConfig = {
|
|
84
|
+
if (!this.options.uiConfig) this.options.uiConfig = {
|
|
85
|
+
logoLight: "",
|
|
86
|
+
logoDark: ""
|
|
87
|
+
};
|
|
85
88
|
if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
|
|
86
89
|
log.info("modalConfig", this.modalConfig);
|
|
87
90
|
}
|
|
@@ -231,9 +234,13 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
231
234
|
this.options.uiConfig = deepmerge(cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
|
|
232
235
|
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = getUserLanguage(this.options.uiConfig.defaultLanguage);
|
|
233
236
|
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
|
|
234
|
-
|
|
237
|
+
const uiConfig = deepmerge.all([projectConfig.loginModal || {}, this.options.uiConfig], {
|
|
235
238
|
arrayMerge: (_, sourceArray) => sourceArray
|
|
236
239
|
});
|
|
240
|
+
this.options.uiConfig = _objectSpread(_objectSpread({}, uiConfig), {}, {
|
|
241
|
+
logoLight: uiConfig.logoLight || "",
|
|
242
|
+
logoDark: uiConfig.logoDark || ""
|
|
243
|
+
});
|
|
237
244
|
|
|
238
245
|
// merge login methods order from project config and user config, with user config taking precedence
|
|
239
246
|
const defaultAuthConnections = projectConfig.embeddedWalletAuth.filter(x => x.isDefault).map(x => x.authConnection);
|
|
@@ -9,6 +9,7 @@ import { DEFAULT_LOGO_DARK, DEFAULT_LOGO_LIGHT } from '../../constants.js';
|
|
|
9
9
|
import { AnalyticsContext } from '../../context/AnalyticsContext.js';
|
|
10
10
|
import { RootContext } from '../../context/RootContext.js';
|
|
11
11
|
import { createPasswordlessHandler } from '../../handlers/factory.js';
|
|
12
|
+
import { isTestAccountPattern } from '../../helper/testAccounts.js';
|
|
12
13
|
import i18nInstance from '../../localeImport.js';
|
|
13
14
|
import { cn, getUserCountry, getIcons, validatePhoneNumber } from '../../utils.js';
|
|
14
15
|
import Image from '../Image/Image.js';
|
|
@@ -163,7 +164,6 @@ function Login(props) {
|
|
|
163
164
|
}, [socialLoginsConfig, isDark, buttonRadius]);
|
|
164
165
|
const handleCustomLogin = async (authConnection, loginHint) => {
|
|
165
166
|
try {
|
|
166
|
-
var _captchaRef$current;
|
|
167
167
|
const handler = createPasswordlessHandler(authConnection, {
|
|
168
168
|
loginHint,
|
|
169
169
|
web3authClientId,
|
|
@@ -172,13 +172,17 @@ function Login(props) {
|
|
|
172
172
|
authConnection,
|
|
173
173
|
authBuildEnv
|
|
174
174
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
let token = undefined;
|
|
176
|
+
if (!isTestAccountPattern(authConnection, loginHint)) {
|
|
177
|
+
var _captchaRef$current;
|
|
178
|
+
const res = await ((_captchaRef$current = captchaRef.current) === null || _captchaRef$current === void 0 ? void 0 : _captchaRef$current.execute({
|
|
179
|
+
async: true
|
|
180
|
+
}));
|
|
181
|
+
if (!res) {
|
|
182
|
+
throw WalletLoginError.connectionError("Captcha token is required");
|
|
183
|
+
}
|
|
184
|
+
token = res.response;
|
|
180
185
|
}
|
|
181
|
-
const token = res.response;
|
|
182
186
|
const result = await handler.sendVerificationCode({
|
|
183
187
|
captchaToken: token
|
|
184
188
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import { PasswordlessHandler } from './AbstractHandler.js';
|
|
3
3
|
|
|
4
4
|
class SmsPasswordlessHandler extends PasswordlessHandler {
|
|
@@ -9,18 +9,15 @@ class SmsPasswordlessHandler extends PasswordlessHandler {
|
|
|
9
9
|
this.trackingId = (_window$sessionStorag = window.sessionStorage.getItem("trackingId")) !== null && _window$sessionStorag !== void 0 ? _window$sessionStorag : undefined;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
async sendVerificationCode(
|
|
13
|
-
|
|
12
|
+
async sendVerificationCode({
|
|
13
|
+
captchaToken
|
|
14
|
+
}) {
|
|
14
15
|
const {
|
|
15
16
|
loginHint,
|
|
16
17
|
network,
|
|
17
18
|
web3authClientId
|
|
18
19
|
} = this.passwordlessParams;
|
|
19
|
-
const
|
|
20
|
-
if (!captchaToken) {
|
|
21
|
-
throw WalletLoginError.connectionError("Captcha token is required");
|
|
22
|
-
}
|
|
23
|
-
const finalParams = {
|
|
20
|
+
const finalParams = _objectSpread({
|
|
24
21
|
client_id: web3authClientId,
|
|
25
22
|
web3auth_client_id: web3authClientId,
|
|
26
23
|
connection: this.connection,
|
|
@@ -28,9 +25,10 @@ class SmsPasswordlessHandler extends PasswordlessHandler {
|
|
|
28
25
|
tracking_id: this.trackingId,
|
|
29
26
|
whitelabel: this.whiteLabelParams,
|
|
30
27
|
version: this.version,
|
|
31
|
-
network
|
|
28
|
+
network
|
|
29
|
+
}, captchaToken && {
|
|
32
30
|
captcha_token: captchaToken
|
|
33
|
-
};
|
|
31
|
+
});
|
|
34
32
|
return super.start(finalParams);
|
|
35
33
|
}
|
|
36
34
|
async verifyCode(code) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AUTH_CONNECTION } from '@web3auth/auth';
|
|
2
|
+
import { WalletInitializationError } from '@web3auth/no-modal';
|
|
3
|
+
|
|
4
|
+
const EMAIL_TEST_ACCOUNT_PREFIX = "test_account_";
|
|
5
|
+
const EMAIL_TEST_ACCOUNT_POSTFIX = "@example.com";
|
|
6
|
+
const PHONE_TEST_ACCOUNT_PREFIX = "+1-555";
|
|
7
|
+
const isTestAccountPattern = (authConnection, loginHint) => {
|
|
8
|
+
if (authConnection === AUTH_CONNECTION.EMAIL_PASSWORDLESS) {
|
|
9
|
+
return loginHint.startsWith(EMAIL_TEST_ACCOUNT_PREFIX) && loginHint.endsWith(EMAIL_TEST_ACCOUNT_POSTFIX);
|
|
10
|
+
} else if (authConnection === AUTH_CONNECTION.SMS_PASSWORDLESS) {
|
|
11
|
+
return loginHint.startsWith(PHONE_TEST_ACCOUNT_PREFIX);
|
|
12
|
+
}
|
|
13
|
+
throw WalletInitializationError.invalidParams(`Unsupported auth connection: ${authConnection}`);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { isTestAccountPattern };
|
|
@@ -107,6 +107,7 @@ var passwordless = {
|
|
|
107
107
|
"error-plan-limit-reached": "E411. Limiet bereikt",
|
|
108
108
|
"error-recaptcha-verification-failed": "Er is iets misgegaan tijdens het verifiëren. Probeer het opnieuw door de pagina te laden.",
|
|
109
109
|
"error-sending-sms-failed": "Er is een fout opgetreden bij het verzenden van een sms. Probeer het opnieuw.",
|
|
110
|
+
"error-invalid-test-account": "Ongeldig testaccount",
|
|
110
111
|
"something-wrong-error": "Er is iets misgegaan"
|
|
111
112
|
};
|
|
112
113
|
var dutch = {
|
|
@@ -107,6 +107,7 @@ var passwordless = {
|
|
|
107
107
|
"error-plan-limit-reached": "E411. Limit Reached",
|
|
108
108
|
"error-recaptcha-verification-failed": "Captcha verification failed. Please try again.",
|
|
109
109
|
"error-sending-sms-failed": "There was an error sending an sms. Please try again.",
|
|
110
|
+
"error-invalid-test-account": "Invalid test account",
|
|
110
111
|
"something-wrong-error": "Something went wrong"
|
|
111
112
|
};
|
|
112
113
|
var en = {
|
|
@@ -105,6 +105,7 @@ var passwordless = {
|
|
|
105
105
|
"error-plan-limit-reached": "E411. Limite atteinte",
|
|
106
106
|
"error-recaptcha-verification-failed": "La vérification Captcha a échoué. Veuillez réessayer.",
|
|
107
107
|
"error-sending-sms-failed": "Une erreur s'est produite lors de l'envoi d'un SMS. Veuillez réessayer.",
|
|
108
|
+
"error-invalid-test-account": "Compte de test non valide",
|
|
108
109
|
"something-wrong-error": "Quelque chose s'est mal passé"
|
|
109
110
|
};
|
|
110
111
|
var french = {
|
|
@@ -107,6 +107,7 @@ var passwordless = {
|
|
|
107
107
|
"error-plan-limit-reached": "E411. Grenze erreicht",
|
|
108
108
|
"error-recaptcha-verification-failed": "Die Captcha-Überprüfung ist fehlgeschlagen. Bitte versuchen Sie es erneut.",
|
|
109
109
|
"error-sending-sms-failed": "Es gab einen Fehler beim Senden einer SMS. Bitte versuche es erneut.",
|
|
110
|
+
"error-invalid-test-account": "Ungültiges Testkonto",
|
|
110
111
|
"something-wrong-error": "Etwas ist schief gelaufen"
|
|
111
112
|
};
|
|
112
113
|
var german = {
|
|
@@ -107,6 +107,7 @@ var passwordless = {
|
|
|
107
107
|
"error-plan-limit-reached": "E411. 制限に達しました",
|
|
108
108
|
"error-recaptcha-verification-failed": "Captcha 検証に失敗しました。もう一度試してください。",
|
|
109
109
|
"error-sending-sms-failed": "SMSの送信エラーがありました。もう一度やり直してください。",
|
|
110
|
+
"error-invalid-test-account": "無効なテストアカウント",
|
|
110
111
|
"something-wrong-error": "何かがうまくいかなかった"
|
|
111
112
|
};
|
|
112
113
|
var japanese = {
|
|
@@ -107,6 +107,7 @@ var passwordless = {
|
|
|
107
107
|
"error-plan-limit-reached": "E411. 제한에 도달했습니다",
|
|
108
108
|
"error-recaptcha-verification-failed": "Captcha 인증에 실패했습니다. 다시 시도해 주세요.",
|
|
109
109
|
"error-sending-sms-failed": "SMS 전송 중 오류가 발생했습니다. 다시 시도해 주세요.",
|
|
110
|
+
"error-invalid-test-account": "잘못된 테스트 계정입니다",
|
|
110
111
|
"something-wrong-error": "문제가 발생했습니다"
|
|
111
112
|
};
|
|
112
113
|
var korean = {
|
|
@@ -107,6 +107,7 @@ var passwordless = {
|
|
|
107
107
|
"error-plan-limit-reached": "E411. 限制已达到",
|
|
108
108
|
"error-recaptcha-verification-failed": "Captcha 验证失败。请再试一次。",
|
|
109
109
|
"error-sending-sms-failed": "发送短信的错误。请再试一遍。",
|
|
110
|
+
"error-invalid-test-account": "测试账户无效",
|
|
110
111
|
"something-wrong-error": "出问题了"
|
|
111
112
|
};
|
|
112
113
|
var mandarin = {
|
|
@@ -107,6 +107,7 @@ var passwordless = {
|
|
|
107
107
|
"error-plan-limit-reached": "E411. Limite atingido",
|
|
108
108
|
"error-recaptcha-verification-failed": "A verificação Captcha falhou. Por favor, tente novamente.",
|
|
109
109
|
"error-sending-sms-failed": "Houve um erro de envio de um SMS. Por favor, tente novamente.",
|
|
110
|
+
"error-invalid-test-account": "Conta de teste inválida",
|
|
110
111
|
"something-wrong-error": "Algo deu errado"
|
|
111
112
|
};
|
|
112
113
|
var portuguese = {
|
|
@@ -107,6 +107,7 @@ var passwordless = {
|
|
|
107
107
|
"error-plan-limit-reached": "E411. Límite alcanzado",
|
|
108
108
|
"error-recaptcha-verification-failed": "La verificación de Captcha ha fallado. Por favor, inténtelo de nuevo.",
|
|
109
109
|
"error-sending-sms-failed": "Hubo un error al enviar el SMS. Inténtalo de nuevo.",
|
|
110
|
+
"error-invalid-test-account": "Cuenta de prueba no válida",
|
|
110
111
|
"something-wrong-error": "Algo salió mal"
|
|
111
112
|
};
|
|
112
113
|
var spanish = {
|
|
@@ -107,6 +107,7 @@ var passwordless = {
|
|
|
107
107
|
"error-plan-limit-reached": "E411. Sınır aşıldı",
|
|
108
108
|
"error-recaptcha-verification-failed": "Captcha doğrulama hatası. Lütfen tekrar deneyin.",
|
|
109
109
|
"error-sending-sms-failed": "SMS gönderilirken bir hata oldu. Lütfen tekrar deneyin.",
|
|
110
|
+
"error-invalid-test-account": "Geçersiz test hesabı",
|
|
110
111
|
"something-wrong-error": "Bir şeyler ters gitti"
|
|
111
112
|
};
|
|
112
113
|
var turkish = {
|
|
@@ -151,6 +151,8 @@ const getErrorMessages = errorCode => {
|
|
|
151
151
|
return "passwordless.error-plan-limit-reached";
|
|
152
152
|
case "E412":
|
|
153
153
|
return "passwordless.error-recaptcha-verification-failed";
|
|
154
|
+
case "E502":
|
|
155
|
+
return "passwordless.error-invalid-test-account";
|
|
154
156
|
default:
|
|
155
157
|
return "passwordless.something-wrong-error";
|
|
156
158
|
}
|